2023-03-25 15:41:32 +01:00
|
|
|
import pygame
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from sprite.Sprite import Sprite
|
|
|
|
from sprite.Spritesheet import Spritesheet
|
|
|
|
from sprite.StaticSprite import StaticSprite
|
|
|
|
|
|
|
|
sys.path.append('./sprite')
|
|
|
|
|
|
|
|
|
|
|
|
class DynamicSprite(StaticSprite):
|
|
|
|
def __init__(self, spritesheet: Spritesheet):
|
|
|
|
super().__init__(spritesheet)
|
|
|
|
|
|
|
|
self.motion = (0, 0)
|
|
|
|
self.deceleration_horizontal = 0
|
2023-03-25 17:18:43 +01:00
|
|
|
self.gravity = 9.81 / 10
|
2023-03-25 15:41:32 +01:00
|
|
|
|
|
|
|
def tick(self, dt: float):
|
|
|
|
super().tick(dt)
|
|
|
|
|
|
|
|
self.motion = (
|
|
|
|
self.motion[0] - self.deceleration_horizontal * dt,
|
|
|
|
self.motion[1] + self.gravity * dt
|
|
|
|
)
|