diff --git a/eng/moteur.c b/eng/moteur.c index 9d5a7de..2310d95 100644 --- a/eng/moteur.c +++ b/eng/moteur.c @@ -33,7 +33,7 @@ void move(RcGame *game) { fixed_t c_rotSpeed = fix(cos(f2float(rotSpeed))); fixed_t s_rotSpeed = fix(sin(f2float(rotSpeed))); - uint8_t *map_test = game->current_map; + uint8_t *map_test = game->current_map->dat; V2d *plane = &game->player.plane; V2d *dir = &game->player.dir; V2d *pos = &game->player.pos; @@ -221,7 +221,7 @@ void draw_walls( fixed_t planeX = game->player.plane.x; fixed_t planeY = game->player.plane.y; extern bopti_image_t *tex_index[TINDEX_S]; - uint8_t *map_test = game->current_map; + uint8_t *map_test = game->current_map->dat; fixed_t cameraX; fixed_t rayDirX; diff --git a/eng/sprites.c b/eng/sprites.c index 6c8b157..5b27ba4 100644 --- a/eng/sprites.c +++ b/eng/sprites.c @@ -5,11 +5,11 @@ #include #include +#include "fixed.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]; diff --git a/include/C3D/config.h b/include/C3D/config.h index 601cdde..c7b4331 100644 --- a/include/C3D/config.h +++ b/include/C3D/config.h @@ -22,11 +22,13 @@ //Tex index #define TINDEX_S 16 -//Sprite index +//Sprite index - map sprites are 1/2 that #define SINDEX_S 64 //Game logic hooks #define HINDEX_S 16 + + //===== Paramètres de debug ===== #define debug 1 //pour afficher les infos de debug diff --git a/include/C3D/game.h b/include/C3D/game.h index ea5c32c..af2dd82 100644 --- a/include/C3D/game.h +++ b/include/C3D/game.h @@ -1,11 +1,25 @@ // Voir README.md pour license précise, par Fcalva 2023-2024 et est sous GPLv3 // See README.md for the exact licensing, by ... -#ifndef game__h -#define game__h +#pragma once #include "utils.h" -#include "map.h" + +typedef struct { + V2d pos; + int tex; +} Sprite; + +typedef struct { + int w, h; + + uint8_t *dat; + + int spritec; + + Sprite sprites[SINDEX_S/2]; + +} RcMap; typedef struct { @@ -27,7 +41,7 @@ typedef struct { int logic_time; - uint8_t *current_map; + RcMap *current_map; RcFlags flags; @@ -45,4 +59,3 @@ void clear_logic_hooks(); void do_logic(RcGame *game, int delta); -#endif diff --git a/include/C3D/map.h b/include/C3D/map.h index 86d8f31..e64dfa8 100644 --- a/include/C3D/map.h +++ b/include/C3D/map.h @@ -1,17 +1,14 @@ // Voir README.md pour license précise, par Fcalva 2023-2024 et est sous GPLv3 // See README.md for the exact licensing, by ... +#pragma once + #include "fixed.h" -#ifndef map__h -#define map__h - -typedef struct { - -} RcMap; +#include "sprites.h" +//TODO : deprecate //! 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__h */ diff --git a/include/C3D/moteur.h b/include/C3D/moteur.h index 7161b00..9eb2215 100644 --- a/include/C3D/moteur.h +++ b/include/C3D/moteur.h @@ -1,8 +1,7 @@ // Voir README.md pour license précise, par Fcalva 2023-2024 et est sous GPLv3 // See README.md for the exact licensing, by ... -#ifndef moteur_h -#define moteur_h +#pragma once #include #include @@ -34,4 +33,3 @@ void draw_walls( ); void move(RcGame *game); -#endif /* moteur */ diff --git a/include/C3D/sprites.h b/include/C3D/sprites.h index 63c8eda..805ccb3 100644 --- a/include/C3D/sprites.h +++ b/include/C3D/sprites.h @@ -1,20 +1,14 @@ // Voir README.md pour license précise, par Fcalva 2023-2024 et est sous GPLv3 // See README.md for the exact licensing, by ... -#ifndef sprites__h -#define sprites__h +#pragma once + +#include #include "utils.h" #include "fixed.h" #include "game.h" -#include - -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); @@ -23,4 +17,3 @@ void clear_sprites(); void draw_sprites(bopti_image_t *tex_index[], RcActor *player); -#endif diff --git a/include/C3D/utils.h b/include/C3D/utils.h index 006be38..142a40d 100644 --- a/include/C3D/utils.h +++ b/include/C3D/utils.h @@ -1,11 +1,9 @@ // Voir README.md pour license précise, par Fcalva 2023-2024 et est sous GPLv3 // See README.md for the exact licensing, by ... -#ifndef utils__h -#define utils__h +#pragma once #include #define min(x, xmin) (x > xmin ? xmin:x) -#endif diff --git a/src/main.c b/src/main.c index 3c020ca..45125c8 100644 --- a/src/main.c +++ b/src/main.c @@ -14,10 +14,10 @@ #include "fixed.h" #include "game.h" +#include "sprites.h" #include "moteur.h" #include "map.h" #include "config.h" -#include "sprites.h" //====== Copy3DEngine ===== // Git du moteur : https://git.planet-casio.com/Fcalva/Copy3DEngine @@ -43,13 +43,19 @@ char disp_frame_time = 0; char first_frame = 0; int frame_time_timer = 1; +RcMap map0 = { + .w = 128, + .h = 64, + .dat = (void*)&map_test +}; + RcGame game = { .player = { .pos = {fix(3.1), fix(3.1)}, .dir = {fix(0), fix(1)}, .plane = {fix(0.66), fix(0)} }, - .current_map = (void*)&map_test, + .current_map = &map0, .flags = {0} };