-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphicsEngine.py
50 lines (45 loc) · 1.74 KB
/
graphicsEngine.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
41
42
43
44
45
46
47
48
49
50
import turtle
class graphicsEngine(object):
def __init__(self):
self.Ramses = turtle
self.Ramses.begin_fill()
self.Ramses.speed(0)
self.Ramses.mode('logo')
def drawState(self, walls, red, blue):
self.Ramses.clearscreen()
self.Ramses.hideturtle()
self.Ramses.penup()
self.Ramses.speed(0)
for wall in walls:
self.Ramses.color("black")
self.Ramses.goto(wall[0])
self.Ramses.pendown()
self.Ramses.goto(wall[1])
self.Ramses.penup()
for unit in red.get_armies():
if unit.strength <= 0:
continue
self.Ramses.color("red")
self.Ramses.goto(unit.location)
self.Ramses.setheading(unit.heading)
self.Ramses.stamp()
self.Ramses.write("{} | {} | {}".format(unit.get_unitID(), unit.strength, unit.heading))
# self.drawRangeCircle(unit.fireRange)
for unit in blue.get_armies():
if unit.strength <= 0:
continue
self.Ramses.color("blue")
self.Ramses.goto(unit.location)
self.Ramses.setheading(unit.heading)
self.Ramses.stamp()
self.Ramses.write("{} | {} | {}".format(unit.get_unitID(), unit.strength, unit.heading))
# self.drawRangeCircle(unit.fireRange)
self.Ramses.hideturtle()
def drawRangeCircle(self, fireRange):
curPos = self.Ramses.position()
self.Ramses.setheading(0)
newX = curPos[0] + fireRange
self.Ramses.setx(newX)
self.Ramses.pendown()
self.Ramses.circle(fireRange)
self.Ramses.penup()