mirror of
https://git.planet-casio.com/Fcalva/Copy3DEngine.git
synced 2024-12-28 04:23:44 +01:00
Refactoring map + #pragma once
This commit is contained in:
parent
599d5295b7
commit
82ab21aed4
9 changed files with 41 additions and 34 deletions
|
@ -33,7 +33,7 @@ void move(RcGame *game) {
|
||||||
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)));
|
||||||
|
|
||||||
uint8_t *map_test = game->current_map;
|
uint8_t *map_test = game->current_map->dat;
|
||||||
V2d *plane = &game->player.plane;
|
V2d *plane = &game->player.plane;
|
||||||
V2d *dir = &game->player.dir;
|
V2d *dir = &game->player.dir;
|
||||||
V2d *pos = &game->player.pos;
|
V2d *pos = &game->player.pos;
|
||||||
|
@ -221,7 +221,7 @@ void draw_walls(
|
||||||
fixed_t planeX = game->player.plane.x;
|
fixed_t planeX = game->player.plane.x;
|
||||||
fixed_t planeY = game->player.plane.y;
|
fixed_t planeY = game->player.plane.y;
|
||||||
extern bopti_image_t *tex_index[TINDEX_S];
|
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 cameraX;
|
||||||
fixed_t rayDirX;
|
fixed_t rayDirX;
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "fixed.h"
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "sprites.h"
|
#include "sprites.h"
|
||||||
#include "moteur.h"
|
#include "moteur.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "fixed.h"
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
extern fixed_t zbuf[viewport_w];
|
extern fixed_t zbuf[viewport_w];
|
||||||
|
|
|
@ -22,11 +22,13 @@
|
||||||
|
|
||||||
//Tex index
|
//Tex index
|
||||||
#define TINDEX_S 16
|
#define TINDEX_S 16
|
||||||
//Sprite index
|
//Sprite index - map sprites are 1/2 that
|
||||||
#define SINDEX_S 64
|
#define SINDEX_S 64
|
||||||
//Game logic hooks
|
//Game logic hooks
|
||||||
#define HINDEX_S 16
|
#define HINDEX_S 16
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//===== Paramètres de debug =====
|
//===== Paramètres de debug =====
|
||||||
|
|
||||||
#define debug 1 //pour afficher les infos de debug
|
#define debug 1 //pour afficher les infos de debug
|
||||||
|
|
|
@ -1,11 +1,25 @@
|
||||||
// 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
|
||||||
// See README.md for the exact licensing, by ...
|
// See README.md for the exact licensing, by ...
|
||||||
|
|
||||||
#ifndef game__h
|
#pragma once
|
||||||
#define game__h
|
|
||||||
|
|
||||||
#include "utils.h"
|
#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 {
|
typedef struct {
|
||||||
|
|
||||||
|
@ -27,7 +41,7 @@ typedef struct {
|
||||||
|
|
||||||
int logic_time;
|
int logic_time;
|
||||||
|
|
||||||
uint8_t *current_map;
|
RcMap *current_map;
|
||||||
|
|
||||||
RcFlags flags;
|
RcFlags flags;
|
||||||
|
|
||||||
|
@ -45,4 +59,3 @@ void clear_logic_hooks();
|
||||||
|
|
||||||
void do_logic(RcGame *game, int delta);
|
void do_logic(RcGame *game, int delta);
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,17 +1,14 @@
|
||||||
// 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
|
||||||
// See README.md for the exact licensing, by ...
|
// See README.md for the exact licensing, by ...
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#include "fixed.h"
|
#include "fixed.h"
|
||||||
#ifndef map__h
|
#include "sprites.h"
|
||||||
#define map__h
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
|
|
||||||
} RcMap;
|
|
||||||
|
|
||||||
|
//TODO : deprecate
|
||||||
//! 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__h */
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
// 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
|
||||||
// See README.md for the exact licensing, by ...
|
// See README.md for the exact licensing, by ...
|
||||||
|
|
||||||
#ifndef moteur_h
|
#pragma once
|
||||||
#define moteur_h
|
|
||||||
|
|
||||||
#include <libprof.h>
|
#include <libprof.h>
|
||||||
#include <gint/display.h>
|
#include <gint/display.h>
|
||||||
|
@ -34,4 +33,3 @@ void draw_walls(
|
||||||
);
|
);
|
||||||
void move(RcGame *game);
|
void move(RcGame *game);
|
||||||
|
|
||||||
#endif /* moteur */
|
|
||||||
|
|
|
@ -1,20 +1,14 @@
|
||||||
// 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
|
||||||
// See README.md for the exact licensing, by ...
|
// See README.md for the exact licensing, by ...
|
||||||
|
|
||||||
#ifndef sprites__h
|
#pragma once
|
||||||
#define sprites__h
|
|
||||||
|
#include <gint/display.h>
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "fixed.h"
|
#include "fixed.h"
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
|
|
||||||
#include <gint/display.h>
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
V2d pos;
|
|
||||||
int tex;
|
|
||||||
} Sprite;
|
|
||||||
|
|
||||||
//Adds the sprite reference to the internal sprite index
|
//Adds the sprite reference to the internal sprite index
|
||||||
// /!\ This sprite reference may be used at every call of draw_sprites
|
// /!\ This sprite reference may be used at every call of draw_sprites
|
||||||
void add_sprite(Sprite *sprite);
|
void add_sprite(Sprite *sprite);
|
||||||
|
@ -23,4 +17,3 @@ void clear_sprites();
|
||||||
|
|
||||||
void draw_sprites(bopti_image_t *tex_index[], RcActor *player);
|
void draw_sprites(bopti_image_t *tex_index[], RcActor *player);
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
// 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
|
||||||
// See README.md for the exact licensing, by ...
|
// See README.md for the exact licensing, by ...
|
||||||
|
|
||||||
#ifndef utils__h
|
#pragma once
|
||||||
#define utils__h
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#define min(x, xmin) (x > xmin ? xmin:x)
|
#define min(x, xmin) (x > xmin ? xmin:x)
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
10
src/main.c
10
src/main.c
|
@ -14,10 +14,10 @@
|
||||||
#include "fixed.h"
|
#include "fixed.h"
|
||||||
|
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
|
#include "sprites.h"
|
||||||
#include "moteur.h"
|
#include "moteur.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "sprites.h"
|
|
||||||
|
|
||||||
//====== Copy3DEngine =====
|
//====== Copy3DEngine =====
|
||||||
// Git du moteur : https://git.planet-casio.com/Fcalva/Copy3DEngine
|
// Git du moteur : https://git.planet-casio.com/Fcalva/Copy3DEngine
|
||||||
|
@ -43,13 +43,19 @@ char disp_frame_time = 0;
|
||||||
char first_frame = 0;
|
char first_frame = 0;
|
||||||
int frame_time_timer = 1;
|
int frame_time_timer = 1;
|
||||||
|
|
||||||
|
RcMap map0 = {
|
||||||
|
.w = 128,
|
||||||
|
.h = 64,
|
||||||
|
.dat = (void*)&map_test
|
||||||
|
};
|
||||||
|
|
||||||
RcGame game = {
|
RcGame game = {
|
||||||
.player = {
|
.player = {
|
||||||
.pos = {fix(3.1), fix(3.1)},
|
.pos = {fix(3.1), fix(3.1)},
|
||||||
.dir = {fix(0), fix(1)},
|
.dir = {fix(0), fix(1)},
|
||||||
.plane = {fix(0.66), fix(0)}
|
.plane = {fix(0.66), fix(0)}
|
||||||
},
|
},
|
||||||
.current_map = (void*)&map_test,
|
.current_map = &map0,
|
||||||
.flags = {0}
|
.flags = {0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue