mirror of
https://github.com/BreizhHardware/project_sanic.git
synced 2026-01-18 16:47:25 +01:00
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:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -12,4 +12,5 @@ checkpoint.db-journal
|
||||
game.db
|
||||
map/infinite/*
|
||||
|
||||
temp_audio.mp3
|
||||
temp_audio.mp3
|
||||
output.prof
|
||||
9
profiler.py
Normal file
9
profiler.py
Normal file
@@ -0,0 +1,9 @@
|
||||
import cProfile
|
||||
from src.handler import handler
|
||||
|
||||
|
||||
def main():
|
||||
handler()
|
||||
|
||||
|
||||
cProfile.run("main()", "output.prof")
|
||||
@@ -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}")
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user