From 9bf9d464ce60fa458f25b09020193fa4ff1ccb13 Mon Sep 17 00:00:00 2001 From: ClementHVT Date: Fri, 4 Apr 2025 09:55:55 +0200 Subject: [PATCH] FIX [Collectibles/InfiniteMode] - Merge Conflict resolve - add generate maps to gitignore --- .gitignore | 3 ++- src/handler.py | 14 +++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 1bd261b..bae480b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ checkpoint.db checkpoint.db-journal -game.db \ No newline at end of file +game.db +map/infinite/* \ No newline at end of file diff --git a/src/handler.py b/src/handler.py index cf76816..26dc037 100644 --- a/src/handler.py +++ b/src/handler.py @@ -185,6 +185,7 @@ def handler(): background, checkpoints, exits, + collectibles ) = initialize_game(game_resources, level_file) projectiles.empty() current_state = PLAYING @@ -341,7 +342,7 @@ def handler(): and game_resources.infinite_mode ): # Mod infinit : load the next level without the menu - P1, P1T, platforms, all_sprites, background, checkpoints, exits = ( + P1, P1T, platforms, all_sprites, background, checkpoints, exits, collectibles = ( handle_exit_collision(exit, game_resources, level_file) ) else: @@ -366,6 +367,12 @@ def handler(): fps_text = font.render(f"FPS: {fps}", True, (255, 255, 255)) displaysurface.blit(fps_text, (10, 10)) + coins_hit = pygame.sprite.spritecollide(P1, collectibles, + False) # Set to False to handle removal in on_collision + for coin in coins_hit: + coin.on_collision() # This will handle the coin removal + P1.collect_coin(displaysurface) # This updates the player's coin counter + P1.draw_dash_cooldown_bar(displaysurface) pos_text = font.render( @@ -375,9 +382,10 @@ def handler(): P1.draw_dash_cooldown_bar(displaysurface) P1.draw_lives(displaysurface) + P1.draw_coins(displaysurface) elif current_state == INFINITE: - P1, P1T, platforms, all_sprites, background, checkpoints, exits = ( + P1, P1T, platforms, all_sprites, background, checkpoints, exits, collectibles = ( start_infinite_mode(game_resources) ) current_state = PLAYING @@ -397,7 +405,7 @@ def handler(): death_timer += dt if death_timer >= death_display_time: if checkpoint_data: - P1, platforms, all_sprites, background, checkpoints = ( + P1, platforms, all_sprites, background, checkpoints, collectibles = ( reset_game_with_checkpoint(level_file, game_resources) ) projectiles.empty()