Reload entire level including the player's position
parent
79b7675182
commit
7fccbcb5b7
|
@ -31,9 +31,9 @@
|
|||
inkscape:bbox-nodes="true"
|
||||
inkscape:snap-bbox-midpoints="true"
|
||||
inkscape:snap-bbox-edge-midpoints="true"
|
||||
inkscape:zoom="2.8284271"
|
||||
inkscape:cx="283.54425"
|
||||
inkscape:cy="371.82329"
|
||||
inkscape:zoom="0.99999999"
|
||||
inkscape:cx="717.86163"
|
||||
inkscape:cy="392.49228"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="18"
|
||||
inkscape:window-maximized="0"
|
||||
|
@ -199,7 +199,7 @@
|
|||
style="fill:#00ff00;stroke-width:1"
|
||||
height="26.414213"
|
||||
width="27.01903"
|
||||
y="117.27399"
|
||||
x="160.26198"
|
||||
y="134.27399"
|
||||
x="722.26196"
|
||||
inkscape:label="#rect4-6-3" />
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
|
@ -1,4 +1,4 @@
|
|||
160.26198 117.27399
|
||||
722.26196 134.27399
|
||||
18
|
||||
0.000000 250.000000 50.000000 50.000000
|
||||
300 200 50 25
|
||||
|
|
19
src/game.c
19
src/game.c
|
@ -42,19 +42,9 @@ game_t *create_game(const char *level_file_path)
|
|||
RETURN_LT(lt, NULL);
|
||||
}
|
||||
|
||||
player_t *const player = PUSH_LT(lt, create_player(100.0f, 0.0f), destroy_player);
|
||||
if (player == NULL) {
|
||||
RETURN_LT(lt, NULL);
|
||||
}
|
||||
|
||||
platforms_t *const platforms = PUSH_LT(lt, load_platforms_from_file(level_file_path), destroy_platforms);
|
||||
if (platforms == NULL) {
|
||||
RETURN_LT(lt, NULL);
|
||||
}
|
||||
|
||||
game->level = PUSH_LT(
|
||||
lt,
|
||||
create_level(RELEASE_LT(lt, player), RELEASE_LT(lt, platforms)),
|
||||
create_level_from_file(level_file_path),
|
||||
destroy_level);
|
||||
if (game->level == NULL) {
|
||||
RETURN_LT(lt, NULL);
|
||||
|
@ -170,7 +160,12 @@ static int game_event_running(game_t *game, const SDL_Event *event)
|
|||
case SDLK_q:
|
||||
printf("Reloading the level from '%s'...\n", game->level_file_path);
|
||||
|
||||
if (level_reload_platforms(game->level, game->level_file_path) < 0) {
|
||||
game->level = RESET_LT(
|
||||
game->lt,
|
||||
game->level,
|
||||
create_level_from_file(game->level_file_path));
|
||||
|
||||
if (game->level == NULL) {
|
||||
print_current_error_msg("Could not reload the level");
|
||||
game->state = GAME_STATE_QUIT;
|
||||
return -1;
|
||||
|
|
|
@ -70,6 +70,10 @@ level_t *create_level_from_file(const char *file_name)
|
|||
RETURN_LT(lt, NULL);
|
||||
}
|
||||
|
||||
level->lt = lt;
|
||||
|
||||
fclose(RELEASE_LT(lt, level_file));
|
||||
|
||||
return level;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue