Skip to content

Instantly share code, notes, and snippets.

@Spittie
Created February 26, 2014 14:13
Show Gist options
  • Select an option

  • Save Spittie/9230141 to your computer and use it in GitHub Desktop.

Select an option

Save Spittie/9230141 to your computer and use it in GitHub Desktop.
import pygame
class Game(object):
def __init__(self, height=640, width=480, fps=60):
self.height = height
self.width = width
self.fps = fps
pygame.init()
self.screen = pygame.display.set_mode((self.height, self.width))
self.clock = pygame.time.Clock()
def __del__(self):
pygame.quit()
def eventloop(self):
running = True
while running:
# Handle input
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# Handle everything else
self.update()
self.draw()
# 60fps
print (self.clock.get_fps())
self.clock.tick(self.fps)
def update(self):
pass
def draw(self):
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment