Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import sys, pygame
- from pygame.locals import *
- import constants as const
- import mario
- # Initialise Pygame
- pygame.init()
- # Create display
- DISPLAYSURF = pygame.display.set_mode(const.SCREEN_DIMENSIONS)
- pygame.display.set_caption("Mario in Pygame")
- class Game(object):
- def __init__(self):
- self.fps = 60
- self.showfps = True
- self.clock = pygame.time.Clock()
- # Set FPS
- self.clock.tick(self.fps)
- # Load background
- bg = pygame.image.load("../assets/images/level_12.png").convert()
- self.main_loop()
- # Quit function
- def closegame(self):
- pygame.display.quit() # Quit display first to make it look like the game closes quicker
- pygame.quit()
- sys.exit()
- def main_loop(self):
- while True:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- self.closegame()
- self.Mario = mario.Mario()
- DISPLAYSURF.fill(const.BLACK)
- pygame.display.flip()
- if self.showfps:
- pygame.display.set_caption("Mario in Pygame - %s FPS" % self.clock.get_fps())
- game = Game()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement