init Score.py and added number sprites
@ -1,4 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="Black">
|
||||||
|
<option name="sdkName" value="Python 3.11 (CNSA-266-FP)" />
|
||||||
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (CNSA-266-FP)" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (CNSA-266-FP)" project-jdk-type="Python SDK" />
|
||||||
</project>
|
</project>
|
34
Main.py
@ -51,6 +51,7 @@ class MyGame(arcade.Window):
|
|||||||
self.alienChangeDir = 0
|
self.alienChangeDir = 0
|
||||||
self.alienCurrentDir = -1
|
self.alienCurrentDir = -1
|
||||||
self.movedown = False
|
self.movedown = False
|
||||||
|
self.current_texture_index = 0
|
||||||
|
|
||||||
self.player_sprite = None
|
self.player_sprite = None
|
||||||
|
|
||||||
@ -78,6 +79,7 @@ class MyGame(arcade.Window):
|
|||||||
# self.overlay_color = (0,255,0,128)
|
# self.overlay_color = (0,255,0,128)
|
||||||
self.player_sprite_death = None
|
self.player_sprite_death = None
|
||||||
self.somethingalsi = True
|
self.somethingalsi = True
|
||||||
|
self.death_textures = None
|
||||||
|
|
||||||
# set up the player
|
# set up the player
|
||||||
image_source = "assets/Sprites/Player/Player.png"
|
image_source = "assets/Sprites/Player/Player.png"
|
||||||
@ -156,6 +158,20 @@ class MyGame(arcade.Window):
|
|||||||
elif key == arcade.key.RIGHT and self.movePlayer == PLAYER_SPEED * SCREEN_SCALE:
|
elif key == arcade.key.RIGHT and self.movePlayer == PLAYER_SPEED * SCREEN_SCALE:
|
||||||
self.movePlayer = 0
|
self.movePlayer = 0
|
||||||
|
|
||||||
|
def load_death_animation(self):
|
||||||
|
self.death_textures = []
|
||||||
|
for i in range(0,5):
|
||||||
|
|
||||||
|
texture = arcade.load_texture("assets/Sprites/Player/PlayerDeath1.png")
|
||||||
|
self.death_textures.append(texture)
|
||||||
|
texture = arcade.load_texture("assets/Sprites/Player/PlayerDeath2.png")
|
||||||
|
self.death_textures.append(texture)
|
||||||
|
|
||||||
|
def play_death_animation(self):
|
||||||
|
if self.current_texture_index < len(self.death_textures):
|
||||||
|
self.player_sprite.set_texture(self.current_texture_index)
|
||||||
|
self.current_texture_index += 1
|
||||||
|
|
||||||
def on_draw(self):
|
def on_draw(self):
|
||||||
self.clear()
|
self.clear()
|
||||||
|
|
||||||
@ -195,14 +211,17 @@ class MyGame(arcade.Window):
|
|||||||
self.activeBullet = False
|
self.activeBullet = False
|
||||||
|
|
||||||
def respawn(self):
|
def respawn(self):
|
||||||
for alienRow in self.aliens:
|
# for alienRow in self.aliens:
|
||||||
for alien in alienRow:
|
# for alien in alienRow:
|
||||||
alien.bullet = None
|
# alien.bullet = None
|
||||||
self.player_sprite.center_x = 32*SCREEN_SCALE
|
self.player_sprite.center_x = 32*SCREEN_SCALE
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
def death(self):
|
def death(self):
|
||||||
if self.lives > 0:
|
if self.lives > 0:
|
||||||
self.somethingalsi = False
|
self.somethingalsi = False
|
||||||
|
self.load_death_animation()
|
||||||
|
self.play_death_animation()
|
||||||
|
self.respawn()
|
||||||
else:
|
else:
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print(str(self.Score))
|
print(str(self.Score))
|
||||||
@ -379,14 +398,7 @@ class MyGame(arcade.Window):
|
|||||||
time.sleep(SLOW_SPEED)
|
time.sleep(SLOW_SPEED)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
test = False
|
self.death()
|
||||||
if test:
|
|
||||||
self.player_sprite = arcade.Sprite("assets/Sprites/Player/PlayerDeath1.png", SCREEN_SCALE)
|
|
||||||
self.player_list.draw()
|
|
||||||
else:
|
|
||||||
|
|
||||||
self.player_sprite = arcade.Sprite("assets/Sprites/Player/PlayerDeath2.png", SCREEN_SCALE)
|
|
||||||
self.player_list.draw()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
19
Score.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import arcade
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
def setValue(self, newValue):
|
||||||
|
self.value = newValue
|
||||||
|
|
||||||
|
def getValue(self):
|
||||||
|
return self.value
|
||||||
|
|
||||||
|
def update(self):
|
BIN
assets/Sprites/Numbers/0.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
assets/Sprites/Numbers/1.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
assets/Sprites/Numbers/2.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
assets/Sprites/Numbers/3.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
assets/Sprites/Numbers/4.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
assets/Sprites/Numbers/5.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
assets/Sprites/Numbers/6.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
assets/Sprites/Numbers/7.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
assets/Sprites/Numbers/8.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
assets/Sprites/Numbers/9.png
Normal file
After Width: | Height: | Size: 1.1 KiB |