-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
97 lines (91 loc) · 3.25 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#main function
import pygame
import math
import world
import visual
pygame.init()
clock = pygame.time.Clock()
gravList = world.getGravList()
#cam
#test cases
'''
player.pos[1]=40
for i in [0,10,20,30,40]:
player.pos[0]=i
center.calulateGrav(player)
for i in [30,20,10,0,-10,-20,-30,-40]:
player.pos[1]=i
center.calulateGrav(player)
for i in [30,20,10,0,-10,-20,-30,-40]:
player.pos[0]=i
center.calulateGrav(player)
for i in [-30,-20,-10,0,10,20,30,40]:
player.pos[1]=i
center.calulateGrav(player)
for i in [-30,-20,-10,0]:
player.pos[0]=i
center.calulateGrav(player)
'''
done=False
while (True != done):
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
fullexit = True
elif event.type==pygame.KEYDOWN:
if event.key == 273: #up
visual.camra.adjPos([0,15])
elif event.key == 274: #down
visual.camra.adjPos([0,-15])
elif event.key == 276: #left
visual.camra.adjPos([15,0])
elif event.key == 275: #right
visual.camra.adjPos([-15,0])
elif event.key == 119: #w,a,s,d = 119, 97, 115, 100
world.player_charecter.engines_on[0] += 1
elif event.key == 115:
world.player_charecter.engines_on[0] -= 1
elif event.key == 97:
world.player_charecter.engines_on[1] += 1
elif event.key == 100:
world.player_charecter.engines_on[1] -= 1
elif event.key ==102:
print((visual.camra.x, visual.camra.y))
print((world.player_charecter.pos[0], world.player_charecter.pos[1]))
#(visual.camra.x, visual.camra.y) = (world.player_charecter.pos[0], world.player_charecter.pos[1])
elif event.key == 32:
#this doesn't work, for some reason. Needed to resort to:
print((visual.camra.x, visual.camra.y))
print(world.player_charecter.pos)
visual.camra.center_on(world.player_charecter)
else:
print(event.key)
elif event.type == pygame.KEYUP:
if event.key == 0:
pass
elif event.key == 119: #w,a,s,d = 119, 97, 115, 100
world.player_charecter.engines_on[0] -= 1
elif event.key == 115:
world.player_charecter.engines_on[0] += 1
elif event.key == 97:
world.player_charecter.engines_on[1] -= 1
elif event.key == 100:
world.player_charecter.engines_on[1] += 1
else:
pass
#print(event.key)
world.updateList()
visual.drawStart()
visual.drawList(gravList)
visual.drawEnd()
pygame.display.flip()
for first in gravList:
for second in gravList:
if first!=second:
try:
#print(first.colision(second))
pass
except:
pass
clock.tick(30)
pygame.quit()