-
Notifications
You must be signed in to change notification settings - Fork 0
/
game_run.py
57 lines (48 loc) · 1.56 KB
/
game_run.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
import pygame
from pygame.locals import *
from player import Player
from world import World
from areas import *
class Game(object):
def __init__(self):
self.clock = pygame.time.Clock()
self.world = World()
self.world.setup(4, 3, 64)
self.player = Player()
self.world.addPlayer(self.player)
area = AreaTest(64, 64)
area2 = AreaTest2(64, 64)
area3 = AreaTest3(64, 64)
self.world.addArea(area)
self.world.addArea(area2)
self.world.addArea(area3)
self.world.loadStartArea(area)
self.keyPressed = None
def controls(self):
self.keyPressed = pygame.key.get_pressed()
for event in pygame.event.get():
if event.type == QUIT:
self.quitGame()
elif event.type == KEYDOWN:
if event.key == K_SPACE: #Action key
d = self.player.facingDirection
if not self.player.direction:
#return node that the player is facing towards
print self.player.mover.getNeighborNode(d)
def readObjectText(self):
pass
def pause(self):
pass
def quitGame(self):
'''Quit the game'''
exit()
def gameLoop(self):
while True:
dt = self.clock.tick(30) / 1000.0
self.controls()
self.world.update(dt, self.keyPressed)
self.world.render()
pygame.display.update()
if __name__ == '__main__':
game = Game()
game.gameLoop()