-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgame.py
More file actions
82 lines (67 loc) · 2.09 KB
/
game.py
File metadata and controls
82 lines (67 loc) · 2.09 KB
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
# Import Pygame
import pygame
# Import time
import time
# Import loading code for pygame
from pygame.locals import *
from Sprite import Player
# Import gesture recognizer
from gesture_recognizer import GestureRecognizer as gr
# Import settings
from settings import *
# Import maps
from maps import *
# Import os
import os
# Import level
#import level
# Import camera
import camera
# Import Create
import create
# Initialise Pygame
pygame.init()
# Create window
display_surface = pygame.display.set_mode((750,750))
# Create rect
rect = pygame.Rect(750,750,60,90)
player = Player()
# Create camera
camera = camera.Camera(player.sprite.rect, MAPWIDTH, MAPHEIGHT)
# Create display title
pygame.display.set_caption('Hand Game')
# Only Allow Script that only allows python3.6 and directly called script
if __name__ != '__main__':
# Python version not 3.6
print("Must be using Python 3.6")
exit()
recognizer = gr.GestureRecognizer(print_pos=False)
recognizer.start_recognizing()
#current = level.Level("level_1.lvl")
rect_list = []
for row in range(MAPHEIGHT):
for column in range(MAPWIDTH):
rect = pygame.draw.rect(display_surface, colors[tilemap[row][column]], (column*TILESIZE,row*TILESIZE,TILESIZE,TILESIZE))
if tilemap[row][column] == WALL:
rect_list.append(rect)
# MAIN LOOP
while True:
time.sleep(1./30)
# If game quit than quit app
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
os.remove('__pycache__/Sprite.cpython-36.pyc')
exit()
x_dir = recognizer.gesture.x_dir
y_dir = recognizer.gesture.y_dir
player.handle_gestures(x_dir, y_dir, rect_list)
# player.handle_keys(rect_list)
# camera_data = camera.update(player, current)
# create.level(display_surface, current, camera_data, player.x, player.y)
for row in range(MAPHEIGHT):
for column in range(MAPWIDTH):
pygame.draw.rect(display_surface, colors[tilemap[row][column]], (column*TILESIZE,row*TILESIZE,TILESIZE,TILESIZE))
player.draw(display_surface)
# Update display
pygame.display.update()