crash on main_loop
This commit is contained in:
parent
bd868143b8
commit
8778623b1c
|
@ -25,6 +25,7 @@ set(ASSETS_fx
|
|||
assets-fx/bgrounds.png
|
||||
assets-fx/tileset.png
|
||||
assets-fx/player.png
|
||||
assets-fx/water.png
|
||||
assets-fx/map/world.csv
|
||||
# ...
|
||||
)
|
||||
|
|
|
@ -1,16 +1,32 @@
|
|||
-1,65,66,66,67,-1,50,-1,-1,-1,0,1,1,1,1,2,30,-1,-1,-1,27,28,27,28,29,29,29,29,29,-1,-1,-1
|
||||
-1,84,85,84,84,-1,50,-1,22,23,19,30,64,-1,83,21,-1,-1,64,-1,46,47,46,47,44,-1,-1,-1,49,-1,-1,44
|
||||
29,84,84,86,85,29,29,-1,41,42,38,-1,-1,11,-1,21,-1,-1,-1,-1,84,85,84,84,-1,-1,24,-1,-1,-1,-1,-1
|
||||
-1,33,-1,11,-1,-1,-1,-1,-1,-1,57,58,58,58,-1,21,29,29,29,29,84,84,86,84,83,83,51,-1,49,-1,-1,-1
|
||||
-1,-1,-1,-1,11,-1,-1,30,-1,-1,11,-1,-1,-1,-1,40,11,-1,64,-1,-1,-1,44,-1,29,29,29,29,29,-1,-1,-1
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,58,58,58,59,-1,-1,-1,-1,-1,-1,44,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||
-1,-1,13,-1,-1,-1,-1,13,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,-1,44,-1,-1
|
||||
-1,-1,-1,-1,-1,-1,64,-1,-1,-1,-1,-1,-1,15,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1
|
||||
-1,-1,26,-1,64,-1,-1,-1,-1,-1,26,24,-1,-1,-1,-1,34,35,36,-1,-1,-1,-1,18,-1,-1,18,-1,-1,-1,-1,-1
|
||||
-1,-1,-1,-1,-1,-1,64,-1,-1,-1,-1,-1,-1,-1,0,1,53,54,55,2,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,-1
|
||||
-1,-1,-1,64,30,-1,-1,0,1,1,1,1,1,1,19,33,-1,-1,44,21,2,18,-1,44,-1,-1,-1,-1,-1,-1,-1,-1
|
||||
-1,-1,-1,-1,-1,-1,-1,19,22,23,52,-1,52,62,38,-1,-1,-1,44,40,21,-1,-1,-1,-1,11,-1,-1,-1,-1,-1,-1
|
||||
-1,15,-1,-1,-1,-1,15,19,41,42,-1,-1,-1,-1,57,58,58,58,20,59,21,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1
|
||||
-1,-1,-1,-1,-1,-1,-1,38,-1,-1,49,-1,-1,-1,-1,-1,-1,-1,-1,52,21,-1,-1,44,-1,-1,-1,-1,-1,-1,-1,-1
|
||||
-1,-1,15,-1,-1,-1,-1,57,58,58,58,58,20,58,58,58,58,58,58,58,59,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||
56,56,56,56,56,56,-1,-1,83,-1,34,35,35,36,-1,-1,50,-1,-1,-1,-1,-1,45,-1,-1,-1,-1,56,56,56,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2
|
||||
56,56,56,56,56,49,49,49,-1,-1,53,54,53,53,-1,-1,50,-1,45,-1,-1,-1,-1,-1,-1,-1,-1,56,56,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,19,45,-1,19,-1,-1,-1,45,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,21
|
||||
56,56,56,56,-1,-1,83,-1,-1,52,53,55,54,53,52,50,-1,-1,-1,-1,45,-1,-1,-1,-1,-1,56,56,56,-1,-1,-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-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||
|
|
|
Before Width: | Height: | Size: 254 B After Width: | Height: | Size: 254 B |
|
@ -4,6 +4,12 @@
|
|||
|
||||
#include "core.h"
|
||||
|
||||
void next_frame(struct game *game)
|
||||
{
|
||||
game->water_frame = (game->water_frame + 1) % 2;
|
||||
}
|
||||
|
||||
|
||||
void analyze_input(struct game *game, const int last_key)
|
||||
{
|
||||
game->total_tick += ENGINE_TICK;
|
||||
|
@ -31,24 +37,6 @@ void analyze_input(struct game *game, const int last_key)
|
|||
}
|
||||
}
|
||||
|
||||
int rtc_key(void)
|
||||
{
|
||||
int opt = GETKEY_DEFAULT & ~GETKEY_MOD_SHIFT & ~GETKEY_MOD_ALPHA & ~GETKEY_REP_ARROWS;
|
||||
int timeout = 1;
|
||||
|
||||
key_event_t ev = getkey_opt(opt, &timeout);
|
||||
if (ev.type == KEYEV_NONE) return 0;
|
||||
|
||||
return ev.key;
|
||||
}
|
||||
|
||||
|
||||
int callback_tick(volatile int *tick)
|
||||
{
|
||||
*tick = 1;
|
||||
return TIMER_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
int is_walkable(const struct game game, const int direction)
|
||||
{
|
||||
|
@ -71,5 +59,23 @@ int is_walkable(const struct game game, const int direction)
|
|||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int rtc_key(void)
|
||||
{
|
||||
int opt = GETKEY_DEFAULT & ~GETKEY_MOD_SHIFT & ~GETKEY_MOD_ALPHA & ~GETKEY_REP_ARROWS;
|
||||
int timeout = 1;
|
||||
|
||||
key_event_t ev = getkey_opt(opt, &timeout);
|
||||
if (ev.type == KEYEV_NONE) return 0;
|
||||
|
||||
return ev.key;
|
||||
}
|
||||
|
||||
|
||||
int callback_tick(volatile int *tick)
|
||||
{
|
||||
*tick = 1;
|
||||
return TIMER_CONTINUE;
|
||||
}
|
||||
|
|
|
@ -3,13 +3,12 @@
|
|||
|
||||
|
||||
#define ENGINE_TICK 100
|
||||
#define PARTICULE_NB 50
|
||||
|
||||
#define TILESET_WIDTH 19
|
||||
#define TILE_SIZE 8
|
||||
|
||||
#define MAP_WIDTH 32
|
||||
#define MAP_HEIGHT 16
|
||||
#define MAP_WIDTH 64
|
||||
#define MAP_HEIGHT 32
|
||||
#define SCREEN_WIDTH 16
|
||||
#define SCREEN_HEIGHT 8
|
||||
|
||||
|
@ -40,17 +39,23 @@ struct game
|
|||
struct player player;
|
||||
|
||||
int total_tick;
|
||||
int water_frame;
|
||||
};
|
||||
|
||||
// next_frame : compute the next frame to display
|
||||
void next_frame(struct game *game);
|
||||
|
||||
// analyze_input : change the player's position
|
||||
void analyze_input(struct game *game, const int last_key);
|
||||
|
||||
// is_walkable : check if the player can go on the targeted case
|
||||
int is_walkable(const struct game game, const int direction);
|
||||
|
||||
// rtc_key : returns the key code with RTC system
|
||||
int rtc_key(void);
|
||||
|
||||
// callback_tick : timer's function
|
||||
int callback_tick(volatile int *tick);
|
||||
|
||||
int is_walkable(const struct game game, const int direction);
|
||||
|
||||
#endif /* _CORE_H */
|
|
@ -7,6 +7,7 @@
|
|||
void draw_map(const struct game game)
|
||||
{
|
||||
extern const bopti_image_t img_tileset;
|
||||
extern const bopti_image_t img_water;
|
||||
|
||||
for (int i = 0; i < SCREEN_HEIGHT; i ++)
|
||||
{
|
||||
|
@ -15,7 +16,9 @@ void draw_map(const struct game game)
|
|||
if (game.map.data[game.world_y + i][game.world_x + j] != -1 && game.world_y + i < (MAP_HEIGHT) && game.world_y + i >= 0 && game.world_x + j < (MAP_WIDTH) && game.world_x + j >= 0)
|
||||
{
|
||||
int tile_x = (TILE_SIZE + 1) * (game.map.data[game.world_y + i][game.world_x + j] % TILESET_WIDTH), tile_y = (TILE_SIZE + 1) * (game.map.data[game.world_y + i][game.world_x + j] / TILESET_WIDTH);
|
||||
dsubimage(j * TILE_SIZE, i * TILE_SIZE, &img_tileset, tile_x, tile_y, 8, 8, DIMAGE_NONE);
|
||||
if (game.map.data[game.world_y + i][game.world_x + j] != 56) dsubimage(j * TILE_SIZE, i * TILE_SIZE, &img_tileset, tile_x, tile_y, 8, 8, DIMAGE_NONE);
|
||||
else dsubimage(j * TILE_SIZE, i * TILE_SIZE, &img_water, 9 * game.water_frame, 0, 8, 8, DIMAGE_NONE);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ int main(void)
|
|||
dfont(&font_odyssee);
|
||||
|
||||
dgray(DGRAY_ON);
|
||||
title_screen();
|
||||
|
||||
title_screen();
|
||||
main_loop();
|
||||
|
||||
dgray(DGRAY_OFF);
|
||||
|
@ -43,46 +43,12 @@ int main(void)
|
|||
void title_screen(void)
|
||||
{
|
||||
extern const bopti_image_t img_title;
|
||||
int key = 0;
|
||||
|
||||
// Initialise particule effect
|
||||
srand(1551001551);
|
||||
int coord_x[PARTICULE_NB];
|
||||
int coord_y[PARTICULE_NB];
|
||||
for (int i = 0; i < PARTICULE_NB; i ++)
|
||||
{
|
||||
coord_x[i] = rand() % 128;
|
||||
coord_y[i] = rand() % 64;
|
||||
}
|
||||
|
||||
static volatile int tick = 0;
|
||||
int t = timer_configure(TIMER_ANY, ENGINE_TICK*1000, GINT_CALL(callback_tick, &tick));
|
||||
if (t >= 0) timer_start(t);
|
||||
|
||||
while (!key)
|
||||
{
|
||||
while (!tick) sleep();
|
||||
tick = 0;
|
||||
|
||||
dclear(C_WHITE);
|
||||
dimage(0, 0, &img_title);
|
||||
|
||||
// Update particules positions
|
||||
for (int i = 0; i < PARTICULE_NB; i ++)
|
||||
{
|
||||
dpixel(coord_x[i], coord_y[i], C_BLACK);
|
||||
coord_x[i] += (rand() % 3) - 1;
|
||||
coord_y[i] += (rand() % 3) - 1;
|
||||
|
||||
if (coord_x[i] < 0 || coord_x[i] > 128) coord_x[i] = rand() % 128;
|
||||
if (coord_y[i] < 0 || coord_y[i] > 64) coord_y[i] = rand() % 64;
|
||||
}
|
||||
|
||||
dupdate();
|
||||
key = rtc_key();
|
||||
}
|
||||
|
||||
if (t >= 0) timer_stop(t);
|
||||
dclear(C_WHITE);
|
||||
dimage(0, 0, &img_title);
|
||||
dupdate();
|
||||
|
||||
getkey();
|
||||
}
|
||||
|
||||
|
||||
|
@ -92,18 +58,28 @@ void main_loop(void)
|
|||
int key = 0;
|
||||
|
||||
struct player player = {DOWN};
|
||||
struct game game = {map_world, 0, 0, player, 0};
|
||||
struct game game = {map_world, 0, 0, player, 0, 0};
|
||||
|
||||
static volatile int tick = 0;
|
||||
int t = timer_configure(TIMER_ANY, ENGINE_TICK*1000, GINT_CALL(callback_tick, &tick));
|
||||
if (t >= 0) timer_start(t);
|
||||
|
||||
while (key != KEY_EXIT)
|
||||
{
|
||||
while (!tick) sleep();
|
||||
tick = 0;
|
||||
|
||||
|
||||
dclear(C_WHITE);
|
||||
|
||||
next_frame(&game);
|
||||
draw_map(game);
|
||||
draw_player(game);
|
||||
|
||||
dupdate();
|
||||
|
||||
key = getkey().key;
|
||||
key = rtc_key();
|
||||
analyze_input(&game, key);
|
||||
}
|
||||
if (t >= 0) timer_stop(t);
|
||||
}
|
Loading…
Reference in New Issue