-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstar.py
More file actions
27 lines (21 loc) · 717 Bytes
/
star.py
File metadata and controls
27 lines (21 loc) · 717 Bytes
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
import pyxel
class Star:
def __init__(self, color_index: int) -> None:
self.color_index = color_index
self.v = 0
self.u = [0, 16, 32, 48, 64][color_index]
def color(self) -> int:
return self.color_index
def draw(self, x, y) -> None:
pyxel.blt(x, y, 0, self.u, self.v, 16, 16, 0)
def __eq__(self, other):
if isinstance(other, Star):
return self.color_index == other.color_index
return False
class SnowStar(Star):
def __init__(self, color_index: int) -> None:
super().__init__(color_index)
self.v = 32
def get_star(color_index: int) -> Star:
return Star(color_index)
# return SnowStar(color_index)