-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCPPMain.py
67 lines (38 loc) · 1.21 KB
/
CPPMain.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import pygame as pg
fps = 10
import BoardEngine
import Robot
from constants import *
def main():
pg.init()
screen = pg.display.set_mode((400,420))
ingame = True
clock = pg.time.Clock()
bs = BoardEngine.Board_State()
robot = Robot.Rb()
bgrcolor = pg.Color(("white"))
while ingame :
for event in pg.event.get() :
if event.type == pg.QUIT:
robot.mark1 = True
if event.type == pg.MOUSEBUTTONDOWN:
location = pg.mouse.get_pos()
x = int(location[1]//BLOCK)
y = int(location[0]//BLOCK)
bs.changeObstacle(x, y)
screen.fill(bgrcolor)
robot.play(bs)
repaintBoard(screen, bs, robot)
clock.tick(fps)
pg.display.flip()
def repaintBoard(screen, bs, robot):
bs.drawObstacle(screen)
bs.drawPath(screen)
bs.drawCurrentPos(screen, robot)
if robot.Pmove and not robot.oldPos == () and not robot.move == ():
bs.drawLine(screen,robot.oldPos,robot.move)
# DRAW LAST
bs.drawStart(screen)
bs.drawOutline(screen)
bs.drawPathLength(screen, robot)
main()