2024-04-26 09:16:45 -04:00
|
|
|
import sys
|
|
|
|
|
2024-04-26 09:09:32 -04:00
|
|
|
import arcade
|
|
|
|
|
2024-04-29 15:49:21 -04:00
|
|
|
LEFT_OFFSET = 16
|
2024-04-29 13:45:50 -04:00
|
|
|
|
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()
|
|
|
|
|
2024-04-29 15:49:21 -04:00
|
|
|
s = arcade.Sprite("assets/Sprites/Letters/s.png", self.scScale)
|
|
|
|
c = arcade.Sprite("assets/Sprites/Letters/c.png", self.scScale)
|
|
|
|
o = arcade.Sprite("assets/Sprites/Letters/o.png", self.scScale)
|
|
|
|
r = arcade.Sprite("assets/Sprites/Letters/r.png", self.scScale)
|
|
|
|
e = arcade.Sprite("assets/Sprites/Letters/e.png", self.scScale)
|
|
|
|
|
|
|
|
s.center_y = self.scScale * 243
|
|
|
|
c.center_y = self.scScale * 243
|
|
|
|
o.center_y = self.scScale * 243
|
|
|
|
r.center_y = self.scScale * 243
|
|
|
|
e.center_y = self.scScale * 243
|
|
|
|
|
|
|
|
s.center_x = self.scScale * 8 + LEFT_OFFSET * self.scScale
|
|
|
|
c.center_x = self.scScale * 8 * 2 + LEFT_OFFSET * self.scScale
|
|
|
|
o.center_x = self.scScale * 8 * 3 + LEFT_OFFSET * self.scScale
|
|
|
|
r.center_x = self.scScale * 8 * 4 + LEFT_OFFSET * self.scScale
|
|
|
|
e.center_x = self.scScale * 8 * 5 + LEFT_OFFSET * self.scScale
|
|
|
|
|
|
|
|
self.sprites.append(s)
|
|
|
|
self.sprites.append(c)
|
|
|
|
self.sprites.append(o)
|
|
|
|
self.sprites.append(r)
|
|
|
|
self.sprites.append(e)
|
2024-04-29 13:45:50 -04:00
|
|
|
|
|
|
|
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)
|
2024-04-29 15:49:21 -04:00
|
|
|
addSprite.center_y = self.scScale * 230
|
2024-04-29 13:45:50 -04:00
|
|
|
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)
|
2024-04-29 15:49:21 -04:00
|
|
|
addSprite.center_y = self.scScale * 230
|
2024-04-29 13:45:50 -04:00
|
|
|
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)
|
2024-04-29 15:49:21 -04:00
|
|
|
addSprite.center_y = self.scScale * 230
|
2024-04-29 13:45:50 -04:00
|
|
|
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)
|
2024-04-29 15:49:21 -04:00
|
|
|
addSprite.center_y = self.scScale * 230
|
2024-04-29 13:45:50 -04:00
|
|
|
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)
|
2024-04-29 15:49:21 -04:00
|
|
|
addSprite.center_y = self.scScale * 230
|
2024-04-29 13:45:50 -04:00
|
|
|
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)
|
2024-04-29 15:49:21 -04:00
|
|
|
addSprite.center_y = self.scScale * 230
|
2024-04-29 13:45:50 -04:00
|
|
|
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)
|
2024-04-29 15:49:21 -04:00
|
|
|
addSprite.center_y = self.scScale * 230
|
2024-04-29 13:45:50 -04:00
|
|
|
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)
|
2024-04-29 15:49:21 -04:00
|
|
|
addSprite.center_y = self.scScale * 230
|
2024-04-29 13:45:50 -04:00
|
|
|
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)
|
2024-04-29 15:49:21 -04:00
|
|
|
addSprite.center_y = self.scScale * 230
|
2024-04-29 13:45:50 -04:00
|
|
|
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)
|
2024-04-29 15:49:21 -04:00
|
|
|
addSprite.center_y = self.scScale * 230
|
2024-04-29 13:45:50 -04:00
|
|
|
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
|
|
|
self.sprites.append(addSprite)
|
|
|
|
if self.deBuggin:
|
|
|
|
print(addSprite.center_x)
|
2024-04-29 15:49:21 -04:00
|
|
|
|