fix vitesse import animation

This commit is contained in:
CoCo_Sol 2023-11-04 17:39:35 +01:00
parent cdacf75e96
commit 5f350bbc0f
15 changed files with 30 additions and 12 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View file

@ -10,12 +10,13 @@ from engine.ecs import World
from engine.math import Vec2 from engine.math import Vec2
from plugins import assets, smooth from plugins import assets, smooth
from plugins import render from plugins import render
from plugins import timing
from plugins.animation import Animation from plugins.animation import Animation
from plugins.inputs import Held, Pressed from plugins.inputs import Held, Pressed
from plugins.render import Sprite from plugins.render import Sprite
from plugins.assets import Assets from plugins.assets import Assets
from plugins.coroutine import wait, Coroutine from plugins.coroutine import wait, Coroutine
from plugins.timing import TimedEvent from plugins.timing import Delta, TimedEvent
class Velocity(int): class Velocity(int):
@ -96,7 +97,7 @@ def __initialize_world(world: World):
origin=Vec2(0.5), origin=Vec2(0.5),
), ),
smooth.Target(world[ShieldPos]), smooth.Target(world[ShieldPos]),
Velocity(6), Velocity(500 * world[Delta]),
) )
@ -108,6 +109,7 @@ def __move(world: World):
s_pos = world[ShieldPos] s_pos = world[ShieldPos]
for entity in world.query(Sprite, Velocity): for entity in world.query(Sprite, Velocity):
for key in held: for key in held:
print(entity[Velocity])
if key in ("up", "z"): if key in ("up", "z"):
if s_pos.y - 45.5 - entity[Velocity] > world[FightBox].p1[1]: if s_pos.y - 45.5 - entity[Velocity] > world[FightBox].p1[1]:
s_pos.y -= entity[Velocity] s_pos.y -= entity[Velocity]
@ -145,11 +147,25 @@ def __check_hurt(world: World):
shield_position = shield.get(Sprite).position shield_position = shield.get(Sprite).position
shield_width, shield_height = shield.get(Sprite).texture.get_size() shield_width, shield_height = shield.get(Sprite).texture.get_size()
is_collision = not ( left1, top1, right1, bottom1 = (
shield_position.y < position.y position.x,
or shield_position.y + shield_height > position.y + height position.y,
or shield_position.x < position.x position.x + width,
or shield_position.x + shield_width > position.x + width position.y + height,
)
left2, top2, right2, bottom2 = (
shield_position.x - shield_width / 2,
shield_position.y - shield_height / 2,
shield_position.x + shield_width / 2,
shield_position.y + shield_height / 2,
)
is_collision = (
left1 < right2
and right1 > left2
and top1 < bottom2
and bottom1 > top2
) )
if is_collision: if is_collision:
world.set(Life(world.get(Life) - entity.get(Hurt).damage)) world.set(Life(world.get(Life) - entity.get(Hurt).damage))
@ -173,7 +189,7 @@ def __create_zone_attack(world: World):
""" """
double = random.randint(1, 10) double = random.randint(1, 10)
locate = random.randint(0, 2) locate = random.randint(0, 2)
if double == 10: if double != 10:
animation = Animation("zone_attack", 60) animation = Animation("zone_attack", 60)
entity = world.new_entity() entity = world.new_entity()
entity.set( entity.set(
@ -187,18 +203,19 @@ def __create_zone_attack(world: World):
) )
yield animation.wait() yield animation.wait()
entity.destroy() entity.destroy()
for i in range(8): for i in range(10):
projectiles = world.new_entity() projectiles = world.new_entity()
projectiles.set( projectiles.set(
Sprite( Sprite(
world[Assets].get_texture("error"), world[Assets].get_texture("projectile"),
Vec2( Vec2(
i * 41 + world[FightBox].p1[0] + (locate * 413), i * 41 + world[FightBox].p1[0] + (locate * 413),
world[FightBox].p1[1], world[FightBox].p1[1],
), ),
2, 2,
), ),
Animation("projectiles", 60, True),
ZoneAttackProjectiles(), ZoneAttackProjectiles(),
Hurt(10), Hurt(10),
TimedEvent(0.4, lambda world, entity: entity.destroy()), TimedEvent(0.4, lambda world, entity: entity.destroy()),
@ -229,18 +246,19 @@ def __create_zone_attack(world: World):
for entity in world.query(ZoneAttack): for entity in world.query(ZoneAttack):
entity.destroy() entity.destroy()
for _z in range(2): for _z in range(2):
for i in range(8): for i in range(10):
projectiles = world.new_entity() projectiles = world.new_entity()
projectiles.set( projectiles.set(
Sprite( Sprite(
world[Assets].get_texture("error"), world[Assets].get_texture("projectile"),
Vec2( Vec2(
i * 41 + world[FightBox].p1[0] + (locate * 413), i * 41 + world[FightBox].p1[0] + (locate * 413),
world[FightBox].p1[1], world[FightBox].p1[1],
), ),
2, 2,
), ),
Animation("projectiles", 60, True),
ZoneAttackProjectiles(), ZoneAttackProjectiles(),
Hurt(10), Hurt(10),
TimedEvent(0.4, lambda world, entity: entity.destroy()), TimedEvent(0.4, lambda world, entity: entity.destroy()),