Gameplay de la recherche dans les dossiers #44

Merged
CoCo_Sol merged 32 commits from directory-search into main 2023-10-30 00:49:00 +00:00
Showing only changes of commit 1ede4a971d - Show all commits

View file

@ -106,6 +106,30 @@ class UserDirectory:
"""
class GameStarted:
"""
Une ressource qui permet de savoir que le jeu commence.
"""
def __change_folders_speeds(world: World, _e: Entity):
"""
Change les vitesses des dossiers.
"""
for entity in world.query(DirectoryPosition, smooth.Speed):
entity[smooth.Speed] = smooth.Speed(random.uniform(2.0, 2.5))
def __remove_folders_speeds(world: World):
"""
Supprime les vitesses des dossiers.
"""
if GameStarted not in world and world[AttackTimer] >= 3.0:
for entity in world.query(DirectoryPosition, smooth.Speed):
del entity[smooth.Speed]
world[GameStarted] = GameStarted()
def __initialize_world(world: World):
"""
Initialise le monde de la scène.
@ -117,7 +141,7 @@ def __initialize_world(world: World):
world.create_entity(
Position(),
Order(0),
Animation("fade_desktop"),
Animation("fade_desktop", __change_folders_speeds),
)
names = [
@ -137,11 +161,31 @@ def __initialize_world(world: World):
"Films",
"Cinéma",
]
positions = [
Position(0, 0),
Position(0, 0),
Position(0, 0),
Position(0, 0),
Position(0, 0),
Position(0, 0),
Position(0, 0),
Position(0, 0),
Position(0, 0),
Position(0, 0),
Position(0, 0),
Position(0, 0),
Position(0, 0),
Position(0, 0),
Position(0, 0),
]
for y in range(LINES):
for x in range(COLUMNS):
position = DirectoryPosition(x, y)
entity = world.create_entity(
Position(position.screen_position()),
positions.pop(),
smooth.Speed(0),
Order(1),
Centered(),
Texture("directory.png"),
@ -211,7 +255,7 @@ def __move_directories(world: World):
Permet de déplacer les dossiers avec la souris.
"""
# Si on n'est pas dans le bon state on annule
if world[State] == State.GAME_OVER:
if GameStarted not in world or world[State] == State.GAME_OVER:
return
# On met à jour la séléction
@ -314,7 +358,7 @@ def __update_directory_names(world: World):
SCENE = (
Scene(
[__initialize_world],
[__attacks, __move_directories, __update_positions],
[__attacks, __move_directories, __update_positions, __remove_folders_speeds],
[],
)
+ smooth.PLUGIN