init Score.py and added number sprites

This commit is contained in:
EggMan 2024-04-26 09:09:32 -04:00
parent b69e28aa2c
commit 82ef977e53
13 changed files with 45 additions and 11 deletions

View File

@ -1,4 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<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" />
</project>

34
Main.py
View File

@ -51,6 +51,7 @@ class MyGame(arcade.Window):
self.alienChangeDir = 0
self.alienCurrentDir = -1
self.movedown = False
self.current_texture_index = 0
self.player_sprite = None
@ -78,6 +79,7 @@ class MyGame(arcade.Window):
# self.overlay_color = (0,255,0,128)
self.player_sprite_death = None
self.somethingalsi = True
self.death_textures = None
# set up the player
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:
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):
self.clear()
@ -195,14 +211,17 @@ class MyGame(arcade.Window):
self.activeBullet = False
def respawn(self):
for alienRow in self.aliens:
for alien in alienRow:
alien.bullet = None
# for alienRow in self.aliens:
# for alien in alienRow:
# alien.bullet = None
self.player_sprite.center_x = 32*SCREEN_SCALE
time.sleep(2)
def death(self):
if self.lives > 0:
self.somethingalsi = False
self.load_death_animation()
self.play_death_animation()
self.respawn()
else:
if DEBUG:
print(str(self.Score))
@ -379,14 +398,7 @@ class MyGame(arcade.Window):
time.sleep(SLOW_SPEED)
else:
test = False
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()
self.death()

19
Score.py Normal file
View 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):

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB