Ajout d'une mechanique de dossier bloqués, et de nouvelles animations #52

Merged
tipragot merged 12 commits from blocked-diractories into main 2023-10-30 21:16:03 +00:00
Showing only changes of commit 62eec44759 - Show all commits

View file

@ -241,29 +241,54 @@ def __attacks(world: World):
del entity[Order]
del entity[Centered]
del entity[Texture]
elif timer >= world[AttackSpeed] + 4.5 and world[State] == State.SEARCHING:
world[State] = State.MOVING
for _ in range(10):
position = AttackPoint(
random.randint(0, COLUMNS - 1),
random.randint(0, LINES - 1),
)
world.create_entity(
position,
Position(position.screen_position()),
Order(50),
Centered(),
Texture("attack_point.png"),
)
# on suprime les dossiers bloqués
for entity in world.query(BlockedDirectory):
del entity[BlockedDirectory]
entity[Texture] = Texture("directory.png")
# On definit les directories comme bloques
for _ in range(3):
position = Vec2(
random.randint(0, COLUMNS - 1),
random.randint(0, LINES - 1),
)
for entity in world.query(DirectoryPosition):
if entity[DirectoryPosition] == position and UserDirectory not in entity:
x = random.randint(0, COLUMNS - 1)
y = random.randint(0, LINES - 1)
position = DirectoryPosition(x, y)
for entity in world.query(
DirectoryPosition, Texture, without=[UserDirectory]
):
if (
entity[DirectoryPosition].screen_position()
== position.screen_position()
):
entity[BlockedDirectory] = BlockedDirectory()
entity[Texture] = Texture("blocked_directory.png")
for _ in range(10):
x = random.randint(0, COLUMNS - 1)
y = random.randint(0, LINES - 1)
position = AttackPoint(x, y)
# On verifie que l'entité n'est pas bloquée
is_on_blocked_directory = False
for entity in world.query(BlockedDirectory, DirectoryPosition):
if (
entity[DirectoryPosition].screen_position()
== position.screen_position()
):
is_on_blocked_directory = True
break
if not is_on_blocked_directory:
world.create_entity(
position,
Position(position.screen_position()),
Order(50),
Centered(),
Texture("attack_point.png"),
)
world[AttackTimer] = AttackTimer(0.0)
world[AttackSpeed] = AttackSpeed(world[AttackSpeed] * 0.9)
@ -297,6 +322,11 @@ def __move_directories(world: World):
del world[SelectedDirectory]
return
# On annule si le dossier selectionne est bloqué
if BlockedDirectory in selected_entity:
del world[SelectedDirectory]
return
# On calcule le déplacement de la souris
mouse_delta = mouse.position - selected_directory.position
@ -333,11 +363,14 @@ def __move_directories(world: World):
# On trouve l'autre dossier
for entity in world.query(DirectoryPosition, without=(Animation,)):
if entity != selected_entity and entity[
DirectoryPosition
] == DirectoryPosition(
directory_position.x + movement[0],
directory_position.y + movement[1],
if (
entity != selected_entity
and entity[DirectoryPosition]
== DirectoryPosition(
directory_position.x + movement[0],
directory_position.y + movement[1],
)
and BlockedDirectory not in entity
):
other_directory = entity
break