Spaces:
Sleeping
Sleeping
File size: 1,294 Bytes
e53fda1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
from copy import copy
from classes.Dashboard import Dashboard
from classes.Maths import Vec2D
class Item(Dashboard):
def __init__(self, collection, screen, x, y):
super(Item, self).__init__("game/supermario/img/font.png", 8, screen)
self.ItemPos = Vec2D(x, y)
self.itemVel = Vec2D(0, 0)
self.screen = screen
self.coin_animation = copy(collection.get("coin-item").animation)
self.sound_played = False
def spawnCoin(self, cam, sound, dashboard):
if not self.sound_played:
self.sound_played = True
dashboard.points += 100
self.coin_animation.update()
if self.coin_animation.timer < 45:
if self.coin_animation.timer < 15:
self.itemVel.y -= 0.5
self.ItemPos.y += self.itemVel.y
elif self.coin_animation.timer < 45:
self.itemVel.y += 0.5
self.ItemPos.y += self.itemVel.y
self.screen.blit(
self.coin_animation.image, (self.ItemPos.x + cam.x, self.ItemPos.y)
)
elif self.coin_animation.timer < 80:
self.itemVel.y = -0.75
self.ItemPos.y += self.itemVel.y
self.drawText("100", self.ItemPos.x + 3 + cam.x, self.ItemPos.y, 8)
|