2024-04-26 09:16:45 -04:00
|
|
|
import sys
|
|
|
|
|
2024-04-26 09:09:32 -04:00
|
|
|
import arcade
|
|
|
|
|
2024-04-29 13:45:50 -04:00
|
|
|
LEFT_OFFSET = 8
|
|
|
|
|
2024-04-26 09:09:32 -04:00
|
|
|
class Score(arcade.Sprite):
|
|
|
|
def __init__(self, SCREEN_SCALE, DEBUG):
|
|
|
|
super().__init__()
|
|
|
|
|
|
|
|
self.center_x = 0 * SCREEN_SCALE
|
|
|
|
self.center_y = 256 * SCREEN_SCALE
|
|
|
|
self.scScale = SCREEN_SCALE
|
|
|
|
self.deBuggin = DEBUG
|
|
|
|
self.value = 0
|
2024-04-29 13:45:50 -04:00
|
|
|
self.sprites = []
|
2024-04-26 09:09:32 -04:00
|
|
|
|
|
|
|
def setValue(self, newValue):
|
|
|
|
self.value = newValue
|
|
|
|
|
|
|
|
def getValue(self):
|
|
|
|
return self.value
|
|
|
|
|
2024-04-29 13:45:50 -04:00
|
|
|
def drawEach(self):
|
|
|
|
for sprite in self.sprites:
|
|
|
|
sprite.draw(pixelated=True)
|
|
|
|
|
|
|
|
def update(self, score):
|
|
|
|
self.sprites.clear()
|
|
|
|
|
|
|
|
self.sprites.append(arcade.Sprite("assets/Sprites/Numbers/0.png", self.scScale))
|
|
|
|
|
|
|
|
self.value = score
|
|
|
|
|
2024-04-26 09:16:45 -04:00
|
|
|
valArr = []
|
|
|
|
for value in str(self.value):
|
|
|
|
valArr.append(value)
|
2024-04-29 13:45:50 -04:00
|
|
|
|
|
|
|
if self.deBuggin:
|
|
|
|
print(valArr)
|
|
|
|
# sys.exit()
|
|
|
|
|
|
|
|
for index, val in enumerate(valArr):
|
|
|
|
if val == "0":
|
|
|
|
addSprite = arcade.Sprite("assets/Sprites/Numbers/0.png", self.scScale)
|
|
|
|
addSprite.center_y = self.scScale * 250
|
|
|
|
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
|
|
|
self.sprites.append(addSprite)
|
|
|
|
if self.deBuggin:
|
|
|
|
print(addSprite.center_x)
|
|
|
|
elif val == "1":
|
|
|
|
addSprite = arcade.Sprite("assets/Sprites/Numbers/1.png", self.scScale)
|
|
|
|
addSprite.center_y = self.scScale * 250
|
|
|
|
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
|
|
|
self.sprites.append(addSprite)
|
|
|
|
if self.deBuggin:
|
|
|
|
print(addSprite.center_x)
|
|
|
|
elif val == "2":
|
|
|
|
addSprite = arcade.Sprite("assets/Sprites/Numbers/2.png", self.scScale)
|
|
|
|
addSprite.center_y = self.scScale * 250
|
|
|
|
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
|
|
|
self.sprites.append(addSprite)
|
|
|
|
if self.deBuggin:
|
|
|
|
print(addSprite.center_x)
|
|
|
|
elif val == "3":
|
|
|
|
addSprite = arcade.Sprite("assets/Sprites/Numbers/3.png", self.scScale)
|
|
|
|
addSprite.center_y = self.scScale * 250
|
|
|
|
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
|
|
|
self.sprites.append(addSprite)
|
|
|
|
if self.deBuggin:
|
|
|
|
print(addSprite.center_x)
|
|
|
|
elif val == "4":
|
|
|
|
addSprite = arcade.Sprite("assets/Sprites/Numbers/4.png", self.scScale)
|
|
|
|
addSprite.center_y = self.scScale * 250
|
|
|
|
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
|
|
|
self.sprites.append(addSprite)
|
|
|
|
if self.deBuggin:
|
|
|
|
print(addSprite.center_x)
|
|
|
|
elif val == "5":
|
|
|
|
addSprite = arcade.Sprite("assets/Sprites/Numbers/5.png", self.scScale)
|
|
|
|
addSprite.center_y = self.scScale * 250
|
|
|
|
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
|
|
|
self.sprites.append(addSprite)
|
|
|
|
if self.deBuggin:
|
|
|
|
print(addSprite.center_x)
|
|
|
|
elif val == "6":
|
|
|
|
addSprite = arcade.Sprite("assets/Sprites/Numbers/6.png", self.scScale)
|
|
|
|
addSprite.center_y = self.scScale * 250
|
|
|
|
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
|
|
|
self.sprites.append(addSprite)
|
|
|
|
if self.deBuggin:
|
|
|
|
print(addSprite.center_x)
|
|
|
|
elif val == "7":
|
|
|
|
addSprite = arcade.Sprite("assets/Sprites/Numbers/7.png", self.scScale)
|
|
|
|
addSprite.center_y = self.scScale * 250
|
|
|
|
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
|
|
|
self.sprites.append(addSprite)
|
|
|
|
if self.deBuggin:
|
|
|
|
print(addSprite.center_x)
|
|
|
|
elif val == "8":
|
|
|
|
addSprite = arcade.Sprite("assets/Sprites/Numbers/8.png", self.scScale)
|
|
|
|
addSprite.center_y = self.scScale * 250
|
|
|
|
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
|
|
|
self.sprites.append(addSprite)
|
|
|
|
if self.deBuggin:
|
|
|
|
print(addSprite.center_x)
|
|
|
|
elif val == "9":
|
|
|
|
addSprite = arcade.Sprite("assets/Sprites/Numbers/9.png", self.scScale)
|
|
|
|
addSprite.center_y = self.scScale * 250
|
|
|
|
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
|
|
|
self.sprites.append(addSprite)
|
|
|
|
if self.deBuggin:
|
|
|
|
print(addSprite.center_x)
|