mirror of
https://github.com/BreizhHardware/project_sanic.git
synced 2026-03-18 21:50:33 +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:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -13,3 +13,4 @@ game.db
|
|||||||
map/infinite/*
|
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()
|
self.conn.commit()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error clearing checkpoint database: {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.life_icon_width = 50
|
||||||
self.fullscreen = False
|
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
|
# Ressources
|
||||||
self.platforms = pygame.sprite.Group()
|
self.platforms = pygame.sprite.Group()
|
||||||
self.all_sprites = 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:
|
Returns:
|
||||||
tuple: (player, platform, platforms_group, all_sprites, background, checkpoints, exits)
|
tuple: (player, platform, platforms_group, all_sprites, background, checkpoints, exits)
|
||||||
"""
|
"""
|
||||||
|
checkpointDB = CheckpointDB()
|
||||||
|
checkpointDB.reset_level(map_file)
|
||||||
|
checkpointDB.close()
|
||||||
parser = MapParser(game_resources)
|
parser = MapParser(game_resources)
|
||||||
map_objects = parser.load_map(map_file)
|
map_objects = parser.load_map(map_file)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user