Fix delta

This commit is contained in:
Tipragot 2023-11-05 09:00:54 +01:00
parent b7e44b4192
commit acaf9475a5

View file

@ -181,7 +181,7 @@ def __initialize_world(world: World):
origin=Vec2(0.5), origin=Vec2(0.5),
), ),
smooth.Target(world[ShieldPos]), smooth.Target(world[ShieldPos]),
Velocity(500 * world[Delta]), Velocity(500),
Player(), Player(),
) )
@ -211,17 +211,29 @@ def __move(world: World):
for entity in world.query(Sprite, Velocity): for entity in world.query(Sprite, Velocity):
for key in held: for key in held:
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 -= entity[Velocity] s_pos.y - 45.5 - entity[Velocity] * world[Delta]
> world[FightBox].p1[1]
):
s_pos.y -= entity[Velocity] * world[Delta]
if key in ("down", "s"): if key in ("down", "s"):
if s_pos.y + 45.5 + entity[Velocity] < world[FightBox].p2[1]: if (
s_pos.y += entity[Velocity] s_pos.y + 45.5 + entity[Velocity] * world[Delta]
< world[FightBox].p2[1]
):
s_pos.y += entity[Velocity] * world[Delta]
if key in ("left", "q"): if key in ("left", "q"):
if s_pos.x - 37 - entity[Velocity] > world[FightBox].p1[0]: if (
s_pos.x -= entity[Velocity] s_pos.x - 37 - entity[Velocity] * world[Delta]
> world[FightBox].p1[0]
):
s_pos.x -= entity[Velocity] * world[Delta]
if key in ("right", "d"): if key in ("right", "d"):
if s_pos.x + 37 + entity[Velocity] < world[FightBox].p2[0]: if (
s_pos.x += entity[Velocity] s_pos.x + 37 + entity[Velocity] * world[Delta]
< world[FightBox].p2[0]
):
s_pos.x += entity[Velocity] * world[Delta]
entity[smooth.Target] = s_pos entity[smooth.Target] = s_pos