Feat(Checkpoints) - Add reset_level method to CheckpointDB for resetting checkpoints; implement profiling functionality with cProfile and output to file.

This commit is contained in:
2025-04-09 17:29:35 +02:00
committed by Félix MARQUET
parent ff3ed61a64
commit bca7cc0cbc
5 changed files with 35 additions and 1 deletions

3
.gitignore vendored
View File

@@ -12,4 +12,5 @@ checkpoint.db-journal
game.db
map/infinite/*
temp_audio.mp3
temp_audio.mp3
output.prof

9
profiler.py Normal file
View File

@@ -0,0 +1,9 @@
import cProfile
from src.handler import handler
def main():
handler()
cProfile.run("main()", "output.prof")

View File

@@ -81,3 +81,18 @@ class CheckpointDB:
self.conn.commit()
except Exception as e:
print(f"Error clearing checkpoint database: {e}")
def reset_level(self, map_name):
"""
Reset the checkpoint for a specific map
Args:
map_name: Map name to reset
"""
try:
self.cursor.execute(
"DELETE FROM checkpoints WHERE map_name = ?", (map_name,)
)
self.conn.commit()
except Exception as e:
print(f"Error resetting checkpoint for {map_name}: {e}")

View File

@@ -16,6 +16,12 @@ class GameResources:
self.life_icon_width = 50
self.fullscreen = False
try:
icon = pygame.image.load("assets/player/Sanic Head.png")
pygame.display.set_icon(icon)
except Exception as e:
print(f"Erreur lors du chargement de l'icône: {e}")
# Ressources
self.platforms = pygame.sprite.Group()
self.all_sprites = pygame.sprite.Group()

View File

@@ -27,6 +27,9 @@ def initialize_game(game_resources, map_file="map/levels/1.json"):
Returns:
tuple: (player, platform, platforms_group, all_sprites, background, checkpoints, exits)
"""
checkpointDB = CheckpointDB()
checkpointDB.reset_level(map_file)
checkpointDB.close()
parser = MapParser(game_resources)
map_objects = parser.load_map(map_file)