-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitems.py
More file actions
executable file
·52 lines (42 loc) · 1.42 KB
/
Copy pathitems.py
File metadata and controls
executable file
·52 lines (42 loc) · 1.42 KB
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
import numpy as np
from gameObject import GameObject
class Item(GameObject):
def __init__(self, gamesize):
location, type = Item.generate(gamesize)
super().__init__(location, objecttype=3)
self.type = type
self.gamesize: int = gamesize
self.identify(self.type)
self.score: int
self.color: tuple[float]
def identify(self, type):
match type:
case 1:
self.score = 10
self.color = (255,0,0)
case 2:
self.score = 20
self.color = (0,255,0)
case 3:
self.score = 5
self.color = (0,0,255)
case _:
print("Unknown food type!")
def getLocation(self):
location: list[tuple[int, int]] = self.location
return location[0]
def getGameSize(self):
return self.gamesize
def getScore(self):
return self.score
def regenerate(self):
gamesize = self.getGameSize()
self.location, self.type = self.generate(gamesize)
self.identify(self.type)
@staticmethod
def generate(gamesize):
type = np.random.randint(1, 4)
loc_x = np.random.randint(1, gamesize)
loc_y = np.random.randint(1, gamesize)
location: list[tuple] = [(loc_x, loc_y)]
return location, type