Compare commits
9 commits
2a5cd3f4a8
...
39a4bd035a
Author | SHA1 | Date | |
---|---|---|---|
|
39a4bd035a | ||
|
19f0a5d022 | ||
|
9e1f307d5b | ||
|
8f2be6b456 | ||
|
e117e19744 | ||
|
12df54420b | ||
|
950a7b5631 | ||
|
428be25c0e | ||
|
1429fb29bd |
1
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
||||||
# Build files
|
# Build files
|
||||||
/build-fx
|
/build-fx
|
||||||
|
/build-fxg3a
|
||||||
/build-cg
|
/build-cg
|
||||||
/build-cg-push
|
/build-cg-push
|
||||||
/*.g1a
|
/*.g1a
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
cmake_minimum_required(VERSION 3.15)
|
cmake_minimum_required(VERSION 3.15)
|
||||||
project(Copy3DEngine LANGUAGES C ASM)
|
project(Copy3DEngine LANGUAGES C ASM)
|
||||||
|
|
||||||
|
include(GenerateG1A)
|
||||||
include(GenerateG3A)
|
include(GenerateG3A)
|
||||||
include(Fxconv)
|
include(Fxconv)
|
||||||
find_package(Gint 2.9 REQUIRED)
|
find_package(Gint 2.9 REQUIRED)
|
||||||
|
@ -16,26 +17,31 @@ set(AUTHOR "Fcalva")
|
||||||
|
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
src/main.c
|
src/main.c
|
||||||
src/moteur.c
|
eng/moteur.c
|
||||||
src/map.c
|
eng/map.c
|
||||||
# src/opti.S
|
eng/sprites.c
|
||||||
)
|
)
|
||||||
|
|
||||||
set(ASSETS
|
set(ASSETS
|
||||||
assets-cg/textures/briques0.png
|
assets-fx/sprite.png
|
||||||
assets-cg/textures/buisson1.png
|
assets-fx/textures/briques0.png
|
||||||
|
assets-fx/textures/buisson1.png
|
||||||
)
|
)
|
||||||
|
|
||||||
fxconv_declare_assets(${ASSETS} WITH_METADATA)
|
fxconv_declare_assets(${ASSETS} WITH_METADATA)
|
||||||
|
|
||||||
add_executable(Copy3DEngine ${SOURCES} ${ASSETS})
|
add_executable(Copy3DEngine ${SOURCES} ${ASSETS})
|
||||||
target_compile_options(Copy3DEngine PRIVATE -Wall -Wextra -Ofast)
|
target_compile_options(Copy3DEngine PRIVATE -Wall -Wextra -Ofast)
|
||||||
|
target_include_directories(Copy3DEngine PRIVATE "include/C3D/")
|
||||||
target_compile_definitions(Copy3DEngine PRIVATE NAMEOFGAME="${NAMEOFGAME}" AUTHOR="${AUTHOR}")
|
target_compile_definitions(Copy3DEngine PRIVATE NAMEOFGAME="${NAMEOFGAME}" AUTHOR="${AUTHOR}")
|
||||||
target_link_libraries(Copy3DEngine Gint::Gint)
|
target_link_libraries(Copy3DEngine Gint::Gint)
|
||||||
target_link_libraries(Copy3DEngine LibProf::LibProf)
|
target_link_libraries(Copy3DEngine LibProf::LibProf)
|
||||||
target_link_options(Copy3DEngine PRIVATE -Wl,--print-memory-usage)
|
target_link_options(Copy3DEngine PRIVATE -Wl,--print-memory-usage)
|
||||||
|
|
||||||
if("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50)
|
if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G)
|
||||||
generate_g3a(TARGET Copy3DEngine OUTPUT "${NAMEOFGAME}.g3a"
|
generate_g1a(TARGET Copy3DEngine OUTPUT ${NAMEOFGAME}".g1a"
|
||||||
NAME "${NAMEOFGAME}" ICONS assets-cg/icon-uns.png assets-cg/icon-sel.png)
|
NAME ${NAMEOFGAME} ICON assets-fx/icon.png)
|
||||||
|
else()
|
||||||
|
generate_g3a(TARGET Copy3DEngine OUTPUT ${NAMEOFGAME}".g3a"
|
||||||
|
NAME ${NAMEOFGAME} ICONS assets-fx/icon.png assets-fx/icon.png)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
# Configure with [fxsdk build-fx] or [fxsdk build-cg], which provide the
|
|
||||||
# toolchain file and module path of the fxSDK
|
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.15)
|
|
||||||
project(Copy3DEngine)
|
|
||||||
|
|
||||||
include(GenerateG3A)
|
|
||||||
include(Fxconv)
|
|
||||||
find_package(Gint 2.9 REQUIRED)
|
|
||||||
find_package(LibProf 2.1 REQUIRED)
|
|
||||||
|
|
||||||
# le nom de votre jeu
|
|
||||||
set(NAMEOFGAME "Amogus")
|
|
||||||
# Nom de l'auteur -> votre nom/pseudo
|
|
||||||
set(AUTHOR "Fcalva")
|
|
||||||
|
|
||||||
set(SOURCES
|
|
||||||
src/main.c
|
|
||||||
src/moteur.c
|
|
||||||
src/map.c
|
|
||||||
)
|
|
||||||
|
|
||||||
set(ASSETS
|
|
||||||
assets-cg/textures/0.png
|
|
||||||
assets-cg/textures/1.png
|
|
||||||
assets-cg/textures/2.png
|
|
||||||
assets-cg/textures/3.png
|
|
||||||
assets-cg/textures/4.png
|
|
||||||
assets-cg/textures/rick.png
|
|
||||||
)
|
|
||||||
|
|
||||||
fxconv_declare_assets(${ASSETS} WITH_METADATA)
|
|
||||||
|
|
||||||
add_executable(Copy3DEngine ${SOURCES} ${ASSETS})
|
|
||||||
target_compile_options(Copy3DEngine PRIVATE -Wall -Wextra -Ofast -fira-region=all -flto -fno-math-errno -funsafe-math-optimizations -fassociative-math -freciprocal-math)
|
|
||||||
target_compile_definitions(Copy3DEngine PRIVATE NAMEOFGAME="${NAMEOFGAME}" AUTHOR="${AUTHOR}")
|
|
||||||
target_link_libraries(Copy3DEngine Gint::Gint)
|
|
||||||
target_link_libraries(Copy3DEngine LibProf::LibProf)
|
|
||||||
target_link_options(Copy3DEngine PRIVATE -Wl,--print-memory-usage,-flto)
|
|
||||||
|
|
||||||
if("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50)
|
|
||||||
generate_g3a(TARGET Copy3DEngine OUTPUT "${NAMEOFGAME}.g3a"
|
|
||||||
NAME "${NAMEOFGAME}" ICONS assets-cg/icon-uns.png assets-cg/icon-sel.png)
|
|
||||||
endif()
|
|
|
@ -1,5 +0,0 @@
|
||||||
# Amogus
|
|
||||||
|
|
||||||
### Mogus
|
|
||||||
|
|
||||||
Sus
|
|
|
@ -1,6 +0,0 @@
|
||||||
zombard1.png:
|
|
||||||
type: bopti-image
|
|
||||||
name: zombard
|
|
||||||
skybox0.png:
|
|
||||||
type: bopti-image
|
|
||||||
name: skybox_quarter
|
|
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 9.7 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 10 KiB |
|
@ -1,19 +0,0 @@
|
||||||
0.png:
|
|
||||||
type: bopti-image
|
|
||||||
name: frame0
|
|
||||||
1.png:
|
|
||||||
type: bopti-image
|
|
||||||
name: frame1
|
|
||||||
2.png:
|
|
||||||
type: bopti-image
|
|
||||||
name: frame2
|
|
||||||
3.png:
|
|
||||||
type: bopti-image
|
|
||||||
name: frame3
|
|
||||||
4.png:
|
|
||||||
type: bopti-image
|
|
||||||
name: frame4
|
|
||||||
|
|
||||||
rick.png:
|
|
||||||
type: bopti-image
|
|
||||||
name: rick
|
|
Before Width: | Height: | Size: 9.6 KiB |
|
@ -1,87 +0,0 @@
|
||||||
//---
|
|
||||||
// fixed: 16:16 fixed-point arithmetic
|
|
||||||
//---
|
|
||||||
//vient de https://gitea.planet-casio.com/Slyvtt/OutRun/src/branch/master/src
|
|
||||||
//
|
|
||||||
#pragma once
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
typedef int32_t fixed_t;
|
|
||||||
/* Standard arithmetic. */
|
|
||||||
|
|
||||||
static inline fixed_t fmul(fixed_t left, fixed_t right)
|
|
||||||
{
|
|
||||||
/* Generally optimized by the compiler to use dmuls.l and xtrct */
|
|
||||||
int64_t p = (int64_t)left * (int64_t)right;
|
|
||||||
return (int32_t)(p >> 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline fixed_t fdiv(fixed_t left, fixed_t right)
|
|
||||||
{
|
|
||||||
/* Pretty slow */
|
|
||||||
int64_t d = (int64_t)left << 16;
|
|
||||||
return d / right;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define fix(x) ((int)((x) * 65536))
|
|
||||||
|
|
||||||
static inline fixed_t fixdouble(double constant)
|
|
||||||
{
|
|
||||||
return (fixed_t)(constant * 65536);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline fixed_t fixfloat(float constant)
|
|
||||||
{
|
|
||||||
return (fixed_t)(constant * 65536);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline fixed_t fdec(fixed_t f)
|
|
||||||
{
|
|
||||||
return f & 0xffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int ffloor(fixed_t f)
|
|
||||||
{
|
|
||||||
return f >> 16;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int fceil(fixed_t f)
|
|
||||||
{
|
|
||||||
return (f + 0xffff) >> 16;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int fround(fixed_t f)
|
|
||||||
{
|
|
||||||
return (f + 0x8000) >> 16;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline float f2float(fixed_t f)
|
|
||||||
{
|
|
||||||
return (float)f / 65536;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline double f2double(fixed_t f)
|
|
||||||
{
|
|
||||||
return (double)f / 65536;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline double f2int(fixed_t f)
|
|
||||||
{
|
|
||||||
return (int)f / 65536;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline fixed_t feasein(fixed_t x)
|
|
||||||
{
|
|
||||||
return fmul(x, x);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline fixed_t fease(fixed_t x)
|
|
||||||
{
|
|
||||||
if(x <= fix(0.5)) {
|
|
||||||
return 2 * fmul(x, x);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
x = fix(1) - x;
|
|
||||||
return fix(1) - 2 * fmul(x, x);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,166 +0,0 @@
|
||||||
#include <stdlib.h>
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
#include <gint/display.h>
|
|
||||||
#include <gint/keyboard.h>
|
|
||||||
#include <gint/image.h>
|
|
||||||
#include <libprof.h>
|
|
||||||
|
|
||||||
#include "fixed.h"
|
|
||||||
|
|
||||||
#include "moteur.h"
|
|
||||||
#include "map.h"
|
|
||||||
|
|
||||||
//====== Copy3DEngine =====
|
|
||||||
// Git du moteur : https://gitea.planet-casio.com/Fcalva/Copy3DEngine
|
|
||||||
// Git du jeu : [Rajoutez le vôtre ici]
|
|
||||||
//
|
|
||||||
// Page du jeu : [La vôtre ici]
|
|
||||||
//
|
|
||||||
// Voir README.md pour license précise, par Fcalva et est sous GPLv3
|
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef FXCG50
|
|
||||||
#error Ce code est pour FXCG50/G90+E uniquement, enlevez ce message a vos riques et périls
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//#define debug //pour afficher les infos de debug
|
|
||||||
|
|
||||||
image_t *tex_index[TINDEX_S];
|
|
||||||
|
|
||||||
extern char map_test[map_w][map_h];
|
|
||||||
|
|
||||||
//Vos images ici
|
|
||||||
|
|
||||||
extern image_t frame0;
|
|
||||||
extern image_t frame1;
|
|
||||||
extern image_t frame2;
|
|
||||||
extern image_t frame3;
|
|
||||||
extern image_t frame4;
|
|
||||||
|
|
||||||
extern image_t rick;
|
|
||||||
|
|
||||||
char exit_game = 0;
|
|
||||||
char disp_frame_time = 0;
|
|
||||||
char first_frame = 0;
|
|
||||||
int frame_time_timer = 1;
|
|
||||||
|
|
||||||
fixed_t posX;
|
|
||||||
fixed_t posY;
|
|
||||||
fixed_t dirX;
|
|
||||||
fixed_t dirY;
|
|
||||||
fixed_t planeX;
|
|
||||||
fixed_t planeY;
|
|
||||||
|
|
||||||
int frame_time = 1;
|
|
||||||
|
|
||||||
void keys_get(){
|
|
||||||
pollevent();
|
|
||||||
|
|
||||||
move();
|
|
||||||
|
|
||||||
if (keydown(KEY_F1) && frame_time_timer <= 0) {
|
|
||||||
if (disp_frame_time == 0) {
|
|
||||||
disp_frame_time = 1;
|
|
||||||
frame_time_timer = 10;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
disp_frame_time = 0;
|
|
||||||
frame_time_timer = 10;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
frame_time_timer--;
|
|
||||||
if (keydown(KEY_EXIT)) exit_game = 1;
|
|
||||||
|
|
||||||
#ifdef debug
|
|
||||||
if (keydown(KEY_TAN)) end_screen();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void main_menu(){
|
|
||||||
//dtext_opt(198, 100, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, NAMEOFGAME, -1);
|
|
||||||
//dtext_opt(198, 120, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, "De " AUTHOR, -1);
|
|
||||||
dtext_opt(198, 150, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, "Appuyez sur une touche", -1);
|
|
||||||
|
|
||||||
dupdate();
|
|
||||||
getkey();
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(){
|
|
||||||
dclear(C_WHITE);
|
|
||||||
|
|
||||||
//trucs de chargement
|
|
||||||
|
|
||||||
load_map();
|
|
||||||
|
|
||||||
image_t *frame_buffer = image_create_vram();
|
|
||||||
|
|
||||||
extern image_t *tex_index[TINDEX_S];
|
|
||||||
|
|
||||||
tex_index[1] = &frame0;
|
|
||||||
tex_index[2] = &rick;
|
|
||||||
|
|
||||||
//Vos textures générées procéduralement
|
|
||||||
|
|
||||||
tex_index[0] = image_alloc(64, 64, IMAGE_RGB565);
|
|
||||||
tex_index[3] = image_alloc(64, 64, IMAGE_RGB565);
|
|
||||||
|
|
||||||
image_fill(tex_index[0], 0x4228);
|
|
||||||
image_fill(tex_index[3], 0x9dbd);
|
|
||||||
|
|
||||||
prof_init();
|
|
||||||
|
|
||||||
int anim_timer = 0;
|
|
||||||
|
|
||||||
while (!exit_game) {
|
|
||||||
prof_t frame = prof_make();
|
|
||||||
prof_enter(frame);
|
|
||||||
|
|
||||||
drect(0, 0, 395, 112, 0x9dbd);
|
|
||||||
drect(0,112, 395, 243, 0x4228);
|
|
||||||
|
|
||||||
switch((anim_timer/62)%5){
|
|
||||||
case 0: tex_index[1] = &frame0; break;
|
|
||||||
case 1: tex_index[1] = &frame1; break;
|
|
||||||
case 2: tex_index[1] = &frame2; break;
|
|
||||||
case 3: tex_index[1] = &frame3; break;
|
|
||||||
case 4: tex_index[1] = &frame4; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
draw_walls(frame_buffer);
|
|
||||||
|
|
||||||
if(first_frame == 1){
|
|
||||||
main_menu();
|
|
||||||
}
|
|
||||||
|
|
||||||
keys_get();
|
|
||||||
|
|
||||||
if (disp_frame_time == 1) dprint( 1, 10, C_BLACK, "Frame time : %d ms", frame_time);
|
|
||||||
|
|
||||||
#ifdef debug
|
|
||||||
dprint( 1, 20, C_BLACK, "planeX : %d", planeX);
|
|
||||||
dprint( 1, 30, C_BLACK, "planeY : %d", planeY);
|
|
||||||
dprint( 1, 40, C_BLACK, "dirX : %d", dirX);
|
|
||||||
dprint( 1, 50, C_BLACK, "dirY : %d", dirY);
|
|
||||||
dprint( 1, 60, C_BLACK, "posX : %d", posX);
|
|
||||||
dprint( 1, 70, C_BLACK, "posY : %d", posY);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
dupdate();
|
|
||||||
prof_leave(frame);
|
|
||||||
frame_time = (int)prof_time(frame)/1000;
|
|
||||||
first_frame = 0;
|
|
||||||
|
|
||||||
anim_timer += frame_time;
|
|
||||||
}
|
|
||||||
|
|
||||||
prof_quit();
|
|
||||||
|
|
||||||
//Libérez vos textures générées procéduralement
|
|
||||||
|
|
||||||
image_free(tex_index[0]);
|
|
||||||
image_free(tex_index[3]);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
|
@ -1,71 +0,0 @@
|
||||||
// Voir README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0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,1,0,1,0,0,0,0,1,0,1,0,1,0,0,1,0,0,0,1,0,1,0,1,0,0,1,0,0,0,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,0,1,0,0,0,1,1,1,0,0,0,1,0,1,0,0,0,1,1,0,0,1,1,0,1,0,0,0,1,1,0,1,1,0,1},
|
|
||||||
{1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0,1,0,0,1,0,0,1,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,1,0,0,0,0,0,0,1,0,0,1},
|
|
||||||
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
|
|
||||||
};
|
|
|
@ -1,325 +0,0 @@
|
||||||
// Voir README.md pour license précise, par Fcalva 2023-2024 et est sous GPLv3
|
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#include <gint/display.h>
|
|
||||||
#include <gint/keyboard.h>
|
|
||||||
#include <libprof.h>
|
|
||||||
|
|
||||||
#include "fixed.h"
|
|
||||||
|
|
||||||
#include "moteur.h"
|
|
||||||
#include "map.h"
|
|
||||||
|
|
||||||
// moteur.c :
|
|
||||||
// ici se trouvent tout ce qui concerne les graphismes, mouvement et collisions
|
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
void move() {
|
|
||||||
extern int frame_time;
|
|
||||||
fixed_t moveSpeed = fmul(fix(frame_time), 0x148); //frame_time * fix(carrés/seconde/1000) là carrés/seconde = 5
|
|
||||||
fixed_t rotSpeed = fmul(fix(frame_time), 0x83); //frame_time * fix(radians/seconde/1000) là radians/seconde = 2
|
|
||||||
fixed_t c_rotSpeed = fix(cos(f2float(rotSpeed)));
|
|
||||||
fixed_t s_rotSpeed = fix(sin(f2float(rotSpeed)));
|
|
||||||
|
|
||||||
extern char map_test[map_w][map_h];
|
|
||||||
extern fixed_t planeX;
|
|
||||||
extern fixed_t planeY;
|
|
||||||
extern fixed_t dirX;
|
|
||||||
extern fixed_t dirY;
|
|
||||||
extern fixed_t posX;
|
|
||||||
extern fixed_t posY;
|
|
||||||
|
|
||||||
fixed_t oldDirX;
|
|
||||||
fixed_t oldPlaneX;
|
|
||||||
int xtemp1;
|
|
||||||
int ytemp1;
|
|
||||||
int xtemp2;
|
|
||||||
int ytemp2;
|
|
||||||
|
|
||||||
if (keydown(KEY_UP)) {
|
|
||||||
xtemp1 = f2int(posX + fmul(dirX, moveSpeed));
|
|
||||||
ytemp1 = f2int(posY);
|
|
||||||
xtemp2 = f2int(posX);
|
|
||||||
ytemp2 = f2int(posY + fmul(dirY, moveSpeed));
|
|
||||||
|
|
||||||
if(map_test[xtemp1][ytemp1] == 0) posX += fmul(dirX, moveSpeed);
|
|
||||||
if(map_test[xtemp2][ytemp2] == 0) posY += fmul(dirY, moveSpeed);
|
|
||||||
}
|
|
||||||
//move backwards if no wall behind you
|
|
||||||
if (keydown(KEY_DOWN)) {
|
|
||||||
xtemp1 = f2int(posX - fmul(dirX, moveSpeed));
|
|
||||||
ytemp1 = f2int(posY);
|
|
||||||
xtemp2 = f2int(posX);
|
|
||||||
ytemp2 = f2int(posY - fmul(dirY, moveSpeed));
|
|
||||||
|
|
||||||
if(map_test[xtemp1][ytemp1] == 0) posX -= fmul(dirX, moveSpeed);
|
|
||||||
if(map_test[xtemp2][ytemp2] == 0) posY -= fmul(dirY, moveSpeed);
|
|
||||||
}
|
|
||||||
//rotate to the rightdouble sin_rotspeed;
|
|
||||||
if (keydown(KEY_RIGHT)) {
|
|
||||||
//both camera direction and camera plane must be rotated
|
|
||||||
oldDirX = dirX;
|
|
||||||
dirX = (fmul(dirX, c_rotSpeed)+1) - (fmul(dirY, -s_rotSpeed)+1);
|
|
||||||
dirY = (fmul(oldDirX, -s_rotSpeed)+1) + (fmul(dirY, c_rotSpeed)+1);
|
|
||||||
oldPlaneX = planeX;
|
|
||||||
planeX = (fmul(planeX, c_rotSpeed)+1) - (fmul(planeY, -s_rotSpeed)+1);
|
|
||||||
planeY = (fmul(oldPlaneX, -s_rotSpeed)+1) + (fmul(planeY, c_rotSpeed)+1);
|
|
||||||
}
|
|
||||||
//rotate to the left
|
|
||||||
if (keydown(KEY_LEFT)) {
|
|
||||||
//both camera direction and camera plane must be rotated
|
|
||||||
oldDirX = dirX;
|
|
||||||
dirX = (fmul(dirX, c_rotSpeed)-1) - (fmul(dirY, s_rotSpeed)-1);
|
|
||||||
dirY = (fmul(oldDirX, s_rotSpeed)+1) + (fmul(dirY, c_rotSpeed)+1);
|
|
||||||
oldPlaneX = planeX;
|
|
||||||
planeX = (fmul(planeX, c_rotSpeed)-1) - (fmul(planeY, s_rotSpeed) - 1);
|
|
||||||
planeY = (fmul(oldPlaneX, s_rotSpeed)+1) + (fmul(planeY, c_rotSpeed) + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dirX > 0xFFFF) dirX = 0xFFFF;
|
|
||||||
if (dirY > 0xFFFF) dirY = 0xFFFF;
|
|
||||||
if (dirX < -0xFFFF) dirX = -0xFFFF;
|
|
||||||
if (dirY < -0xFFFF) dirY = -0xFFFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
void spawn_gen(){
|
|
||||||
extern fixed_t posX;
|
|
||||||
extern fixed_t posY;
|
|
||||||
extern fixed_t dirX;
|
|
||||||
extern fixed_t dirY;
|
|
||||||
extern fixed_t planeX;
|
|
||||||
extern fixed_t planeY;
|
|
||||||
extern char map_test[map_w][map_h];
|
|
||||||
|
|
||||||
int seed, seed_x, seed_y;
|
|
||||||
int SeedSeed;
|
|
||||||
|
|
||||||
time_t timeN;
|
|
||||||
time(&timeN);
|
|
||||||
SeedSeed = timeN;
|
|
||||||
|
|
||||||
srand(SeedSeed);
|
|
||||||
|
|
||||||
while(1){
|
|
||||||
seed = rand() * 0.5 + rand() * 0.5;
|
|
||||||
seed_x = seed & 0b1111111;
|
|
||||||
seed_y = (seed >> 8) & 0b111111;
|
|
||||||
if (seed_x < map_w && seed_y < map_h && (seed_x < 111 && seed_y > 15)){
|
|
||||||
if(map_test[seed_x][seed_y] == 0){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fixed_t start_dirX, start_dirY;
|
|
||||||
|
|
||||||
int dirSeed = (seed >> 9) & 0b11 ;
|
|
||||||
switch(dirSeed){
|
|
||||||
case 0: {
|
|
||||||
start_dirX = 0x0;
|
|
||||||
start_dirY = 0xFFFF;
|
|
||||||
planeX = fix(0.66);
|
|
||||||
planeY = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1: {
|
|
||||||
start_dirX = 0xFFFF;
|
|
||||||
start_dirY = 0x0;
|
|
||||||
planeX = 0;
|
|
||||||
planeY = fix(-0.66);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 2: {
|
|
||||||
start_dirX = -0xFFFF;
|
|
||||||
start_dirY = 0x0;
|
|
||||||
planeX = 0;
|
|
||||||
planeY = fix(0.66);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 3: {
|
|
||||||
start_dirX = 0x0;
|
|
||||||
start_dirY = -0xFFFF;
|
|
||||||
planeX = fix(-0.66);
|
|
||||||
planeY = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default : {
|
|
||||||
start_dirX = 0xFFFF;
|
|
||||||
start_dirY = 0x0;
|
|
||||||
planeX = 0;
|
|
||||||
planeY = fix(-0.66);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
posX = fix(seed_x) + 0x7FFF;
|
|
||||||
posY = fix(seed_y) + 0x7FFF; //x and y start position
|
|
||||||
dirX = start_dirX;
|
|
||||||
dirY = start_dirY; //initial direction vector
|
|
||||||
}
|
|
||||||
|
|
||||||
void load_map(){
|
|
||||||
spawn_gen();
|
|
||||||
}
|
|
||||||
|
|
||||||
void draw_walls(image_t *frame_buffer){
|
|
||||||
extern fixed_t posX;
|
|
||||||
extern fixed_t posY;
|
|
||||||
extern fixed_t dirX;
|
|
||||||
extern fixed_t dirY;
|
|
||||||
extern fixed_t planeX;
|
|
||||||
extern fixed_t planeY;
|
|
||||||
extern image_t *tex_index[TINDEX_S];
|
|
||||||
extern char map_test[map_w][map_h];
|
|
||||||
|
|
||||||
fixed_t cameraX;
|
|
||||||
fixed_t rayDirX;
|
|
||||||
fixed_t rayDirY;
|
|
||||||
fixed_t sideDistX;//length of ray from current position to next x or y-side
|
|
||||||
fixed_t sideDistY;
|
|
||||||
fixed_t deltaDistX;
|
|
||||||
fixed_t deltaDistY;
|
|
||||||
fixed_t perpWallDist;
|
|
||||||
fixed_t texSize;
|
|
||||||
int x;
|
|
||||||
int mapX;
|
|
||||||
int mapY;
|
|
||||||
int stepX; //what direction to step in x or y-direction (either +1 or -1)
|
|
||||||
int stepY;
|
|
||||||
int side; //was a NS or a EW wall hit?
|
|
||||||
int lineHeight;
|
|
||||||
int texX;
|
|
||||||
int texSample;
|
|
||||||
int texSampleY;
|
|
||||||
|
|
||||||
int v_offset = 0; //(int)(sin(f2int(posX + posY)) * 5); //a raffiner un peu
|
|
||||||
fixed_t h_offset = 0; //fix(sin(f2int(posX - posY)) * 0.01);
|
|
||||||
|
|
||||||
struct image_linear_map temp;
|
|
||||||
|
|
||||||
for(x = 0; x < viewport_w; x++) {
|
|
||||||
|
|
||||||
//calculate ray position and direction
|
|
||||||
cameraX = fdiv(fix(x*2), fix(viewport_w)) - 0xFFFF + h_offset; //x-coordinate in camera space
|
|
||||||
|
|
||||||
rayDirX = dirX + fmul(planeX, cameraX);
|
|
||||||
rayDirY = dirY + fmul(planeY, cameraX);
|
|
||||||
|
|
||||||
|
|
||||||
//which box of the map we're in
|
|
||||||
mapX = f2int(posX);
|
|
||||||
mapY = f2int(posY);
|
|
||||||
|
|
||||||
// length of ray from one x or y-side to next x or y-side
|
|
||||||
// these are derived as:
|
|
||||||
// deltaDistX = sqrt(1 + (rayDirY * rayDirY) / (rayDirX * rayDirX))
|
|
||||||
// deltaDistY = sqrt(1 + (rayDirX * rayDirX) / (rayDirY * rayDirY))
|
|
||||||
// which can be simplified to abs(|rayDir| / rayDirX) and abs(|rayDir| / rayDirY)
|
|
||||||
// where |rayDir| is the length of the vector (rayDirX, rayDirY). Its length,
|
|
||||||
// unlike (dirX, dirY) is not 1, however this does not matter, only the
|
|
||||||
// ratio between deltaDistX and deltaDistY matters, due to the way the DDA
|
|
||||||
// stepping further below works. So the values can be computed as below.
|
|
||||||
// Division through zero is prevented, even though technically that's not
|
|
||||||
// needed in C++ with IEEE 754 floating point values.
|
|
||||||
// Fcalva : removed the 0 div prevention
|
|
||||||
|
|
||||||
deltaDistX = abs(fdiv(0xFFFF, rayDirX));
|
|
||||||
deltaDistY = abs(fdiv(0xFFFF, rayDirY));
|
|
||||||
|
|
||||||
//calculate step and initial sideDist
|
|
||||||
if (rayDirX < 0) {
|
|
||||||
stepX = -1;
|
|
||||||
sideDistX = fmul(posX - fix(mapX), deltaDistX);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
stepX = 1;
|
|
||||||
sideDistX = fmul( fix(mapX + 1) - posX, deltaDistX);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rayDirY == 0) {
|
|
||||||
stepY = 0;
|
|
||||||
sideDistY = 0;
|
|
||||||
}
|
|
||||||
else if (rayDirY < 0) {
|
|
||||||
stepY = -1;
|
|
||||||
sideDistY = fmul(posY - fix(mapY), deltaDistY);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
stepY = 1;
|
|
||||||
sideDistY = fmul( fix(mapY + 1) - posY, deltaDistY);
|
|
||||||
}
|
|
||||||
//perform DDA
|
|
||||||
while(true) {
|
|
||||||
//Check if the ray is out of range/bounds
|
|
||||||
if (sideDistX >= max_dist || sideDistY >= max_dist || mapX < 0 || mapY < 0 || mapX >= map_w || mapY >= map_h) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
//Otherwise check if ray has hit a wall
|
|
||||||
else if (map_test[mapX][mapY] > 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
//jump to next map square, either in x-direction, or in y-direction
|
|
||||||
if (sideDistX < sideDistY) {
|
|
||||||
sideDistX += deltaDistX;
|
|
||||||
mapX += stepX;
|
|
||||||
side = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sideDistY += deltaDistY;
|
|
||||||
mapY += stepY;
|
|
||||||
side = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Calculate distance projected on camera direction. This is the shortest distance from the point where the wall is
|
|
||||||
//hit to the camera plane. Euclidean to center camera point would give fisheye effect!
|
|
||||||
//This can be computed as (mapX - posX + (1 - stepX) / 2) / rayDirX for side == 0, or same formula with Y
|
|
||||||
//for size == 1, but can be simplified to the code below thanks to how sideDist and deltaDist are computed:
|
|
||||||
//because they were left scaled to |rayDir|. sideDist is the entire length of the ray above after the multiple
|
|
||||||
//steps, but we subtract deltaDist once because one step more into the wall was taken above.
|
|
||||||
|
|
||||||
if (side == 0) perpWallDist = (sideDistX - deltaDistX);
|
|
||||||
else perpWallDist = (sideDistY - deltaDistY);
|
|
||||||
|
|
||||||
//texturing calculations
|
|
||||||
//int texNum = test_map[mapX][mapY] - 1; //a voir plus tard
|
|
||||||
|
|
||||||
//calculate value of wallX
|
|
||||||
fixed_t wallX; //where exactly the wall was hit
|
|
||||||
if (side == 0) wallX = posY + fmul(perpWallDist, rayDirY);
|
|
||||||
else wallX = posX + fmul(perpWallDist, rayDirX);
|
|
||||||
wallX -= fix(floor(f2int(wallX)));
|
|
||||||
|
|
||||||
//x coordinate on the texture
|
|
||||||
texX = fmul(wallX, 64);
|
|
||||||
texX = texX % 64;
|
|
||||||
|
|
||||||
if(side == 0 && rayDirX > 0) texX = 64 - texX - 1;
|
|
||||||
if(side == 1 && rayDirY < 0) texX = 64 - texX - 1;
|
|
||||||
|
|
||||||
lineHeight = f2int(fdiv(fix(viewport_h), perpWallDist)); //Taille en px de la ligne
|
|
||||||
if (lineHeight < 1) lineHeight = 1;
|
|
||||||
//if (lineHeight > viewport_h) lineHeight = viewport_h - 1;
|
|
||||||
|
|
||||||
fixed_t texSize = fix(lineHeight) / 64; //taille proportionelle de la ligne a la tex
|
|
||||||
if (texSize < 0x400) texSize = 0x400; //0x400 = 1/64 * 2^16
|
|
||||||
if (texSize > 0x3D000) { //0x3D000 = 3.8125 * 2^16, 3.8125 = viewport_h/64
|
|
||||||
texSample = fceil(fdiv(fix(viewport_h), texSize));
|
|
||||||
texSampleY = 32 - (int)texSample * 0.5;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
texSample = 64;
|
|
||||||
texSampleY = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
image_t texStripe;
|
|
||||||
|
|
||||||
texStripe = *image_sub(tex_index[map_test[mapX][mapY]], texX, texSampleY, 1, texSample);
|
|
||||||
|
|
||||||
image_scale(&texStripe, 0xFFFF, texSize, &temp);
|
|
||||||
image_linear(&texStripe, image_at(frame_buffer, x, (int)(viewport_h * 0.5 - lineHeight * 0.5) + v_offset), &temp);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
// Voir README.md pour license précise, par Fcalva 2023-2024 et est sous GPLv3
|
|
||||||
|
|
||||||
#ifndef moteur_h
|
|
||||||
#define moteur_h
|
|
||||||
|
|
||||||
#include <gint/image.h>
|
|
||||||
|
|
||||||
//param. graphiques
|
|
||||||
#define screen_w 396
|
|
||||||
#define screen_h 224
|
|
||||||
#define viewport_w 396
|
|
||||||
#define viewport_h 224
|
|
||||||
#define max_dist 0x1FFFFF //en tuiles << 16, actuellement 32
|
|
||||||
|
|
||||||
#define TINDEX_S 256
|
|
||||||
|
|
||||||
void load_map();
|
|
||||||
void end_screen();
|
|
||||||
void draw_walls(image_t *frame_buffer);
|
|
||||||
void move();
|
|
||||||
|
|
||||||
#endif /* moteur */
|
|
|
@ -1,6 +0,0 @@
|
||||||
zombard1.png:
|
|
||||||
type: bopti-image
|
|
||||||
name: zombard
|
|
||||||
skybox0.png:
|
|
||||||
type: bopti-image
|
|
||||||
name: skybox_quarter
|
|
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 8.2 KiB |
Before Width: | Height: | Size: 31 KiB |
4
assets-fx/fxconv-metadata.txt
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
sprite.png:
|
||||||
|
type: bopti-image
|
||||||
|
name: sprite_tst
|
||||||
|
profile: gray_alpha
|
BIN
assets-fx/icon.png
Normal file
After Width: | Height: | Size: 7.3 KiB |
BIN
assets-fx/sprite.png
Normal file
After Width: | Height: | Size: 642 B |
BIN
assets-fx/textures/briques0.png
Normal file
After Width: | Height: | Size: 5.6 KiB |
BIN
assets-fx/textures/buisson1.png
Normal file
After Width: | Height: | Size: 6.4 KiB |
|
@ -1,9 +1,11 @@
|
||||||
// Voir README.md pour license précise, par Fcalva 2023-2024 et est sous GPLv3
|
// Voir README.md pour license précise, par Fcalva 2023-2024 et est sous GPLv3
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include "moteur.h"
|
#include "moteur.h"
|
||||||
|
|
||||||
char map_test[map_w][map_h] = {
|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,0,0,0,0,0,0,0,0,0,0,0,0,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3},
|
||||||
{1,0,1,0,1,0,0,1,1,1,0,1,1,1,0,1,0,1,1,1,0,1,1,1,0,1,0,0,1,0,1,0,1,0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,1,0,0,0,0,0,1,1,1,1,1,0,1,0,0,1,0,1,1,1,0,1,0,1,1,0,1,0,1,0,0,0,1,1,1,0,0,0,0,0,1,0,1,1,0,2,0,2,0,0,2,0,0,0,0,2,0,0,2,0,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3},
|
{1,0,1,0,1,0,0,1,1,1,0,1,1,1,0,1,0,1,1,1,0,1,1,1,0,1,0,0,1,0,1,0,1,0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,1,0,0,0,0,0,1,1,1,1,1,0,1,0,0,1,0,1,1,1,0,1,0,1,1,0,1,0,1,0,0,0,1,1,1,0,0,0,0,0,1,0,1,1,0,2,0,2,0,0,2,0,0,0,0,2,0,0,2,0,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3},
|
|
@ -2,38 +2,41 @@
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include <gint/display.h>
|
#include <gint/display.h>
|
||||||
|
#include <gint/display-fx.h>
|
||||||
#include <gint/keyboard.h>
|
#include <gint/keyboard.h>
|
||||||
|
#include <gint/gray.h>
|
||||||
#include <libprof.h>
|
#include <libprof.h>
|
||||||
|
|
||||||
#include "fixed.h"
|
#include "fixed.h"
|
||||||
|
|
||||||
#include "gint/display-cg.h"
|
|
||||||
#include "moteur.h"
|
#include "moteur.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
|
#include "game.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
// moteur.c :
|
// moteur.c :
|
||||||
// ici se trouvent tout ce qui concerne les graphismes, mouvement et collisions
|
// ici se trouvent tout ce qui concerne les graphismes, mouvement et collisions
|
||||||
//
|
//
|
||||||
//
|
|
||||||
|
|
||||||
void move() {
|
//1D zbuf for sprites
|
||||||
|
fixed_t zbuf[viewport_w];
|
||||||
|
|
||||||
|
void move(RcGame *game) {
|
||||||
extern int frame_time;
|
extern int frame_time;
|
||||||
fixed_t moveSpeed = fmul(fix(frame_time), 0x148); //frame_time * fix(carrés/seconde/1000) là carrés/seconde = 5
|
fixed_t moveSpeed = fmul(fix(frame_time), 0x148); //frame_time * fix(carrés/seconde/1000) là carrés/seconde = 5
|
||||||
fixed_t rotSpeed = fmul(fix(frame_time), 0x83); //frame_time * fix(radians/seconde/1000) là radians/seconde = 2
|
fixed_t rotSpeed = fmul(fix(frame_time), 0x83); //frame_time * fix(radians/seconde/1000) là radians/seconde = 2
|
||||||
fixed_t c_rotSpeed = fix(cos(f2float(rotSpeed)));
|
fixed_t c_rotSpeed = fix(cos(f2float(rotSpeed)));
|
||||||
fixed_t s_rotSpeed = fix(sin(f2float(rotSpeed)));
|
fixed_t s_rotSpeed = fix(sin(f2float(rotSpeed)));
|
||||||
|
|
||||||
extern char map_test[map_w][map_h];
|
uint8_t *map_test = game->current_map;
|
||||||
extern fixed_t planeX;
|
V2d *plane = &game->player.plane;
|
||||||
extern fixed_t planeY;
|
V2d *dir = &game->player.dir;
|
||||||
extern fixed_t dirX;
|
V2d *pos = &game->player.pos;
|
||||||
extern fixed_t dirY;
|
|
||||||
extern fixed_t posX;
|
|
||||||
extern fixed_t posY;
|
|
||||||
|
|
||||||
fixed_t oldDirX;
|
fixed_t oldDirX;
|
||||||
fixed_t oldPlaneX;
|
fixed_t oldPlaneX;
|
||||||
|
@ -43,176 +46,182 @@ void move() {
|
||||||
int ytemp2;
|
int ytemp2;
|
||||||
|
|
||||||
if (keydown(KEY_UP)) {
|
if (keydown(KEY_UP)) {
|
||||||
xtemp1 = f2int(posX + fmul(dirX, moveSpeed) - 0xF);
|
xtemp1 = ffloor(pos->x + fmul(dir->x, moveSpeed));
|
||||||
ytemp1 = f2int(posY);
|
ytemp1 = ffloor(pos->y);
|
||||||
xtemp2 = f2int(posX);
|
xtemp2 = ffloor(pos->x);
|
||||||
ytemp2 = f2int(posY + fmul(dirY, moveSpeed) - 0xF);
|
ytemp2 = ffloor(pos->y + fmul(dir->y, moveSpeed));
|
||||||
|
|
||||||
if(map_test[xtemp1][ytemp1] == 0) posX += fmul(dirX, moveSpeed);
|
if(!map_test[xtemp1*map_w+ytemp1])
|
||||||
if(map_test[xtemp2][ytemp2] == 0) posY += fmul(dirY, moveSpeed);
|
pos->x += fmul(dir->x, moveSpeed);
|
||||||
|
if(!map_test[xtemp2*map_w+ytemp2])
|
||||||
|
pos->y += fmul(dir->y, moveSpeed);
|
||||||
}
|
}
|
||||||
//move backwards if no wall behind you
|
//move backwards if no wall behind you
|
||||||
if (keydown(KEY_DOWN)) {
|
if (keydown(KEY_DOWN)) {
|
||||||
xtemp1 = f2int(posX - fmul(dirX, moveSpeed) + 0xF);
|
xtemp1 = ffloor(pos->x - fmul(dir->x, moveSpeed));
|
||||||
ytemp1 = f2int(posY);
|
ytemp1 = ffloor(pos->y);
|
||||||
xtemp2 = f2int(posX);
|
xtemp2 = ffloor(pos->x);
|
||||||
ytemp2 = f2int(posY - fmul(dirY, moveSpeed) + 0xF);
|
ytemp2 = ffloor(pos->y - fmul(dir->y, moveSpeed));
|
||||||
|
|
||||||
if(map_test[xtemp1][ytemp1] == 0) posX -= fmul(dirX, moveSpeed);
|
if(!map_test[xtemp1*map_w+ytemp1])
|
||||||
if(map_test[xtemp2][ytemp2] == 0) posY -= fmul(dirY, moveSpeed);
|
pos->x -= fmul(dir->x, moveSpeed);
|
||||||
|
if(!map_test[xtemp2*map_w+ytemp2])
|
||||||
|
pos->y -= fmul(dir->y, moveSpeed);
|
||||||
}
|
}
|
||||||
//rotate to the rightdouble sin_rotspeed;
|
//rotate to the right
|
||||||
if (keydown(KEY_RIGHT)) {
|
if (keydown(KEY_RIGHT)) {
|
||||||
//both camera direction and camera plane must be rotated
|
//both camera direction and camera plane must be rotated
|
||||||
oldDirX = dirX;
|
oldDirX = dir->x;
|
||||||
dirX = (fmul(dirX, c_rotSpeed)+1) - (fmul(dirY, -s_rotSpeed)+1);
|
dir->x = (fmul(dir->x, c_rotSpeed)+1) - (fmul(dir->y, -s_rotSpeed)+1);
|
||||||
dirY = (fmul(oldDirX, -s_rotSpeed)+1) + (fmul(dirY, c_rotSpeed)+1);
|
dir->y = (fmul(oldDirX, -s_rotSpeed)+1) + (fmul(dir->y, c_rotSpeed)+1);
|
||||||
oldPlaneX = planeX;
|
oldPlaneX = plane->x;
|
||||||
planeX = (fmul(planeX, c_rotSpeed)+1) - (fmul(planeY, -s_rotSpeed)+1);
|
plane->x = (fmul(plane->x, c_rotSpeed)+1) - (fmul(plane->y, -s_rotSpeed)+1);
|
||||||
planeY = (fmul(oldPlaneX, -s_rotSpeed)+1) + (fmul(planeY, c_rotSpeed)+1);
|
plane->y = (fmul(oldPlaneX, -s_rotSpeed)+1) + (fmul(plane->y, c_rotSpeed)+1);
|
||||||
}
|
}
|
||||||
//rotate to the left
|
//rotate to the left
|
||||||
if (keydown(KEY_LEFT)) {
|
if (keydown(KEY_LEFT)) {
|
||||||
//both camera direction and camera plane must be rotated
|
//both camera direction and camera plane must be rotated
|
||||||
oldDirX = dirX;
|
oldDirX = dir->x;
|
||||||
dirX = (fmul(dirX, c_rotSpeed)-1) - (fmul(dirY, s_rotSpeed)-1);
|
dir->x = (fmul(dir->x, c_rotSpeed)-1) - (fmul(dir->y, s_rotSpeed)-1);
|
||||||
dirY = (fmul(oldDirX, s_rotSpeed)+1) + (fmul(dirY, c_rotSpeed)+1);
|
dir->y = (fmul(oldDirX, s_rotSpeed)+1) + (fmul(dir->y, c_rotSpeed)+1);
|
||||||
oldPlaneX = planeX;
|
oldPlaneX = plane->x;
|
||||||
planeX = (fmul(planeX, c_rotSpeed)-1) - (fmul(planeY, s_rotSpeed) - 1);
|
plane->x = (fmul(plane->x, c_rotSpeed)-1) - (fmul(plane->y, s_rotSpeed) - 1);
|
||||||
planeY = (fmul(oldPlaneX, s_rotSpeed)+1) + (fmul(planeY, c_rotSpeed) + 1);
|
plane->y = (fmul(oldPlaneX, s_rotSpeed)+1) + (fmul(plane->y, c_rotSpeed) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dirX > 0xFFFF) dirX = 0xFFFF;
|
if (dir->x > 0xFFFF) dir->x = 0xFFFF;
|
||||||
if (dirY > 0xFFFF) dirY = 0xFFFF;
|
if (dir->y > 0xFFFF) dir->y = 0xFFFF;
|
||||||
if (dirX < -0xFFFF) dirX = -0xFFFF;
|
if (dir->x < -0xFFFF) dir->x = -0xFFFF;
|
||||||
if (dirY < -0xFFFF) dirY = -0xFFFF;
|
if (dir->y < -0xFFFF) dir->y = -0xFFFF;
|
||||||
}
|
|
||||||
|
|
||||||
void spawn_gen(){
|
|
||||||
extern fixed_t posX;
|
|
||||||
extern fixed_t posY;
|
|
||||||
extern fixed_t dirX;
|
|
||||||
extern fixed_t dirY;
|
|
||||||
extern fixed_t planeX;
|
|
||||||
extern fixed_t planeY;
|
|
||||||
extern char map_test[map_w][map_h];
|
|
||||||
|
|
||||||
int seed, seed_x, seed_y;
|
|
||||||
int SeedSeed;
|
|
||||||
|
|
||||||
time_t timeN;
|
|
||||||
time(&timeN);
|
|
||||||
SeedSeed = timeN;
|
|
||||||
|
|
||||||
srand(SeedSeed);
|
|
||||||
|
|
||||||
while(1){
|
|
||||||
seed = rand() * 0.5 + rand() * 0.5;
|
|
||||||
seed_x = seed & 0b1111111;
|
|
||||||
seed_y = (seed >> 8) & 0b111111;
|
|
||||||
if (seed_x < map_w && seed_y < map_h && (seed_x < 111 && seed_y > 15)){
|
|
||||||
if(map_test[seed_x][seed_y] == 0){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fixed_t start_dirX, start_dirY;
|
|
||||||
|
|
||||||
int dirSeed = (seed >> 9) & 0b11 ;
|
|
||||||
switch(dirSeed){
|
|
||||||
case 0: {
|
|
||||||
start_dirX = 0x0;
|
|
||||||
start_dirY = 0xFFFF;
|
|
||||||
planeX = fix(0.66);
|
|
||||||
planeY = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1: {
|
|
||||||
start_dirX = 0xFFFF;
|
|
||||||
start_dirY = 0x0;
|
|
||||||
planeX = 0;
|
|
||||||
planeY = fix(-0.66);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 2: {
|
|
||||||
start_dirX = -0xFFFF;
|
|
||||||
start_dirY = 0x0;
|
|
||||||
planeX = 0;
|
|
||||||
planeY = fix(0.66);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 3: {
|
|
||||||
start_dirX = 0x0;
|
|
||||||
start_dirY = -0xFFFF;
|
|
||||||
planeX = fix(-0.66);
|
|
||||||
planeY = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default : {
|
|
||||||
start_dirX = 0xFFFF;
|
|
||||||
start_dirY = 0x0;
|
|
||||||
planeX = 0;
|
|
||||||
planeY = fix(-0.66);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
posX = fix(seed_x) + 0x7FFF;
|
|
||||||
posY = fix(seed_y) + 0x7FFF; //x and y start position
|
|
||||||
dirX = start_dirX;
|
|
||||||
dirY = start_dirY; //initial direction vector
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void load_map(){
|
void load_map(){
|
||||||
spawn_gen();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if asm_opti
|
//Fonction fournie par le grand Lephé :D
|
||||||
#else
|
inline int __attribute__((always_inline))
|
||||||
inline void __attribute__((always_inline)) draw_stripe(image_t *tex, int texSampleY,
|
get_pixel(bopti_image_t const *img, int u, int v)
|
||||||
int linePos, fixed_t texSize, int texX, int x){
|
{
|
||||||
fixed_t screenPos = fix(linePos);
|
int layers = image_layer_count(img->profile);
|
||||||
uint32_t texDat = (uint32_t)tex->data + 2*texX;
|
int columns = (img->width + 31) >> 5;
|
||||||
register int vramSize asm("r2") = 396;
|
|
||||||
register int oneConst asm("r12");
|
uint32_t const *layer_ptr = (void *)img->data;
|
||||||
asm("mov #-1, r12\n"
|
layer_ptr += (v * columns + (u >> 5)) * layers;
|
||||||
"extu.w r12, r12"
|
|
||||||
: "=r" (oneConst)
|
uint32_t mask = 0x80000000u >> (u & 31);
|
||||||
: "r" (oneConst)
|
|
||||||
);
|
int light = (layer_ptr[0] & mask) != 0;
|
||||||
register int maxConst asm("r13") = viewport_w*viewport_h;
|
int dark = (layer_ptr[1] & mask) != 0;
|
||||||
for(int texPos = texSampleY; texPos < 64; ++texPos){
|
int alpha = 0;
|
||||||
if(screenPos >= -texSize){
|
if(layers > 2){
|
||||||
int vrampos = ffloor(screenPos)*vramSize+x;
|
alpha = !(layer_ptr[2] & mask);
|
||||||
fixed_t oldPos = screenPos;
|
}
|
||||||
int16_t pix = *(int16_t*)texDat;
|
return (alpha << 2) + (dark << 1) + light;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t *light, *dark;
|
||||||
|
|
||||||
|
//Version simplifiée de gpixel dans gint/src/gray/gpixel.c
|
||||||
|
//Tout le crédit revient à Lephé
|
||||||
|
inline void __attribute__((always_inline))
|
||||||
|
cust_dpixel(int x, int y, color_t color){
|
||||||
|
|
||||||
|
if(y >= viewport_h || y < 0)
|
||||||
|
return;
|
||||||
|
int offset = (y << 2) + (x >> 5);
|
||||||
|
uint32_t mask = 1 << (~x & 31);
|
||||||
|
|
||||||
|
switch(color){
|
||||||
|
case C_WHITE:
|
||||||
|
light[offset] &= ~mask;
|
||||||
|
dark [offset] &= ~mask;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case C_LIGHT:
|
||||||
|
light[offset] |= mask;
|
||||||
|
dark [offset] &= ~mask;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case C_DARK:
|
||||||
|
light[offset] &= ~mask;
|
||||||
|
dark [offset] |= mask;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case C_BLACK:
|
||||||
|
light[offset] |= mask;
|
||||||
|
dark [offset] |= mask;
|
||||||
|
break;
|
||||||
|
case C_NONE:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dscale_bopti(bopti_image_t *tex, fixed_t scale_x, fixed_t scale_y, int x, int y){
|
||||||
|
dgray_getvram(&light,&dark);
|
||||||
|
|
||||||
|
fixed_t screen_y = fix(y);
|
||||||
|
fixed_t tex_y = 0;
|
||||||
|
do{
|
||||||
|
fixed_t oldy = screen_y;
|
||||||
|
if(screen_y < 0 || screen_y+scale_x > viewport_h)
|
||||||
|
return;
|
||||||
|
do{
|
||||||
|
fixed_t screen_x = fix(x);
|
||||||
|
fixed_t tex_x = 0;
|
||||||
|
do{
|
||||||
|
fixed_t oldx = screen_x;
|
||||||
|
int tpix = get_pixel(tex, tex_x, tex_y);
|
||||||
|
if(screen_x < 0 || screen_x+scale_x > viewport_w)
|
||||||
|
return;
|
||||||
do{
|
do{
|
||||||
gint_vram[vrampos] = pix;
|
cust_dpixel(ffloor(oldx), ffloor(oldy), tpix);
|
||||||
vrampos += vramSize;
|
oldx += 0xFFFF;
|
||||||
oldPos += oneConst;
|
} while(oldx < screen_x+scale_x);
|
||||||
if(vrampos >= maxConst)
|
screen_x += scale_x;
|
||||||
return;
|
tex_x++;
|
||||||
}while(oldPos < screenPos+texSize);
|
} while(tex_x < tex->width);
|
||||||
|
oldy += 0xFFFF;
|
||||||
|
} while(oldy < screen_y+scale_y);
|
||||||
|
screen_y += scale_y;
|
||||||
|
tex_y++;
|
||||||
|
} while(tex_y < tex->height);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void __attribute__((always_inline))
|
||||||
|
draw_stripe(bopti_image_t *tex, int texSampleY, int linePos, fixed_t texSize,
|
||||||
|
int texX, int x){
|
||||||
|
|
||||||
|
fixed_t screenPos = fix(linePos);
|
||||||
|
for(int texPos = texSampleY; texPos < TSIZE; ++texPos){
|
||||||
|
if(screenPos >= 0){
|
||||||
|
fixed_t oldPos = screenPos;
|
||||||
|
int tpix = get_pixel(tex, texX, texPos);
|
||||||
|
do{
|
||||||
|
oldPos += 0xFFFF;
|
||||||
|
cust_dpixel(x, fround(oldPos), tpix);
|
||||||
|
} while(oldPos < screenPos+texSize);
|
||||||
}
|
}
|
||||||
screenPos += texSize;
|
screenPos += texSize;
|
||||||
texDat += tex->stride;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void draw_walls(
|
void draw_walls(
|
||||||
#if debug
|
#if debug
|
||||||
EngineTimers *timers
|
EngineTimers *timers,
|
||||||
#endif
|
#endif
|
||||||
|
RcGame *game
|
||||||
){
|
){
|
||||||
extern fixed_t posX;
|
fixed_t posX = game->player.pos.x;
|
||||||
extern fixed_t posY;
|
fixed_t posY = game->player.pos.y;
|
||||||
extern fixed_t dirX;
|
fixed_t dirX = game->player.dir.x;
|
||||||
extern fixed_t dirY;
|
fixed_t dirY = game->player.dir.y;
|
||||||
extern fixed_t planeX;
|
fixed_t planeX = game->player.plane.x;
|
||||||
extern fixed_t planeY;
|
fixed_t planeY = game->player.plane.y;
|
||||||
extern image_t *tex_index[TINDEX_S];
|
extern bopti_image_t *tex_index[TINDEX_S];
|
||||||
extern char map_test[map_w][map_h];
|
uint8_t *map_test = game->current_map;
|
||||||
|
|
||||||
fixed_t cameraX;
|
fixed_t cameraX;
|
||||||
fixed_t rayDirX;
|
fixed_t rayDirX;
|
||||||
|
@ -235,10 +244,12 @@ void draw_walls(
|
||||||
int texSample;
|
int texSample;
|
||||||
int texSampleY;
|
int texSampleY;
|
||||||
|
|
||||||
int v_offset = 0; //(int)(sin(f2int(posX + posY)) * 5); //a raffiner un peu
|
dgray_getvram(&light,&dark);
|
||||||
fixed_t h_offset = 0; //fix(sin(f2int(posX - posY)) * 0.01);
|
|
||||||
|
|
||||||
struct image_linear_map temp;
|
int v_offset = 0;
|
||||||
|
fixed_t h_offset = 0;
|
||||||
|
|
||||||
|
//struct image_linear_map temp;
|
||||||
|
|
||||||
for(x = 0; x < viewport_w; x++) {
|
for(x = 0; x < viewport_w; x++) {
|
||||||
#if debug
|
#if debug
|
||||||
|
@ -251,10 +262,9 @@ void draw_walls(
|
||||||
rayDirX = dirX + fmul(planeX, cameraX);
|
rayDirX = dirX + fmul(planeX, cameraX);
|
||||||
rayDirY = dirY + fmul(planeY, cameraX);
|
rayDirY = dirY + fmul(planeY, cameraX);
|
||||||
|
|
||||||
|
|
||||||
//which box of the map we're in
|
//which box of the map we're in
|
||||||
mapX = f2int(posX);
|
mapX = ffloor(posX);
|
||||||
mapY = f2int(posY);
|
mapY = ffloor(posY);
|
||||||
|
|
||||||
// length of ray from one x or y-side to next x or y-side
|
// length of ray from one x or y-side to next x or y-side
|
||||||
// these are derived as:
|
// these are derived as:
|
||||||
|
@ -274,6 +284,8 @@ void draw_walls(
|
||||||
|
|
||||||
deltaDistX = abs(fdiv(0xFFFF, rayDirX));
|
deltaDistX = abs(fdiv(0xFFFF, rayDirX));
|
||||||
deltaDistY = abs(fdiv(0xFFFF, rayDirY));
|
deltaDistY = abs(fdiv(0xFFFF, rayDirY));
|
||||||
|
if(deltaDistX > max_dist) deltaDistX = max_dist;
|
||||||
|
if(deltaDistY > max_dist) deltaDistY = max_dist;
|
||||||
|
|
||||||
//calculate step and initial sideDist
|
//calculate step and initial sideDist
|
||||||
if (rayDirX < 0) {
|
if (rayDirX < 0) {
|
||||||
|
@ -300,11 +312,11 @@ void draw_walls(
|
||||||
//perform DDA
|
//perform DDA
|
||||||
while(true) {
|
while(true) {
|
||||||
//Check if the ray is out of range/bounds
|
//Check if the ray is out of range/bounds
|
||||||
if (sideDistX >= max_dist || sideDistY >= max_dist || mapX < 0 || mapY < 0 || mapX >= map_w || mapY >= map_h) {
|
if (sideDistX >= max_dist || sideDistY >= max_dist || mapX < 0 || mapY < 0 || mapY >= map_w || mapX >= map_h) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//Otherwise check if ray has hit a wall
|
//Otherwise check if ray has hit a wall
|
||||||
if (map_test[mapX][mapY] > 0) {
|
if (map_test[mapX*map_w+mapY] > 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//jump to next map square, either in x-direction, or in y-direction
|
//jump to next map square, either in x-direction, or in y-direction
|
||||||
|
@ -329,6 +341,8 @@ void draw_walls(
|
||||||
if (side == 0) perpWallDist = (sideDistX - deltaDistX);
|
if (side == 0) perpWallDist = (sideDistX - deltaDistX);
|
||||||
else perpWallDist = (sideDistY - deltaDistY);
|
else perpWallDist = (sideDistY - deltaDistY);
|
||||||
|
|
||||||
|
zbuf[x] = perpWallDist;
|
||||||
|
|
||||||
#if debug
|
#if debug
|
||||||
prof_leave(timers->raycast_time);
|
prof_leave(timers->raycast_time);
|
||||||
prof_enter(timers->draw_time);
|
prof_enter(timers->draw_time);
|
||||||
|
@ -340,35 +354,38 @@ void draw_walls(
|
||||||
fixed_t wallX; //where exactly the wall was hit
|
fixed_t wallX; //where exactly the wall was hit
|
||||||
if (side == 0) wallX = posY + fmul(perpWallDist, rayDirY);
|
if (side == 0) wallX = posY + fmul(perpWallDist, rayDirY);
|
||||||
else wallX = posX + fmul(perpWallDist, rayDirX);
|
else wallX = posX + fmul(perpWallDist, rayDirX);
|
||||||
wallX -= fix(floor(f2int(wallX)));
|
wallX -= fix(ffloor(wallX));
|
||||||
|
|
||||||
//x coordinate on the texture
|
//x coordinate on the texture
|
||||||
texX = fmul(wallX, 64);
|
texX = fmul(wallX, TSIZE);
|
||||||
texX = texX % 64;
|
texX %= TSIZE;
|
||||||
|
|
||||||
if(side == 0 && rayDirX > 0) texX = 64 - texX - 1;
|
if(side == 0 && rayDirX > 0) texX = 64 - texX - 1;
|
||||||
if(side == 1 && rayDirY < 0) texX = 64 - texX - 1;
|
if(side == 1 && rayDirY < 0) texX = 64 - texX - 1;
|
||||||
|
|
||||||
lineHeight = f2int(fdiv(fix(viewport_h), perpWallDist)); //Taille en px de la ligne
|
lineHeight = ffloor(fdiv(fix(viewport_h), perpWallDist)); //Taille en px de la ligne
|
||||||
if (lineHeight < 1) lineHeight = 1;
|
if (lineHeight < 1) lineHeight = 1;
|
||||||
//if (lineHeight > viewport_h) lineHeight = viewport_h - 1;
|
//if (lineHeight > viewport_h) lineHeight = viewport_h - 1;
|
||||||
|
|
||||||
fixed_t texSize = fix(lineHeight) / 64; //taille proportionelle de la ligne a la tex
|
fixed_t texSize = fix(lineHeight) / TSIZE; //taille proportionelle de la ligne a la tex
|
||||||
if (texSize < 0x400) texSize = 0x400; //0x400 = 1/64 * 2^16
|
if (texSize < fix(1.0/(float)TSIZE)) texSize = fix(1.0/(float)TSIZE);
|
||||||
if (texSize > 0x3D000) { //0x3D000 = 3.8125 * 2^16, 3.8125 = viewport_h/64
|
if (texSize > fix((float)viewport_h/(float)TSIZE)) {
|
||||||
texSample = fceil(fdiv(fix(viewport_h), texSize));
|
texSample = fceil(fdiv(fix(viewport_h), texSize));
|
||||||
texSampleY = 32 - texSample/2;
|
texSampleY = TSIZE/2 - texSample/2;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
texSample = 64;
|
texSample = TSIZE;
|
||||||
texSampleY = 0;
|
texSampleY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int linePos = viewport_h/2 - lineHeight/2;
|
int linePos = viewport_h/2 - lineHeight/2;
|
||||||
|
|
||||||
image_t *tex = tex_index[map_test[mapX][mapY]];
|
bopti_image_t *tex = tex_index[map_test[mapX*map_w+mapY]];
|
||||||
|
|
||||||
draw_stripe(tex, texSampleY, linePos, texSize, texX, x);
|
//dline(x, linePos, x, linePos + lineHeight, 1);
|
||||||
|
|
||||||
|
draw_stripe(tex, texSampleY, linePos,
|
||||||
|
texSize, texX, x);
|
||||||
|
|
||||||
#if debug
|
#if debug
|
||||||
prof_leave(timers->draw_time);
|
prof_leave(timers->draw_time);
|
122
eng/sprites.c
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
// Voir README.md pour license précise, par Fcalva 2023-2024 et est sous GPLv3
|
||||||
|
|
||||||
|
#include <gint/display.h>
|
||||||
|
#include <gint/keyboard.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "game.h"
|
||||||
|
#include "sprites.h"
|
||||||
|
#include "moteur.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include "fixed.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
extern fixed_t zbuf[viewport_w];
|
||||||
|
|
||||||
|
int spritec;
|
||||||
|
|
||||||
|
Sprite *sprite_index[SINDEX_S];
|
||||||
|
|
||||||
|
void add_sprite(Sprite *sprite){
|
||||||
|
if(spritec >= SINDEX_S)
|
||||||
|
return;
|
||||||
|
sprite_index[spritec++] = sprite;
|
||||||
|
}
|
||||||
|
|
||||||
|
void clear_sprites(){
|
||||||
|
spritec = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void remove_sprite(GUNUSED Sprite *sprite){
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
//Lodev's sprite projection, translated
|
||||||
|
|
||||||
|
void project_sprite(bopti_image_t *tex_index[], Sprite *sprite, RcActor *player){
|
||||||
|
|
||||||
|
V2d relpos = sprite->pos;
|
||||||
|
relpos.x -= player->pos.x;
|
||||||
|
relpos.y -= player->pos.y;
|
||||||
|
|
||||||
|
fixed_t idet = fmul(player->plane.x, player->dir.y) -
|
||||||
|
fmul(player->dir.x, player->plane.y);
|
||||||
|
idet = idet ? fdiv(fix(1), idet):0;
|
||||||
|
|
||||||
|
fixed_t tx = fmul(idet, fmul(player->dir.y, relpos.x) -
|
||||||
|
fmul(player->dir.x, relpos.y));
|
||||||
|
fixed_t ty = fmul(idet, fmul(-player->plane.y, relpos.x) +
|
||||||
|
fmul(player->plane.x, relpos.y));
|
||||||
|
fixed_t txtydiv = ty ? fdiv(tx, ty):0;
|
||||||
|
int screen_x = ffloor(fmul(fix(viewport_w/2),(fix(1) + txtydiv)));
|
||||||
|
|
||||||
|
int sprite_h = ffloor(fixabs(fdiv(fix(viewport_h),ty)));
|
||||||
|
|
||||||
|
int sprite_pos_y = -sprite_h / 2 + viewport_h / 2;
|
||||||
|
|
||||||
|
if(sprite_pos_y < 0)
|
||||||
|
sprite_pos_y = 0;
|
||||||
|
|
||||||
|
int sprite_pos_x = -sprite_h / 2 + screen_x;
|
||||||
|
if(sprite_pos_x < 0)
|
||||||
|
sprite_pos_x = 0;
|
||||||
|
int sprite_end_x = sprite_h / 2 + screen_x;
|
||||||
|
if(sprite_end_x > viewport_w)
|
||||||
|
sprite_end_x = viewport_w;
|
||||||
|
|
||||||
|
int sprite_w = sprite_h;
|
||||||
|
|
||||||
|
if(sprite_pos_x + sprite_h > viewport_w)
|
||||||
|
sprite_h = viewport_w - sprite_pos_x;
|
||||||
|
if(sprite_pos_y + sprite_w > viewport_h)
|
||||||
|
sprite_w = viewport_h - sprite_pos_y;
|
||||||
|
if(sprite_pos_x + sprite_h < 0 || sprite_pos_x > viewport_w)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fixed_t sprite_size = fdiv(fix(sprite_w), fix(TSIZE));
|
||||||
|
|
||||||
|
for(int x = sprite_pos_x; x < sprite_end_x; x++){
|
||||||
|
if(ty < 0 || x < 0 || ty > zbuf[x])
|
||||||
|
continue;
|
||||||
|
if(x > viewport_w)
|
||||||
|
break;
|
||||||
|
int tex_x = ffloor((x-sprite_pos_x) * fdiv(fix(TSIZE), fix(sprite_w)));
|
||||||
|
tex_x %= TSIZE;
|
||||||
|
|
||||||
|
draw_stripe(tex_index[4], 0, sprite_pos_y, sprite_size, tex_x, x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct SpriteDist{
|
||||||
|
fixed_t dist;
|
||||||
|
int id;
|
||||||
|
};
|
||||||
|
|
||||||
|
int sprite_cmpfnc(const void *p1, const void *p2){
|
||||||
|
return ((struct SpriteDist*)p2)->dist - ((struct SpriteDist*)p1)->dist;
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_sprites(bopti_image_t *tex_index[], RcActor *player){
|
||||||
|
struct SpriteDist dists[SINDEX_S];
|
||||||
|
memset(dists, 0, sizeof(struct SpriteDist)*SINDEX_S);
|
||||||
|
for(int i = 0; i < spritec; i++){
|
||||||
|
Sprite *spr = sprite_index[i];
|
||||||
|
fixed_t d = player->pos.x - spr->pos.x;
|
||||||
|
d = fmul(d,d);
|
||||||
|
d += fmul(player->pos.y - spr->pos.y,player->pos.y - spr->pos.y);
|
||||||
|
dists[i].dist = d;
|
||||||
|
dists[i].id = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
qsort(dists, SINDEX_S, sizeof(struct SpriteDist), &sprite_cmpfnc);
|
||||||
|
|
||||||
|
int msprite = min(spritec,max_sprites);
|
||||||
|
for(int i = msprite; i > 0; i--){
|
||||||
|
struct SpriteDist *sd = &dists[i];
|
||||||
|
Sprite *spr = sprite_index[sd->id];
|
||||||
|
if(sd->dist > max_dist)
|
||||||
|
continue;
|
||||||
|
project_sprite(tex_index, spr, player);
|
||||||
|
}
|
||||||
|
}
|
21
include/C3D/config.h
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
//param. graphiques
|
||||||
|
#define screen_w 128
|
||||||
|
#define screen_h 64
|
||||||
|
#define viewport_w 128
|
||||||
|
#define viewport_h 64
|
||||||
|
#define max_dist fix(32)
|
||||||
|
//Max sprites to attempt to render
|
||||||
|
#define max_sprites 16
|
||||||
|
|
||||||
|
#define TSIZE 32
|
||||||
|
|
||||||
|
//Tex index
|
||||||
|
#define TINDEX_S 16
|
||||||
|
//Sprite index
|
||||||
|
#define SINDEX_S 64
|
||||||
|
|
||||||
|
#define debug 1 //pour afficher les infos de debug
|
||||||
|
|
||||||
|
#define asm_opti 0
|
|
@ -4,8 +4,11 @@
|
||||||
//vient de https://gitea.planet-casio.com/Slyvtt/OutRun/src/branch/master/src
|
//vient de https://gitea.planet-casio.com/Slyvtt/OutRun/src/branch/master/src
|
||||||
//
|
//
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
typedef int32_t fixed_t;
|
typedef int32_t fixed_t;
|
||||||
/* Standard arithmetic. */
|
/* Standard arithmetic. */
|
||||||
|
|
||||||
|
@ -69,11 +72,6 @@ static inline double f2double(fixed_t f)
|
||||||
return (double)f / 65536;
|
return (double)f / 65536;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double f2int(fixed_t f)
|
|
||||||
{
|
|
||||||
return (int)f / 65536;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline fixed_t feasein(fixed_t x)
|
static inline fixed_t feasein(fixed_t x)
|
||||||
{
|
{
|
||||||
return fmul(x, x);
|
return fmul(x, x);
|
||||||
|
@ -90,6 +88,10 @@ static inline fixed_t fease(fixed_t x)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline fixed_t fixabs(fixed_t x){
|
||||||
|
return x & 0x7FFFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
static inline fixed_t fV2d_dotp(V2d u, V2d v){
|
static inline fixed_t fV2d_dotp(V2d u, V2d v){
|
||||||
return fmul(u.x,v.x) + fmul(u.y,v.y);
|
return fmul(u.x,v.x) + fmul(u.y,v.y);
|
||||||
}
|
}
|
25
include/C3D/game.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
// Voir README.md pour license précise, par Fcalva 2023-2024 et est sous GPLv3
|
||||||
|
|
||||||
|
#ifndef game__h
|
||||||
|
#define game__h
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
#include "map.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
|
||||||
|
V2d pos;
|
||||||
|
V2d dir;
|
||||||
|
V2d plane;
|
||||||
|
|
||||||
|
} RcActor;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
|
||||||
|
RcActor player;
|
||||||
|
|
||||||
|
uint8_t *current_map;
|
||||||
|
|
||||||
|
} RcGame;
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,12 +1,16 @@
|
||||||
// Voir README.md pour license précise, par Fcalva 2023-2024 et est sous GPLv3
|
// Voir README.md pour license précise, par Fcalva 2023-2024 et est sous GPLv3
|
||||||
|
|
||||||
#include "fixed.h"
|
#include "fixed.h"
|
||||||
#ifndef map_test_M
|
#ifndef map__h
|
||||||
#define map_test_M
|
#define map__h
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
|
||||||
|
} RcMap;
|
||||||
|
|
||||||
//! Attention à avoir *exactement* la même taille entre ces valeurs et la carte dans map.c !
|
//! Attention à avoir *exactement* la même taille entre ces valeurs et la carte dans map.c !
|
||||||
|
|
||||||
#define map_w 64
|
#define map_w 64
|
||||||
#define map_h 128
|
#define map_h 128
|
||||||
|
|
||||||
#endif /* map_test.h */
|
#endif /* map__h */
|
36
include/C3D/moteur.h
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
// Voir README.md pour license précise, par Fcalva 2023-2024 et est sous GPLv3
|
||||||
|
|
||||||
|
#ifndef moteur_h
|
||||||
|
#define moteur_h
|
||||||
|
|
||||||
|
#include <libprof.h>
|
||||||
|
#include <gint/display.h>
|
||||||
|
#include "fixed.h"
|
||||||
|
#include "game.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
|
||||||
|
prof_t raycast_time;
|
||||||
|
prof_t draw_time;
|
||||||
|
|
||||||
|
} EngineTimers;
|
||||||
|
|
||||||
|
int get_pixel(bopti_image_t const *tex, int u, int v);
|
||||||
|
|
||||||
|
void dscale_bopti(bopti_image_t *tex, fixed_t scale_x, fixed_t scale_y,
|
||||||
|
int x, int y);
|
||||||
|
|
||||||
|
void draw_stripe(bopti_image_t *tex, int texSampleY, int linePos,
|
||||||
|
fixed_t texSize, int texX, int x);
|
||||||
|
|
||||||
|
void load_map();
|
||||||
|
void draw_walls(
|
||||||
|
#if debug
|
||||||
|
EngineTimers *timers,
|
||||||
|
#endif
|
||||||
|
RcGame *game
|
||||||
|
);
|
||||||
|
void move(RcGame *game);
|
||||||
|
|
||||||
|
#endif /* moteur */
|
25
include/C3D/sprites.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
// Voir README.md pour license précise, par Fcalva 2023-2024 et est sous GPLv3
|
||||||
|
|
||||||
|
#ifndef sprites__h
|
||||||
|
#define sprites__h
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
#include "fixed.h"
|
||||||
|
#include "game.h"
|
||||||
|
|
||||||
|
#include <gint/display.h>
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
V2d pos;
|
||||||
|
int tex;
|
||||||
|
} Sprite;
|
||||||
|
|
||||||
|
//Adds the sprite reference to the internal sprite index
|
||||||
|
// /!\ This sprite reference may be used at every call of draw_sprites
|
||||||
|
void add_sprite(Sprite *sprite);
|
||||||
|
|
||||||
|
void clear_sprites();
|
||||||
|
|
||||||
|
void draw_sprites(bopti_image_t *tex_index[], RcActor *player);
|
||||||
|
|
||||||
|
#endif
|
10
include/C3D/utils.h
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
// Voir README.md pour license précise, par Fcalva 2023-2024 et est sous GPLv3
|
||||||
|
|
||||||
|
#ifndef utils__h
|
||||||
|
#define utils__h
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#define min(x, xmin) (x > xmin ? xmin:x)
|
||||||
|
|
||||||
|
#endif
|
98
src/main.c
|
@ -1,20 +1,26 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include <gint/display.h>
|
#include <gint/display.h>
|
||||||
#include <gint/keyboard.h>
|
#include <gint/keyboard.h>
|
||||||
#include <gint/image.h>
|
#include <gint/image.h>
|
||||||
|
#include <gint/gray.h>
|
||||||
#include <gint/dma.h>
|
#include <gint/dma.h>
|
||||||
#include <gint/gdb.h>
|
#include <gint/gdb.h>
|
||||||
#include <libprof.h>
|
#include <libprof.h>
|
||||||
|
|
||||||
#include "fixed.h"
|
#include "fixed.h"
|
||||||
|
|
||||||
|
#include "game.h"
|
||||||
#include "moteur.h"
|
#include "moteur.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include "sprites.h"
|
||||||
|
|
||||||
//====== Copy3DEngine =====
|
//====== Copy3DEngine =====
|
||||||
// Git du moteur : https://gitea.planet-casio.com/Fcalva/Copy3DEngine
|
// Git du moteur : https://git.planet-casio.com/Fcalva/Copy3DEngine
|
||||||
// Git du jeu : [Rajoutez le vôtre ici]
|
// Git du jeu : [Rajoutez le vôtre ici]
|
||||||
//
|
//
|
||||||
// Page du jeu : [La vôtre ici]
|
// Page du jeu : [La vôtre ici]
|
||||||
|
@ -23,37 +29,36 @@
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef FXCG50
|
bopti_image_t *tex_index[TINDEX_S];
|
||||||
#error Ce code est pour FXCG50/G90+E uniquement, enlevez ce message a vos riques et périls
|
|
||||||
#endif
|
|
||||||
|
|
||||||
image_t *tex_index[TINDEX_S];
|
extern uint8_t map_test[map_w][map_h];
|
||||||
|
|
||||||
extern char map_test[map_w][map_h];
|
|
||||||
|
|
||||||
//Vos images ici
|
//Vos images ici
|
||||||
|
|
||||||
extern image_t briques0;
|
extern bopti_image_t briques0;
|
||||||
extern image_t buisson0;
|
extern bopti_image_t buisson0;
|
||||||
|
extern bopti_image_t sprite_tst;
|
||||||
|
|
||||||
char exit_game = 0;
|
char exit_game = 0;
|
||||||
char disp_frame_time = 0;
|
char disp_frame_time = 0;
|
||||||
char first_frame = 0;
|
char first_frame = 0;
|
||||||
int frame_time_timer = 1;
|
int frame_time_timer = 1;
|
||||||
|
|
||||||
fixed_t posX;
|
RcGame game = {
|
||||||
fixed_t posY;
|
.player = {
|
||||||
fixed_t dirX;
|
.pos = {fix(3.1), fix(3.1)},
|
||||||
fixed_t dirY;
|
.dir = {fix(0), fix(1)},
|
||||||
fixed_t planeX;
|
.plane = {fix(0.66), fix(0)}
|
||||||
fixed_t planeY;
|
},
|
||||||
|
.current_map = (void*)&map_test
|
||||||
|
};
|
||||||
|
|
||||||
int frame_time = 1;
|
int frame_time = 1;
|
||||||
|
|
||||||
void keys_get(){
|
void keys_get(){
|
||||||
pollevent();
|
pollevent();
|
||||||
|
|
||||||
move();
|
move(&game);
|
||||||
|
|
||||||
if (keydown(KEY_F1) && frame_time_timer <= 0) {
|
if (keydown(KEY_F1) && frame_time_timer <= 0) {
|
||||||
if (disp_frame_time == 0) {
|
if (disp_frame_time == 0) {
|
||||||
|
@ -74,8 +79,8 @@ void keys_get(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void main_menu(){
|
void main_menu(){
|
||||||
dtext_opt(198, 100, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, "Demo 3D", -1);
|
dtext_opt(198, 100, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, NAMEOFGAME, -1);
|
||||||
dtext_opt(198, 120, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, "De Fcalva", -1);
|
dtext_opt(198, 120, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, "De "AUTHOR, -1);
|
||||||
dtext_opt(198, 150, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, "Appuyez sur une touche", -1);
|
dtext_opt(198, 150, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, "Appuyez sur une touche", -1);
|
||||||
|
|
||||||
dupdate();
|
dupdate();
|
||||||
|
@ -89,33 +94,41 @@ int main(){
|
||||||
|
|
||||||
load_map();
|
load_map();
|
||||||
|
|
||||||
extern image_t *tex_index[TINDEX_S];
|
|
||||||
|
|
||||||
tex_index[1] = &buisson0;
|
tex_index[1] = &buisson0;
|
||||||
tex_index[2] = &briques0;
|
tex_index[2] = &briques0;
|
||||||
|
|
||||||
//Vos textures générées procéduralement
|
//Vos textures générées procéduralement (TODO)
|
||||||
|
|
||||||
tex_index[0] = image_alloc(64, 64, IMAGE_RGB565);
|
tex_index[0] = &briques0;
|
||||||
tex_index[3] = image_alloc(64, 64, IMAGE_RGB565);
|
tex_index[3] = &briques0;
|
||||||
|
|
||||||
image_fill(tex_index[0], 0x4228);
|
tex_index[4] = &sprite_tst;
|
||||||
image_fill(tex_index[3], 0x9dbd);
|
|
||||||
|
|
||||||
prof_init();
|
prof_init();
|
||||||
|
|
||||||
|
if(dgray(DGRAY_ON))
|
||||||
|
goto c3d_abort;
|
||||||
|
dupdate();
|
||||||
|
|
||||||
|
dclear(0);
|
||||||
|
|
||||||
#if debug
|
#if debug
|
||||||
EngineTimers timers;
|
EngineTimers timers;
|
||||||
|
//gdb_start_on_exception();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Sprite tsprite = {
|
||||||
|
.pos = {200000, 300000},
|
||||||
|
.tex = 4
|
||||||
|
};
|
||||||
|
|
||||||
|
add_sprite(&tsprite);
|
||||||
|
|
||||||
while (!exit_game) {
|
while (!exit_game) {
|
||||||
prof_t frame = prof_make();
|
prof_t frame = prof_make();
|
||||||
prof_enter(frame);
|
prof_enter(frame);
|
||||||
|
|
||||||
//Big brain drect()
|
dclear(C_WHITE);
|
||||||
dma_memset(gint_vram, 0x9dbd9dbd, viewport_w*viewport_h);
|
|
||||||
dma_memset((void*)((uint32_t)gint_vram + viewport_w*viewport_h),
|
|
||||||
0xc4c9c4c9, viewport_w*viewport_h);
|
|
||||||
|
|
||||||
if(first_frame){
|
if(first_frame){
|
||||||
main_menu();
|
main_menu();
|
||||||
|
@ -125,21 +138,20 @@ int main(){
|
||||||
|
|
||||||
draw_walls(
|
draw_walls(
|
||||||
#if debug
|
#if debug
|
||||||
&timers
|
&timers,
|
||||||
#endif
|
#endif
|
||||||
|
&game
|
||||||
);
|
);
|
||||||
|
|
||||||
if (disp_frame_time == 1) dprint( 1, 10, C_BLACK, "Frame time : %d ms", frame_time);
|
draw_sprites(tex_index, &game.player);
|
||||||
|
|
||||||
|
if (disp_frame_time == 1) dprint( 0, 0, C_BLACK, "%d ms", frame_time);
|
||||||
|
|
||||||
#if debug
|
#if debug
|
||||||
dprint( 1, 20, C_BLACK, "planeX : %d", planeX);
|
dprint( 1, 27, C_BLACK, "pX %d", game.player.pos.x);
|
||||||
dprint( 1, 30, C_BLACK, "planeY : %d", planeY);
|
dprint( 1, 36, C_BLACK, "pY %d", game.player.pos.y);
|
||||||
dprint( 1, 40, C_BLACK, "dirX : %d", dirX);
|
dprint( 1, 9, C_BLACK, "Rct %d", prof_time(timers.raycast_time));
|
||||||
dprint( 1, 50, C_BLACK, "dirY : %d", dirY);
|
dprint( 1, 18, C_BLACK, "Dt %d", prof_time(timers.draw_time));
|
||||||
dprint( 1, 60, C_BLACK, "posX : %d", posX);
|
|
||||||
dprint( 1, 70, C_BLACK, "posY : %d", posY);
|
|
||||||
dprint( 1, 80, C_BLACK, "Raycast time : %d", prof_time(timers.raycast_time));
|
|
||||||
dprint( 1, 90, C_BLACK, "Draw time : %d", prof_time(timers.draw_time));
|
|
||||||
timers.raycast_time = prof_make();
|
timers.raycast_time = prof_make();
|
||||||
timers.draw_time = prof_make();
|
timers.draw_time = prof_make();
|
||||||
#endif
|
#endif
|
||||||
|
@ -150,12 +162,16 @@ int main(){
|
||||||
first_frame = 0;
|
first_frame = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c3d_abort:
|
||||||
|
|
||||||
|
dgray(DGRAY_OFF);
|
||||||
|
|
||||||
prof_quit();
|
prof_quit();
|
||||||
|
|
||||||
//Libérez vos textures générées procéduralement
|
//Libérez vos textures générées procéduralement
|
||||||
|
|
||||||
image_free(tex_index[0]);
|
//bopti_free(tex_index[0]);
|
||||||
image_free(tex_index[3]);
|
//bopti_free(tex_index[3]);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
12
src/map.h
|
@ -1,12 +0,0 @@
|
||||||
// Voir README.md pour license précise, par Fcalva 2023-2024 et est sous GPLv3
|
|
||||||
|
|
||||||
#include "fixed.h"
|
|
||||||
#ifndef map_test_M
|
|
||||||
#define map_test_M
|
|
||||||
|
|
||||||
//! Attention à avoir *exactement* la même taille entre ces valeurs et la carte dans map.c !
|
|
||||||
|
|
||||||
#define map_w 64
|
|
||||||
#define map_h 128
|
|
||||||
|
|
||||||
#endif /* map_test.h */
|
|
40
src/moteur.h
|
@ -1,40 +0,0 @@
|
||||||
// Voir README.md pour license précise, par Fcalva 2023-2024 et est sous GPLv3
|
|
||||||
|
|
||||||
#ifndef moteur_h
|
|
||||||
#define moteur_h
|
|
||||||
|
|
||||||
#include "libprof.h"
|
|
||||||
#include <gint/image.h>
|
|
||||||
|
|
||||||
//param. graphiques
|
|
||||||
#define screen_w 396
|
|
||||||
#define screen_h 224
|
|
||||||
#define viewport_w 396
|
|
||||||
#define viewport_h 224
|
|
||||||
#define max_dist fix(32) //en tuiles << 16, actuellement 32
|
|
||||||
|
|
||||||
#define TINDEX_S 256
|
|
||||||
|
|
||||||
#define debug 0 //pour afficher les infos de debug
|
|
||||||
|
|
||||||
#define asm_opti 0
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
|
|
||||||
prof_t raycast_time;
|
|
||||||
prof_t draw_time;
|
|
||||||
|
|
||||||
} EngineTimers;
|
|
||||||
|
|
||||||
void draw_stripe(image_t *tex, int texSampleY, int linePos, fixed_t texSize, int texX, int x);
|
|
||||||
|
|
||||||
void load_map();
|
|
||||||
void end_screen();
|
|
||||||
void draw_walls(
|
|
||||||
#if debug
|
|
||||||
EngineTimers *timers
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
void move();
|
|
||||||
|
|
||||||
#endif /* moteur */
|
|