Haiotoko/lib/animate.py
2023-07-11 02:22:21 +10:00

20 lines
522 B
Python

import time
import displayio
bounce = False
bounceAmount = 0
def doAnimate(haioGroup: displayio.Group, duration: float, newBounceAmount: int):
global bounce
global bounceAmount
if bounceAmount == 0:
bounceAmount = newBounceAmount
if(round(time.monotonic()%duration, 2) == round(duration, 2)):
if bounce == False:
bounce = True
bounceAmount = bounceAmount * -1
haioGroup.y += bounceAmount
else:
if bounce == True:
bounce = False