-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
81 lines (52 loc) · 2.06 KB
/
main.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import turtle as t
import time
from pacmanClass import Pacman
from enemiesClass import Enemy
from wallClass import Walls
from config import *
from importWalls import importWallsTab
from pointsClass import *
Walls.importWalls(importWallsTab)
pacman = Pacman()
Enemy.enemiesTab.append(Enemy('red',0))
Enemy.enemiesTab.append(Enemy("blue",1))
Enemy.enemiesTab.append(Enemy("pink",2))
Enemy.enemiesTab.append(Enemy("orange",3))
t.onkeypress(pacman.goUp, "Up")
t.onkeypress(pacman.goDown, "Down")
t.onkeypress(pacman.goLeft, "Left")
t.onkeypress(pacman.goRight, "Right")
Point(-240.0, 120.0)
Point(193.0, 271.0)
Point(-69.0, -331.0)
Point(-321.0, 330.0)
Point(134.0, 118.0)
Point(279.0, -228.0)
t.listen()
while True:
window.update()
pacman.move()
pointShowFlag = False
for point in Point.pointsTab:
if pacman.distance(point.point) < 20 and point.getEaten() == False:
point.packmanColission()
if point.getEaten() == False:
pointShowFlag = True
if pointShowFlag == False:
Point.showPoints()
for enemy in Enemy.enemiesTab:
enemy.move()
for wall in Walls.wallsTab:
if pacman.pacman.pos()[0] < wall.wall.pos()[0] + wall.wall.width and pacman.pacman.pos()[0] + pacman.pacman.width > wall.wall.pos()[0] and pacman.pacman.pos()[1] < wall.wall.pos()[1] + wall.wall.height and pacman.pacman.pos()[1] + pacman.pacman.height > wall.wall.pos()[1]:
pacman.wallColission()
for enemy in Enemy.enemiesTab:
if enemy.enemy.pos()[0] < wall.wall.pos()[0] + wall.wall.width and enemy.enemy.pos()[0] + enemy.enemy.width > wall.wall.pos()[0] and enemy.enemy.pos()[1] < wall.wall.pos()[1] + wall.wall.height and enemy.enemy.pos()[1] + enemy.enemy.height > wall.wall.pos()[1]:
enemy.wallColission()
if enemy.distance(pacman.pacman) < 40:
updateScorebar()
window.update()
print("GAME OVER")
time.sleep(2)
window.bye()
quit()
time.sleep(0.01)