-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
52 lines (37 loc) · 1.39 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
import pygame
from OpenGL.GL import *
import time
from game import Game, GameState
class App:
def __init__(self):
pygame.init()
self.display = (800, 600)
pygame.display.gl_set_attribute(pygame.GL_CONTEXT_MAJOR_VERSION, 3)
pygame.display.gl_set_attribute(pygame.GL_CONTEXT_MINOR_VERSION, 3)
pygame.display.gl_set_attribute(pygame.GL_CONTEXT_PROFILE_MASK,
pygame.GL_CONTEXT_PROFILE_CORE)
pygame.display.set_mode(self.display, pygame.DOUBLEBUF | pygame.OPENGL)
pygame.display.set_caption('Hooman')
self.mainloop()
def mainloop(self):
cur_time = time.time()
game = Game(self.display)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
game.delete()
pygame.quit()
quit()
if event.type == pygame.KEYDOWN:
game.prevState = game.state
game.state = GameState.JUMPING
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
prev_time = cur_time
cur_time = time.time()
dt = cur_time - prev_time
game.update(dt)
game.render()
pygame.display.flip()
pygame.time.wait(10)
if __name__ == "__main__":
App()