-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitems.py
41 lines (35 loc) · 1.05 KB
/
items.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
import pygame
import random
class Item:
x = 5
y = 19
itemType = ''
color = ''
def draw(self, size, screen, offset):
pygame.draw.rect(screen, self.color, pygame.Rect(self.x * size + offset[0], self.y * size + offset[1], size, size))
def reset(self, avoidPoints, size):
self.x = random.randint(0, size)
self.y = random.randint(0, size)
for i in avoidPoints:
if [self.x, self.y] == i:
self.reset(avoidPoints, size)
def checkOutside(self, boardSize):
if self.x > boardSize - 1:
self.x = boardSize - 1
if self.y > boardSize - 1:
self.y = boardSize - 1
class Apple(Item):
color = (205, 92, 92)
class Rosine(Item):
# hard to see this one
color = (10,0,10)
getSmaller = 15
def action(self, boardSize):
if boardSize == 10:
return False
if self.getSmaller == 0:
self.getSmaller = 15
return True
else:
self.getSmaller -= 1
return None