got "score" to show on screen
This commit is contained in:
parent
20717a1ac6
commit
262df318f3
20
Main.py
20
Main.py
@ -184,15 +184,7 @@ class MyGame(arcade.Window):
|
|||||||
# except Exception as e:
|
# except Exception as e:
|
||||||
# pass
|
# pass
|
||||||
|
|
||||||
# Render player bullet if it exists
|
|
||||||
try:
|
|
||||||
self.bullet.bullet_sprite.draw(pixelated=True)
|
|
||||||
except Exception as e:
|
|
||||||
if DEBUG:
|
|
||||||
self.rend += 1
|
|
||||||
if self.rend >= 20:
|
|
||||||
print(e)
|
|
||||||
self.rend = 0
|
|
||||||
|
|
||||||
# Render alien bullets if they exist and render aliens
|
# Render alien bullets if they exist and render aliens
|
||||||
try:
|
try:
|
||||||
@ -206,7 +198,15 @@ class MyGame(arcade.Window):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# Render player bullet if it exists
|
||||||
|
try:
|
||||||
|
self.bullet.bullet_sprite.draw(pixelated=True)
|
||||||
|
except Exception as e:
|
||||||
|
if DEBUG:
|
||||||
|
self.rend += 1
|
||||||
|
if self.rend >= 20:
|
||||||
|
print(e)
|
||||||
|
self.rend = 0
|
||||||
|
|
||||||
self.player_list.draw(pixelated=True)
|
self.player_list.draw(pixelated=True)
|
||||||
self.wall_list.draw(pixelated=True)
|
self.wall_list.draw(pixelated=True)
|
||||||
|
51
Score.py
51
Score.py
@ -2,7 +2,7 @@ import sys
|
|||||||
|
|
||||||
import arcade
|
import arcade
|
||||||
|
|
||||||
LEFT_OFFSET = 8
|
LEFT_OFFSET = 16
|
||||||
|
|
||||||
class Score(arcade.Sprite):
|
class Score(arcade.Sprite):
|
||||||
def __init__(self, SCREEN_SCALE, DEBUG):
|
def __init__(self, SCREEN_SCALE, DEBUG):
|
||||||
@ -28,11 +28,29 @@ class Score(arcade.Sprite):
|
|||||||
def update(self, score):
|
def update(self, score):
|
||||||
self.sprites.clear()
|
self.sprites.clear()
|
||||||
|
|
||||||
self.sprites.append(arcade.Sprite("assets/Sprites/Letters/s.png", self.scScale)) # add x and y coords
|
s = arcade.Sprite("assets/Sprites/Letters/s.png", self.scScale)
|
||||||
self.sprites.append(arcade.Sprite("assets/Sprites/Letters/c.png", self.scScale)) # add x and y coords
|
c = arcade.Sprite("assets/Sprites/Letters/c.png", self.scScale)
|
||||||
self.sprites.append(arcade.Sprite("assets/Sprites/Letters/o.png", self.scScale)) # add x and y coords
|
o = arcade.Sprite("assets/Sprites/Letters/o.png", self.scScale)
|
||||||
self.sprites.append(arcade.Sprite("assets/Sprites/Letters/r.png", self.scScale)) # add x and y coords
|
r = arcade.Sprite("assets/Sprites/Letters/r.png", self.scScale)
|
||||||
self.sprites.append(arcade.Sprite("assets/Sprites/Letters/e.png", self.scScale)) # add x and y coords
|
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)
|
||||||
|
|
||||||
self.value = score
|
self.value = score
|
||||||
|
|
||||||
@ -47,71 +65,72 @@ class Score(arcade.Sprite):
|
|||||||
for index, val in enumerate(valArr):
|
for index, val in enumerate(valArr):
|
||||||
if val == "0":
|
if val == "0":
|
||||||
addSprite = arcade.Sprite("assets/Sprites/Numbers/0.png", self.scScale)
|
addSprite = arcade.Sprite("assets/Sprites/Numbers/0.png", self.scScale)
|
||||||
addSprite.center_y = self.scScale * 250
|
addSprite.center_y = self.scScale * 230
|
||||||
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
||||||
self.sprites.append(addSprite)
|
self.sprites.append(addSprite)
|
||||||
if self.deBuggin:
|
if self.deBuggin:
|
||||||
print(addSprite.center_x)
|
print(addSprite.center_x)
|
||||||
elif val == "1":
|
elif val == "1":
|
||||||
addSprite = arcade.Sprite("assets/Sprites/Numbers/1.png", self.scScale)
|
addSprite = arcade.Sprite("assets/Sprites/Numbers/1.png", self.scScale)
|
||||||
addSprite.center_y = self.scScale * 250
|
addSprite.center_y = self.scScale * 230
|
||||||
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
||||||
self.sprites.append(addSprite)
|
self.sprites.append(addSprite)
|
||||||
if self.deBuggin:
|
if self.deBuggin:
|
||||||
print(addSprite.center_x)
|
print(addSprite.center_x)
|
||||||
elif val == "2":
|
elif val == "2":
|
||||||
addSprite = arcade.Sprite("assets/Sprites/Numbers/2.png", self.scScale)
|
addSprite = arcade.Sprite("assets/Sprites/Numbers/2.png", self.scScale)
|
||||||
addSprite.center_y = self.scScale * 250
|
addSprite.center_y = self.scScale * 230
|
||||||
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
||||||
self.sprites.append(addSprite)
|
self.sprites.append(addSprite)
|
||||||
if self.deBuggin:
|
if self.deBuggin:
|
||||||
print(addSprite.center_x)
|
print(addSprite.center_x)
|
||||||
elif val == "3":
|
elif val == "3":
|
||||||
addSprite = arcade.Sprite("assets/Sprites/Numbers/3.png", self.scScale)
|
addSprite = arcade.Sprite("assets/Sprites/Numbers/3.png", self.scScale)
|
||||||
addSprite.center_y = self.scScale * 250
|
addSprite.center_y = self.scScale * 230
|
||||||
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
||||||
self.sprites.append(addSprite)
|
self.sprites.append(addSprite)
|
||||||
if self.deBuggin:
|
if self.deBuggin:
|
||||||
print(addSprite.center_x)
|
print(addSprite.center_x)
|
||||||
elif val == "4":
|
elif val == "4":
|
||||||
addSprite = arcade.Sprite("assets/Sprites/Numbers/4.png", self.scScale)
|
addSprite = arcade.Sprite("assets/Sprites/Numbers/4.png", self.scScale)
|
||||||
addSprite.center_y = self.scScale * 250
|
addSprite.center_y = self.scScale * 230
|
||||||
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
||||||
self.sprites.append(addSprite)
|
self.sprites.append(addSprite)
|
||||||
if self.deBuggin:
|
if self.deBuggin:
|
||||||
print(addSprite.center_x)
|
print(addSprite.center_x)
|
||||||
elif val == "5":
|
elif val == "5":
|
||||||
addSprite = arcade.Sprite("assets/Sprites/Numbers/5.png", self.scScale)
|
addSprite = arcade.Sprite("assets/Sprites/Numbers/5.png", self.scScale)
|
||||||
addSprite.center_y = self.scScale * 250
|
addSprite.center_y = self.scScale * 230
|
||||||
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
||||||
self.sprites.append(addSprite)
|
self.sprites.append(addSprite)
|
||||||
if self.deBuggin:
|
if self.deBuggin:
|
||||||
print(addSprite.center_x)
|
print(addSprite.center_x)
|
||||||
elif val == "6":
|
elif val == "6":
|
||||||
addSprite = arcade.Sprite("assets/Sprites/Numbers/6.png", self.scScale)
|
addSprite = arcade.Sprite("assets/Sprites/Numbers/6.png", self.scScale)
|
||||||
addSprite.center_y = self.scScale * 250
|
addSprite.center_y = self.scScale * 230
|
||||||
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
||||||
self.sprites.append(addSprite)
|
self.sprites.append(addSprite)
|
||||||
if self.deBuggin:
|
if self.deBuggin:
|
||||||
print(addSprite.center_x)
|
print(addSprite.center_x)
|
||||||
elif val == "7":
|
elif val == "7":
|
||||||
addSprite = arcade.Sprite("assets/Sprites/Numbers/7.png", self.scScale)
|
addSprite = arcade.Sprite("assets/Sprites/Numbers/7.png", self.scScale)
|
||||||
addSprite.center_y = self.scScale * 250
|
addSprite.center_y = self.scScale * 230
|
||||||
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
||||||
self.sprites.append(addSprite)
|
self.sprites.append(addSprite)
|
||||||
if self.deBuggin:
|
if self.deBuggin:
|
||||||
print(addSprite.center_x)
|
print(addSprite.center_x)
|
||||||
elif val == "8":
|
elif val == "8":
|
||||||
addSprite = arcade.Sprite("assets/Sprites/Numbers/8.png", self.scScale)
|
addSprite = arcade.Sprite("assets/Sprites/Numbers/8.png", self.scScale)
|
||||||
addSprite.center_y = self.scScale * 250
|
addSprite.center_y = self.scScale * 230
|
||||||
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
||||||
self.sprites.append(addSprite)
|
self.sprites.append(addSprite)
|
||||||
if self.deBuggin:
|
if self.deBuggin:
|
||||||
print(addSprite.center_x)
|
print(addSprite.center_x)
|
||||||
elif val == "9":
|
elif val == "9":
|
||||||
addSprite = arcade.Sprite("assets/Sprites/Numbers/9.png", self.scScale)
|
addSprite = arcade.Sprite("assets/Sprites/Numbers/9.png", self.scScale)
|
||||||
addSprite.center_y = self.scScale * 250
|
addSprite.center_y = self.scScale * 230
|
||||||
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
addSprite.center_x = self.scScale * (index*8) + (self.scScale * LEFT_OFFSET)
|
||||||
self.sprites.append(addSprite)
|
self.sprites.append(addSprite)
|
||||||
if self.deBuggin:
|
if self.deBuggin:
|
||||||
print(addSprite.center_x)
|
print(addSprite.center_x)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user