forked from InfoProjekt/game
41 lines
1 KiB
Python
41 lines
1 KiB
Python
import pygame
|
|
import sys
|
|
import json
|
|
import time
|
|
|
|
def setUp(config):
|
|
pygame.init()
|
|
if config["fullscreen"]:
|
|
screen = pygame.display.set_mode(config["res"], pygame.FULLSCREEN)
|
|
else:
|
|
screen = pygame.display.set_mode(config["res"])
|
|
clock = pygame.time.Clock()
|
|
running = True
|
|
return screen, clock, running
|
|
|
|
def readConfig():
|
|
with open('config.json', 'r') as c:
|
|
json_data = c.read()
|
|
return json.loads(json_data)
|
|
|
|
def main():
|
|
config = readConfig()
|
|
screen, clock, running = setUp(config["screen"])
|
|
while running:
|
|
for event in pygame.event.get():
|
|
if event.type == pygame.QUIT:
|
|
running = False
|
|
# fill the screen with a color to wipe away anything from last frame
|
|
screen.fill("purple")
|
|
|
|
# RENDER YOUR GAME HERE
|
|
|
|
# flip() the display to put your work on screen
|
|
pygame.display.flip()
|
|
|
|
clock.tick(60) # limits FPS to 60
|
|
|
|
pygame.quit()
|
|
|
|
if __name__ == '__main__':
|
|
main()
|