Better animations and timings

This commit is contained in:
Tipragot 2023-10-29 23:28:01 +01:00
parent e025e29896
commit 793697ad50
2 changed files with 9 additions and 6 deletions

View file

@ -1,5 +1,4 @@
{ {
"end_image": "directory.png",
"offset": { "offset": {
"x": 8, "x": 8,
"y": -83 "y": -83

View file

@ -162,8 +162,12 @@ def __attacks(world: World):
world[AttackTimer] = AttackTimer(world[AttackTimer] + world[Delta]) world[AttackTimer] = AttackTimer(world[AttackTimer] + world[Delta])
timer = world[AttackTimer] timer = world[AttackTimer]
if timer >= world[AttackSpeed] and world[State] == State.MOVING: if timer >= world[AttackSpeed] and world[State] == State.MOVING:
entities = world.query(AttackPoint)
if len(entities) > 0:
world[State] = State.SEARCHING world[State] = State.SEARCHING
for entity in world.query(AttackPoint): else:
world[State] = State.WAITING
for entity in entities:
position = entity[AttackPoint] position = entity[AttackPoint]
for directory_entity in world.query(DirectoryPosition): for directory_entity in world.query(DirectoryPosition):
if directory_entity[DirectoryPosition] == position: if directory_entity[DirectoryPosition] == position:
@ -173,9 +177,9 @@ def __attacks(world: World):
del entity[Order] del entity[Order]
del entity[Centered] del entity[Centered]
del entity[Texture] del entity[Texture]
elif timer >= world[AttackSpeed] + 4 and world[State] == State.SEARCHING: elif timer >= world[AttackSpeed] + 4.5 and world[State] == State.SEARCHING:
world[State] = State.WAITING world[State] = State.WAITING
elif timer >= world[AttackSpeed] + 5 and world[State] == State.WAITING: elif timer >= world[AttackSpeed] + 7 and world[State] == State.WAITING:
world[State] = State.MOVING world[State] = State.MOVING
for _ in range(10): for _ in range(10):
position = AttackPoint( position = AttackPoint(
@ -187,7 +191,7 @@ def __attacks(world: World):
Position(position.screen_position(State.MOVING)), Position(position.screen_position(State.MOVING)),
Order(50), Order(50),
Centered(), Centered(),
Texture("loupe.png"), Texture("attack_point.png"),
) )
world[AttackTimer] = AttackTimer(0.0) world[AttackTimer] = AttackTimer(0.0)
world[AttackSpeed] = AttackSpeed(world[AttackSpeed] * 0.9) world[AttackSpeed] = AttackSpeed(world[AttackSpeed] * 0.9)