-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathship_lives_display.py
57 lines (44 loc) · 1.79 KB
/
ship_lives_display.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""This file contains a class to keep track of the ship's lives, and displaying them on the screen."""
from point import Point
import constants
import math
import arcade
class Ship_Lives:
"""This class is responsible for displaying the number of lives the ship has left on the screen."""
def __init__(self):
"""Initializes the count of little ships to display on the screen."""
self._center = Point()
self._center.y = constants.SCREEN_HEIGHT - 30
self._center.x = 30
self._texture = self.load_texture(":resources:images/space_shooter/playerLife1_orange.png")
def draw(self):
"""Draws a few little ships, based on the current life count."""
width, height, alpha, texture = self._texture
angle = math.degrees(0)
arcade.draw_texture_rectangle(self._center.x, self._center.y, width, height, texture, angle, alpha)
def load_texture(self, img):
"""A method to load the texture of the flying object."""
texture = arcade.load_texture(img)
width = texture.width
height = texture.height
alpha = 255
return width, height, alpha, texture
# Getter and Setter properties are listed below
@property
def life_count(self):
return self._life_count
@life_count.setter
def life_count(self, life_count):
self._life_count = life_count
@property
def texture(self):
return self._texture
@texture.setter
def texture(self, texture):
self._texture = texture
@property
def center(self):
return self._center
@center.setter
def center(self, center):
self._center = center