Refactoring map + #pragma once

This commit is contained in:
attilavs2 2024-10-10 17:53:09 +02:00
parent 599d5295b7
commit 82ab21aed4
9 changed files with 41 additions and 34 deletions

View file

@ -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;

View file

@ -5,11 +5,11 @@
#include <stdlib.h>
#include <string.h>
#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];

View file

@ -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

View file

@ -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

View file

@ -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 */

View file

@ -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 <libprof.h>
#include <gint/display.h>
@ -34,4 +33,3 @@ void draw_walls(
);
void move(RcGame *game);
#endif /* moteur */

View file

@ -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 <gint/display.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);
@ -23,4 +17,3 @@ void clear_sprites();
void draw_sprites(bopti_image_t *tex_index[], RcActor *player);
#endif

View file

@ -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 <stdint.h>
#define min(x, xmin) (x > xmin ? xmin:x)
#endif

View file

@ -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}
};