-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathabstractobjects.py
More file actions
32 lines (26 loc) · 1.5 KB
/
abstractobjects.py
File metadata and controls
32 lines (26 loc) · 1.5 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
from pyglet.gl import *
from pyglet.window import *
class GameObject:
def __init__(self, centerX, centerY, height, width, color):
self.centerX = centerX
self.centerY = centerY
self.height = height
self.width = width
self.color = color
def draw(self):
raise Exception("you moron, you didnt make a draw method in", self.__class__.__name__)
class RectangleObject(GameObject):
def __init__(self, centerX, centerY, height, width, color):
super().__init__(centerX, centerY, height, width, color)
def draw(self):
colorR, colorG, colorB = self.color
pyglet.graphics.draw(4, pyglet.gl.GL_QUADS, ('v2f', ((self.centerX - (self.width/2)), (self.centerY - (self.height/2)),
(self.centerX - (self.width/2)), (self.centerY + (self.height/2)),
(self.centerX + (self.width/2)), (self.centerY + (self.height/2)),
(self.centerX + (self.width/2)), (self.centerY - (self.height/2)))),
('c3B', (colorR, colorG, colorB,
colorR, colorG, colorB,
colorR, colorG, colorB,
colorR, colorG, colorB)))
def update(self):
super().update()