#include #include #include #include #include #include #define USB #ifdef USB #include #include #endif #include "fixed.h" #include "moteur.h" #include "map_test.h" //====== Maze3D V0.2 ===== // Git du moteur : https://github.com/attilavs2/Raycaster_prealpha // Git du jeu : https://gitea.planet-casio.com/Fcalva/Maze3D // // Page du jeu : https://www.planet-casio.com/Fr/programmes/programme4355-1-maze3d-fcalva-jeux-reflexion.html // // Tout le code de cette version est en GPL3 // Game design : Fcalva (aka. fklv, Fcalva#6860, attilavs2) // Programmation : Fcalva // "Art" : Fcalva // // // #ifndef FXCG50 #error Ce code est pour FXCG50/G90+E uniquement, enlevez ce message a vos riques et périls #endif #ifdef USB void USB_capture() { if (usb_is_open()) usb_fxlink_screenshot(false); } #endif //#define debug //pour afficher les infos de debug extern char map_test[map_w][map_h]; extern image_t briques0; extern image_t buisson0; char exit_game = 0; char disp_frame_time = 0; char first_frame = 1; int frame_time_timer = 1; int capture_timer = 1; fixed_t posX; fixed_t posY; fixed_t dirX; fixed_t dirY; fixed_t planeX; fixed_t planeY; int frame_time = 0; void keys_get(){ move(); pollevent(); 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_F6)) exit_game = 1; #ifdef debug if (keydown(KEY_TAN)) end_screen(); #endif #ifdef USB if (keydown(KEY_0) && keydown(KEY_EXE) && capture_timer <= 0) { USB_capture(); capture_timer = 10; } capture_timer--; #endif } void main_menu(){ dtext_opt(198, 100, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, "Maze 3D", -1); dtext_opt(198, 120, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, "De Fcalva", -1); dtext_opt(198, 150, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, "Appuyez sur une touche", -1); dtext( 1, 1, C_BLACK, "Version BETA"); dupdate(); getkey(); } int main(){ dclear(C_WHITE); //trucs de chargement load_map(); image_t frame_buffer = *image_alloc(viewport_w, viewport_h, IMAGE_RGB565A); image_t sky_tex = *image_alloc(64, 64, IMAGE_RGB565); image_t WXOR_tex = *image_alloc(64, 64, IMAGE_RGB565); image_t D_tex = *image_alloc(64, 64, IMAGE_RGB565); int i, j; for (i = 0; i<= 64; i++){ for (j = 0; j<= 64; j++){ int c = (int)floor((float)(i ^ j) * 0.5); unsigned short color = (c << 8) + (c << 4) + c; image_set_pixel(&WXOR_tex, i, j, color); } } image_fill(&D_tex, 0x4228); image_fill(&sky_tex, 0x9dbd); prof_init(); #ifdef USB usb_interface_t const *interfaces[] = {&usb_ff_bulk, NULL}; usb_open(interfaces, GINT_CALL_NULL); #endif while (exit_game == 0) { prof_t frame = prof_make(); prof_enter(frame); drect(0, 0, 395, 112, 0x9dbd); drect(0,112, 395, 243, 0xc4c9); image_clear(&frame_buffer); draw_walls(&buisson0, &briques0, &sky_tex, &WXOR_tex, &D_tex, &frame_buffer); dimage(0, 0, &frame_buffer); if(first_frame == 1) main_menu(); keys_get(); logic(); 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; } prof_quit(); usb_close(); free(&sky_tex); free(&WXOR_tex); free(&D_tex); free(&frame_buffer); return 1; }