mirror of
https://git.planet-casio.com/Fcalva/Copy3DEngine.git
synced 2025-06-06 15:35:03 +02:00
167 lines
3.2 KiB
C
167 lines
3.2 KiB
C
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <math.h>
|
|
|
|
#include <gint/display.h>
|
|
#include <gint/keyboard.h>
|
|
#include <gint/image.h>
|
|
#include <gint/gray.h>
|
|
#include <gint/dma.h>
|
|
#include <gint/gdb.h>
|
|
#include <libprof.h>
|
|
|
|
#include "fixed.h"
|
|
|
|
#include "gint/display-fx.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
|
|
//
|
|
//
|
|
|
|
bopti_image_t *tex_index[TINDEX_S];
|
|
|
|
extern char map_test[map_w][map_h];
|
|
|
|
//Vos images ici
|
|
|
|
extern bopti_image_t briques0;
|
|
extern bopti_image_t buisson0;
|
|
|
|
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();
|
|
|
|
tex_index[1] = &buisson0;
|
|
tex_index[2] = &briques0;
|
|
|
|
//Vos textures générées procéduralement
|
|
|
|
tex_index[0] = &briques0;//bopti_make(64,64,1);
|
|
tex_index[3] = &briques0;//bopti_make(64, 64,0);
|
|
|
|
prof_init();
|
|
|
|
if(dgray(DGRAY_ON))
|
|
goto c3d_abort;
|
|
dupdate();
|
|
|
|
dimage(0,0,tex_index[0]);
|
|
dimage(32,0,tex_index[1]);
|
|
dimage(64,0,tex_index[2]);
|
|
dimage(96,0,tex_index[3]);
|
|
|
|
dupdate();
|
|
getkey();
|
|
|
|
#if debug
|
|
EngineTimers timers;
|
|
#endif
|
|
|
|
while (!exit_game) {
|
|
prof_t frame = prof_make();
|
|
prof_enter(frame);
|
|
|
|
dclear(C_WHITE);
|
|
|
|
if(first_frame){
|
|
main_menu();
|
|
}
|
|
|
|
keys_get();
|
|
|
|
draw_walls(
|
|
#if debug
|
|
&timers
|
|
#endif
|
|
);
|
|
|
|
if (disp_frame_time == 1) dprint( 0, 0, C_BLACK, "%d ms", frame_time);
|
|
|
|
#if debug
|
|
dprint( 1, 9, C_BLACK, "plX %d", planeX);
|
|
dprint( 1, 18, C_BLACK, "plY %d", planeY);
|
|
dprint( 1, 27, C_BLACK, "dX %d", dirX);
|
|
dprint( 1, 36, C_BLACK, "dY %d", dirY);
|
|
dprint( 1, 45, C_BLACK, "pX %d", posX);
|
|
dprint( 1, 54, C_BLACK, "pY %d", posY);
|
|
dprint( 1, 63, C_BLACK, "Rct %d", prof_time(timers.raycast_time));
|
|
dprint( 1, 72, C_BLACK, "Dt %d", prof_time(timers.draw_time));
|
|
timers.raycast_time = prof_make();
|
|
timers.draw_time = prof_make();
|
|
#endif
|
|
|
|
dupdate();
|
|
prof_leave(frame);
|
|
frame_time = (int)prof_time(frame)/1000;
|
|
first_frame = 0;
|
|
}
|
|
c3d_abort:
|
|
|
|
dgray(DGRAY_OFF);
|
|
|
|
prof_quit();
|
|
|
|
//Libérez vos textures générées procéduralement
|
|
|
|
//bopti_free(tex_index[0]);
|
|
//bopti_free(tex_index[3]);
|
|
|
|
return 1;
|
|
}
|