// Voir README.md pour license précise, par Fcalva 2023-2024 et est sous GPLv3 #include #include "C3D/map.h" #include "C3D/moteur.h" #include "C3D/game.h" #include "C3D/fixed.h" #include "map.h" #include "game.h" #define SEC_ROM __attribute__((section(".rodata"))) int trigger_weapon_anvilstick(RcGame *_game){ CCGame *game = (void*)_game; game->curr_weapon = weap_anvilstick; game->weapon_use = 0; return 0; } uint8_t SEC_ROM map_dat0[] = { 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, 6,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,6, 6,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,6, 6,0,0,0,0,0,6,6,5,5,5,6,6,6,6,6,0,0,0,6, 6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,6, 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,0,6,6,6,6, 6,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,6, 6,0,0,0,0,0,6,0,6,0,0,6,0,0,6,0,0,6,0,6, 6,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,6, 6,0,1,6,5,5,6,0,0,0,0,0,0,0,0,0,0,0,0,6, 6,1,0,0,0,0,0,0,6,0,0,6,0,0,6,0,0,6,0,6, 6,0,1,6,6,6,6,0,0,0,0,0,0,0,0,0,0,0,0,6, 6,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,6, 6,0,0,0,0,0,6,0,6,0,0,6,0,0,6,0,0,6,0,6, 6,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,6, 6,0,0,0,0,0,6,6,6,6,6,6,6,6,6,6,6,6,6,6, 6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6, 6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6, 6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6, 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6 }; CCMap SEC_ROM map0 = { ._bmap = { .w = 20, .h = 20, .dat = (void*)&map_dat0, .start_pos = {fix(3.1),fix(1.1)}, .sprites = { {.pos = {fix(4.2),fix(14.2)}, .tex = 4}, {.pos = {fix(8.2),fix(10.2)}, .tex = 4} }, .spritec = 2 }, .triggers = { {.pos = {10,2}, .dat = {.tolvl = 1}, .type = 0 }, {}, {} } }; uint8_t SEC_ROM map_dat1[] = { 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, 6,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6, 6,0,0,6,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,6, 6,0,6,6,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,6, 6,0,0,0,6,0,0,0,0,0,0,0,2,0,0,0,0,0,0,6, 6,6,6,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6, 6,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6, 6,0,6,6,6,6,6,6,6,6,6,6,6,6,6,6,0,0,0,6, 6,0,0,0,0,0,0,0,0,6,0,0,0,0,0,6,0,0,0,6, 6,6,0,6,6,6,0,6,0,0,0,6,6,6,6,6,0,0,0,6, 6,0,0,0,0,0,0,6,6,6,6,0,0,0,6,6,0,0,0,6, 6,0,5,5,0,0,0,6,6,6,6,6,0,6,5,6,0,0,6,6, 6,0,5,0,0,5,0,6,0,0,0,0,0,0,0,0,0,6,0,6, 6,0,0,0,5,5,0,0,0,5,0,6,0,6,6,6,6,0,0,6, 6,0,5,0,0,0,0,6,6,0,0,6,0,6,0,0,0,0,0,6, 6,0,0,0,0,0,0,0,0,0,6,0,0,6,0,0,0,0,0,6, 6,0,6,6,6,6,6,6,6,6,6,0,5,6,6,6,6,6,6,6, 6,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,6, 6,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,6, 6,6,6,5,5,6,6,5,6,6,6,6,6,6,6,6,6,6,6,6 }; CCMap SEC_ROM map1 = { ._bmap = { .w = 20, .h = 20, .dat = map_dat1, .start_pos = {fix(1.5),fix(1.5)}, .spritec = 4, .sprites = { {.pos = {fix(17.25),fix(2.25)}, .tex = 7}, {.pos = {fix(12.25),fix(3.25)}, .tex = 4}, {.pos = {fix(15.25),fix(6.25)}, .tex = 4}, {.pos = {fix(8.25),fix(1.25)}, .tex = 4} } }, .triggers = { {.pos = {3,12}, .type = 0, .dat = {.tolvl = 2} }, {.pos = {17,2}, .type = 1, .dat = {&trigger_weapon_anvilstick} }, {} } }; uint8_t SEC_ROM map_dat2[] = { 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, 6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,6, 6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,6, 6,0,0,0,0,0,0,0,0,0,5,5,5,5,5,5,5,5,5,5,5,5,5,0,0,0,0,0,0,6, 6,0,0,0,0,6,5,6,6,6,5,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,6, 6,0,0,0,6,0,0,0,0,0,0,0,5,5,0,0,5,5,0,0,5,5,0,5,0,0,0,0,0,6, 6,0,0,0,6,0,5,6,0,6,5,0,5,5,0,0,5,5,0,0,5,5,0,5,0,0,0,0,0,6, 6,0,0,0,5,0,5,0,0,6,5,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,6, 6,0,0,0,6,0,6,0,6,6,5,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,6, 6,0,0,0,6,0,6,0,0,6,5,0,5,5,0,0,0,0,0,0,5,5,0,5,0,0,0,0,0,6, 6,0,0,0,6,0,6,6,0,6,5,0,5,5,0,0,0,0,0,0,5,5,0,5,0,0,0,0,0,6, 6,0,0,0,5,0,6,0,0,6,5,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,6, 6,0,0,0,6,0,5,0,6,6,5,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,6, 6,0,0,0,6,0,6,0,0,6,5,0,5,5,0,0,5,5,0,0,5,5,0,5,0,0,0,0,0,6, 6,0,0,0,6,0,6,6,0,6,5,0,5,5,0,0,5,5,0,0,5,5,0,5,0,0,0,0,0,6, 6,6,5,6,6,0,5,0,0,6,5,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,6, 6,0,0,0,5,0,6,0,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,0,0,0,0,0,0,6, 6,0,0,0,5,0,0,0,6,6,0,0,0,0,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,6, 6,0,0,0,0,0,5,0,6,6,0,0,0,0,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,6, 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, }; CCMap SEC_ROM map2 = { ._bmap = { .w = 30, .h = 20, .dat = map_dat2, .start_pos = {fix(18.5),fix(1.5)}, .spritec = 0, .sprites = { } }, .triggers = { {}, {}, {} } }; #define MAPC 3 CCMap *maps[MAPC] = { &map0, &map1, &map2 }; void switch_map(CCGame *game, int map){ clear_sprites(); RcMap *nmap = (RcMap*)maps[map]; game->_bgame.current_map = nmap; game->curr_map = map; cc_load_msprites(nmap->sprites, nmap->spritec); game->_bgame.player.pos = nmap->start_pos; game->_bgame.player.hp = 100; } int map_triggers_agent(RcGame *game){ CCMap *map = (CCMap*)game->current_map; for(int i = 0; i < LTRIGGER_C; i++){ LevelTrigger *trig = &map->triggers[i]; if(trig->pos.x == ffloor(game->player.pos.x) && trig->pos.y == ffloor(game->player.pos.y)){ if(!trig->type) switch_map((CCGame*)game, trig->dat.tolvl); else if(trig->dat.func(game)) game->flags.exit = 1; } } return 0; } void init_map(CCGame *game){ switch_map(game, 0); add_logic_hook((RcLogicFunc*)&map_triggers_agent); };