Better calculs

This commit is contained in:
Tipragot 2023-10-29 16:46:22 +01:00
parent be278171cc
commit d544c5a57d

View file

@ -2,7 +2,6 @@
Un plugin permettant de faire des déplacements fluides des entités.
"""
import math
from engine import Delta, Position, Scene, Vec2, World
@ -25,9 +24,10 @@ def __update_positions(world: World):
for entity in world.query(Position, Target):
position = entity[Position]
target = entity[Target]
speed = entity[Speed] if Speed in entity else Speed(500)
blend = math.pow(0.5, world[Delta] * speed)
entity[Position] = Position(position + ((target - position) * blend))
speed = entity[Speed] if Speed in entity else Speed(5)
entity[Position] = Position(
position + (target - position) * world[Delta] * speed
)
PLUGIN = Scene(