diff --git a/Examples/AmogusGame/CMakeLists.txt b/Examples/AmogusGame/CMakeLists.txt new file mode 100644 index 0000000..33d4e64 --- /dev/null +++ b/Examples/AmogusGame/CMakeLists.txt @@ -0,0 +1,44 @@ +# 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() diff --git a/Examples/AmogusGame/README.md b/Examples/AmogusGame/README.md new file mode 100644 index 0000000..63028d2 --- /dev/null +++ b/Examples/AmogusGame/README.md @@ -0,0 +1,5 @@ +# Amogus + +### Mogus + +Sus diff --git a/Examples/AmogusGame/assets-cg/fxconv-metadata.txt b/Examples/AmogusGame/assets-cg/fxconv-metadata.txt new file mode 100644 index 0000000..50fbc7f --- /dev/null +++ b/Examples/AmogusGame/assets-cg/fxconv-metadata.txt @@ -0,0 +1,6 @@ +zombard1.png: + type: bopti-image + name: zombard +skybox0.png: + type: bopti-image + name: skybox_quarter diff --git a/Examples/AmogusGame/assets-cg/icon-cg.xcf b/Examples/AmogusGame/assets-cg/icon-cg.xcf new file mode 100644 index 0000000..5b854f0 Binary files /dev/null and b/Examples/AmogusGame/assets-cg/icon-cg.xcf differ diff --git a/Examples/AmogusGame/assets-cg/icon-sel.png b/Examples/AmogusGame/assets-cg/icon-sel.png new file mode 100644 index 0000000..60ce63d Binary files /dev/null and b/Examples/AmogusGame/assets-cg/icon-sel.png differ diff --git a/Examples/AmogusGame/assets-cg/icon-uns.png b/Examples/AmogusGame/assets-cg/icon-uns.png new file mode 100644 index 0000000..a0a0c6b Binary files /dev/null and b/Examples/AmogusGame/assets-cg/icon-uns.png differ diff --git a/Examples/AmogusGame/assets-cg/textures/0.png b/Examples/AmogusGame/assets-cg/textures/0.png new file mode 100644 index 0000000..b0faf7f Binary files /dev/null and b/Examples/AmogusGame/assets-cg/textures/0.png differ diff --git a/Examples/AmogusGame/assets-cg/textures/1.png b/Examples/AmogusGame/assets-cg/textures/1.png new file mode 100644 index 0000000..c25a001 Binary files /dev/null and b/Examples/AmogusGame/assets-cg/textures/1.png differ diff --git a/Examples/AmogusGame/assets-cg/textures/2.png b/Examples/AmogusGame/assets-cg/textures/2.png new file mode 100644 index 0000000..c4c4cf9 Binary files /dev/null and b/Examples/AmogusGame/assets-cg/textures/2.png differ diff --git a/Examples/AmogusGame/assets-cg/textures/3.png b/Examples/AmogusGame/assets-cg/textures/3.png new file mode 100644 index 0000000..9a793b4 Binary files /dev/null and b/Examples/AmogusGame/assets-cg/textures/3.png differ diff --git a/Examples/AmogusGame/assets-cg/textures/4.png b/Examples/AmogusGame/assets-cg/textures/4.png new file mode 100644 index 0000000..8325155 Binary files /dev/null and b/Examples/AmogusGame/assets-cg/textures/4.png differ diff --git a/Examples/AmogusGame/assets-cg/textures/fxconv-metadata.txt b/Examples/AmogusGame/assets-cg/textures/fxconv-metadata.txt new file mode 100644 index 0000000..4898489 --- /dev/null +++ b/Examples/AmogusGame/assets-cg/textures/fxconv-metadata.txt @@ -0,0 +1,19 @@ +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 diff --git a/Examples/AmogusGame/assets-cg/textures/rick.png b/Examples/AmogusGame/assets-cg/textures/rick.png new file mode 100644 index 0000000..e6e5307 Binary files /dev/null and b/Examples/AmogusGame/assets-cg/textures/rick.png differ diff --git a/Examples/AmogusGame/src/fixed.h b/Examples/AmogusGame/src/fixed.h new file mode 100644 index 0000000..7818697 --- /dev/null +++ b/Examples/AmogusGame/src/fixed.h @@ -0,0 +1,87 @@ +//--- +// fixed: 16:16 fixed-point arithmetic +//--- +//vient de https://gitea.planet-casio.com/Slyvtt/OutRun/src/branch/master/src +// +#pragma once +#include + +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); + } +} diff --git a/Examples/AmogusGame/src/main.c b/Examples/AmogusGame/src/main.c new file mode 100644 index 0000000..890dc58 --- /dev/null +++ b/Examples/AmogusGame/src/main.c @@ -0,0 +1,166 @@ +#include +#include + +#include +#include +#include +#include + +#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; +} diff --git a/Examples/AmogusGame/src/map.c b/Examples/AmogusGame/src/map.c new file mode 100644 index 0000000..bfbab7f --- /dev/null +++ b/Examples/AmogusGame/src/map.c @@ -0,0 +1,71 @@ +// Voir README.md pour license précise, par Fcalva 1011-1011 et est sous GPLv1 + +#include "map.h" +#include "moteur.h" + +char map_test[map_w][map_h] = { + {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,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,1,1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,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,0,0,1,0,1,0,0,0,0,0,0,0,1,0,0,1,1,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, + {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,1,0,1,0,0,1,0,0,0,0,1,0,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, + {1,0,0,0,1,0,1,0,0,0,0,0,0,0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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} +}; diff --git a/Examples/AmogusGame/src/map.h b/Examples/AmogusGame/src/map.h new file mode 100644 index 0000000..e9289b9 --- /dev/null +++ b/Examples/AmogusGame/src/map.h @@ -0,0 +1,12 @@ +// 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 */ diff --git a/Examples/AmogusGame/src/moteur.c b/Examples/AmogusGame/src/moteur.c new file mode 100644 index 0000000..e61c78c --- /dev/null +++ b/Examples/AmogusGame/src/moteur.c @@ -0,0 +1,325 @@ +// Voir README.md pour license précise, par Fcalva 2023-2024 et est sous GPLv3 + +#include +#include +#include +#include + +#include +#include +#include + +#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); + } +} diff --git a/Examples/AmogusGame/src/moteur.h b/Examples/AmogusGame/src/moteur.h new file mode 100644 index 0000000..fb32a09 --- /dev/null +++ b/Examples/AmogusGame/src/moteur.h @@ -0,0 +1,22 @@ +// Voir README.md pour license précise, par Fcalva 2023-2024 et est sous GPLv3 + +#ifndef moteur_h +#define moteur_h + +#include + +//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 */ diff --git a/src/main.c b/src/main.c index e9322cb..1b515d2 100644 --- a/src/main.c +++ b/src/main.c @@ -12,7 +12,7 @@ #include "map.h" //====== Copy3DEngine ===== -// Git du moteur : TODO +// 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] @@ -74,8 +74,8 @@ void keys_get(){ } 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 Fcalva" /*AUTHOR*/, -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 " AUTHOR, -1); dtext_opt(198, 150, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, "Appuyez sur une touche", -1); dupdate(); @@ -117,13 +117,10 @@ int main(){ if(first_frame == 1){ main_menu(); - first_frame = 0; } keys_get(); - logic(); - if (disp_frame_time == 1) dprint( 1, 10, C_BLACK, "Frame time : %d ms", frame_time); #ifdef debug @@ -138,6 +135,7 @@ int main(){ dupdate(); prof_leave(frame); frame_time = (int)prof_time(frame)/1000; + first_frame = 0; } prof_quit(); diff --git a/src/moteur.c b/src/moteur.c index 04d51ed..e61c78c 100644 --- a/src/moteur.c +++ b/src/moteur.c @@ -87,34 +87,6 @@ void move() { if (dirY < -0xFFFF) dirY = -0xFFFF; } - -void end_screen(){ - int a; - - dtext_opt(198, 70, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, "Vous avez battu Maze3D !", -1); - dtext_opt(198, 90, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, "Optn - Rejouer", -1); - dtext_opt(198, 100, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, "Menu - Quitter", -1); - - dupdate(); - - while(true){ - a = getkey().key; - if (a == KEY_OPTN) { - load_map(); - break; - } - } -} - -void logic(){ - extern fixed_t posX; - extern fixed_t posY; - - if (ffloor(posX) == 15 && ffloor(posY) == 113) { - end_screen(); - } -} - void spawn_gen(){ extern fixed_t posX; extern fixed_t posY; @@ -190,11 +162,7 @@ void spawn_gen(){ dirY = start_dirY; //initial direction vector } - - void load_map(){ - - spawn_gen(); } diff --git a/src/moteur.h b/src/moteur.h index 04ea33b..fb32a09 100644 --- a/src/moteur.h +++ b/src/moteur.h @@ -16,7 +16,6 @@ void load_map(); void end_screen(); -void logic(); void draw_walls(image_t *frame_buffer); void move();