diff options
author | UnavailableDev <ggwildplay@gmail.com> | 2023-04-05 20:50:07 +0200 |
---|---|---|
committer | UnavailableDev <ggwildplay@gmail.com> | 2023-04-05 20:50:07 +0200 |
commit | 0dd7be7230b3ccba9a930c01549d79d108d091c4 (patch) | |
tree | 62f42cbf597232ed1076bb539426df8ddcf2886e /src/game_loop | |
parent | 06b9a5e3c252713c211d77b5643143276db209ba (diff) | |
parent | dc5e246ff1e8d89e59acf70c149f180fb41dd584 (diff) |
Merge branch 'dev' of https://github.com/heavydemon21/avans-arcade into dev
Diffstat (limited to 'src/game_loop')
-rw-r--r-- | src/game_loop/gameplay.c | 45 | ||||
-rw-r--r-- | src/game_loop/gameplay.h | 3 | ||||
-rw-r--r-- | src/game_loop/starting_screen.c | 1 |
3 files changed, 38 insertions, 11 deletions
diff --git a/src/game_loop/gameplay.c b/src/game_loop/gameplay.c index 2950870..a7ce5b6 100644 --- a/src/game_loop/gameplay.c +++ b/src/game_loop/gameplay.c @@ -12,7 +12,7 @@ void hh_gameplay(hh_g_all_levels* game, hh_e_game_state* hh_game_state){ .speed = 6, .is_grounded = false, .is_hit = false, - .radius = 8, + .radius = 16, .pos = (vec2){32,32}, .size = (vec2){32,32}, .vel = (vec2){0,0}, @@ -29,12 +29,13 @@ void hh_gameplay(hh_g_all_levels* game, hh_e_game_state* hh_game_state){ }; // enemy gets replaced here is just for reference static hh_entity enemy={ + .object_type = jumping_slime, .hp = 4, - .speed = 6, + .speed = 2, .is_grounded = false, .is_hit = false, .radius = 8, - .pos = (vec2){128,24}, + .pos = (vec2){200,200}, .size = (vec2){16,16}, .vel = (vec2){0,0}, // .vec = (vec2){0,0}, @@ -53,19 +54,17 @@ void hh_gameplay(hh_g_all_levels* game, hh_e_game_state* hh_game_state){ switch (gameplay) { case hh_e_setup_screen: - printf("%d\n",game->current_level); bullets = hh_init_bullets(total_bullets); hh_setup_screen(game->level[game->current_level]); gameplay = hh_e_play_level; - enemy.hp=4; break; case hh_e_play_level: - // TODO: here come all the different functions for the gameplay - vec_cor cam_pos;//value in tiles + + vec_cor cam_pos; cam_pos = hh_draw_screen(player1.pos); hh_player_actions(&player1); hh_multiple_bullets(player1.pos,bullets); - hh_multiple_enemies(cam_pos, &enemy,1); + hh_multiple_enemies(&enemy, player1, cam_pos, 1); hh_check_all_collisions(&player1,&enemy,1,bullets,total_bullets,cam_pos); hh_solve_hitted_enemies(&enemy,1); hh_render_all_entities(&player1,bullets,&enemy,total_bullets,1, cam_pos); @@ -75,19 +74,24 @@ void hh_gameplay(hh_g_all_levels* game, hh_e_game_state* hh_game_state){ if(game->level[game->current_level].hh_level_completed){ gameplay = hh_e_level_complete; } + else if(player1.hp == 0){ + gameplay = hh_e_game_over; + } break; case hh_e_level_complete: + // TODO: from complete to shop or game_over if(game->current_level < 3){ game->current_level+=1; gameplay = hh_e_setup_screen; } else { + gameplay = hh_e_game_over; } break; case hh_e_game_over: // todo make reset levels - hh_reset_levels(); + hh_reset_levels(&player1); gameplay = hh_e_setup_screen; *hh_game_state = hh_e_state_game_over; break; @@ -96,7 +100,28 @@ void hh_gameplay(hh_g_all_levels* game, hh_e_game_state* hh_game_state){ } } -void hh_reset_levels(){} +void hh_reset_levels(hh_entity* player){ + *player = (hh_entity){ + .hp = 4, + .speed = 6, + .is_grounded = false, + .is_hit = false, + .radius = 16, + .pos = (vec2){32,32}, + .size = (vec2){32,32}, + .vel = (vec2){0,0}, + .render = { + .frame0 = 3, + .palette = 3, + .fam = (hh_s_ppu_loc_fam_entry){ + .horizontal_flip = false, + .vertical_flip = false, + .palette_index = 3, + .tilemap_index = 80, + } + } + }; +} void hh_render_all_entities(hh_entity* player, hh_entity* bullets, hh_entity* enemies, int bullet_size, int enemy_size, vec_cor cam_pos){ diff --git a/src/game_loop/gameplay.h b/src/game_loop/gameplay.h index 9d66c37..8adddb4 100644 --- a/src/game_loop/gameplay.h +++ b/src/game_loop/gameplay.h @@ -15,8 +15,9 @@ typedef enum { hh_e_level_complete, hh_e_game_over, }hh_e_gameplay; + /** @brief resets all the levels the first condition */ -void hh_reset_levels(); +void hh_reset_levels(hh_entity* player); /** @brief game loop function to handle the gameplay*/ void hh_gameplay(hh_g_all_levels* game, hh_e_game_state* hh_game_state); /** @brief renders all the entities*/ diff --git a/src/game_loop/starting_screen.c b/src/game_loop/starting_screen.c index c11e4fc..d9f8ea6 100644 --- a/src/game_loop/starting_screen.c +++ b/src/game_loop/starting_screen.c @@ -11,6 +11,7 @@ bool hh_show_starting_screen(){ { case hh_e_state_show: hh_clear_screen(); + hh_clear_sprite(); hh_init_title_screen(); hh_e_starting_screen = hh_e_state_input; return false; |