-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
45 lines (35 loc) · 1.08 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
# This Python file uses the following encoding: utf-8
import os, sys
import pygame
from scenes import GameScene
if not pygame.font: print ('Warning, fonts disabled')
if not pygame.mixer: print ('Warning, sound disabled')
#Juego
class PyGame:
def __init__(self):
#Pygame init
pygame.init()
#Posicion de la ventana
os.environ['SDL_VIDEO_WINDOW_POS'] = str(500) + "," + str(200)
self.screen = pygame.display.set_mode((800,600))
self.currentScene=GameScene(self.screen)
#Main loop. Delegates everything on running scene
def MainLoop(self):
#Main loop
clock=pygame.time.Clock()
loop=True
FPS=30
second=float(1000)
while loop:
delta=clock.tick(FPS)/second
for event in pygame.event.get():
self.currentScene.processInput(event)
if event.type == pygame.QUIT:
sys.exit()
if event.type == pygame.KEYDOWN and event.key==pygame.K_ESCAPE:
sys.exit()
self.currentScene.update(delta)
self.currentScene.draw(self.screen)
if __name__ == "__main__":
MainWindow = PyGame()
MainWindow.MainLoop()