Last active
November 16, 2015 17:49
-
-
Save nocturnaltortoise/4b608e384aaebf8e3bbd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame, sys | |
from pygame.locals import * | |
from enum import Enum | |
class Game: | |
def __init__(self, width, height, game_state): | |
pygame.init() | |
self.Game_State = Game_State(game_state) | |
self.SCREEN_WIDTH = width | |
self.SCREEN_HEIGHT = height | |
self.DISPLAYSURF = pygame.display.set_mode((self.SCREEN_WIDTH, self.SCREEN_HEIGHT)) | |
pygame.display.set_caption("Test Game") | |
def handle_event(self,event): | |
if event.type == QUIT: | |
self.Game_State = Game_State.FINISHED | |
pygame.quit() | |
sys.exit() | |
def play(self): | |
while self.Game_State == Game_State.PLAYING: | |
for event in pygame.event.get(): | |
self.handle_event(event) | |
pygame.display.update() | |
class Game_State(Enum): | |
PLAYING = 1 | |
PAUSED = 2 | |
FINISHED = 3 | |
game = Game(800,600,Game_State.PLAYING) | |
game.play() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment