-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjects.py
More file actions
93 lines (74 loc) · 2.36 KB
/
Objects.py
File metadata and controls
93 lines (74 loc) · 2.36 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import pygame
pygame.init()
class Object():
def __init__(self,x, y, t):
self.width = 120 -(60*t)
self.height = 120 -(60*t)
self.x = x
self.y = y
self.type = t
self.rect = pygame.Rect(self.x, self.y, self.width, self.height)
self.colours = [(0,0,0),(65, 213, 215)]
self.colour = self.colours[t]
self.speed = 13.5
def moveDown(self):
self.y += self.speed
def isVisible(self):
if self.y <750:
return True
else:
return False
def update(self,window):
self.moveDown()
self.rect = pygame.Rect(self.x, self.y, self.width, self.height)
if self.type == 0:
pygame.draw.rect(window, self.colour, self.rect)
else:
pygame.draw.circle(window, self.colour,(self.x+self.width/2,self.y+self.height/2),30)
class TrailBlock():
def __init__(self, x, y):
self.x = x
self.y = y
self.colour = (55, 203, 205)
self.speed = 13
def moveDown(self):
self.y += self.speed
def setColour(self,c):
self.colour = c
def update(self,window):
self.moveDown()
pygame.draw.circle(window, self.colour,(self.x,self.y), 30)
class Projectile():
def __init__(self,x,y,t):
self.x = x
self.y = y
self.colours = [(65, 213, 215),(252, 73, 73)]
self.colour = self.colours[t]
self.speed = 19
self.type = t
self.rect = pygame.Rect(self.x - 30, self.y - 30 ,30,30)
def moveUpOrDown(self):
if self.type == 0:
self.y -= self.speed
else:
self.y += self.speed
def getType(self):
return self.type
def update(self,window):
self.moveUpOrDown()
self.rect = pygame.Rect(self.x - 30, self.y - 30 ,30,30)
pygame.draw.circle(window, self.colour,(self.x,self.y), 30)
class Button():
def __init__(self,x,y,t):
self.x = x
self.y = y
self.imgs = ["assets/start.png","assets/quit.png"]
self.img = pygame.image.load(self.imgs[t]).convert()
self.rect = pygame.Rect(self.x, self.y, 300, 120)
def getX(self):
return self.x
def getY(self):
return self.y
def update(self,window):
self.rect = pygame.Rect(self.x, self.y, 300, 120)
window.blit(self.img, self.rect)