Development #57
					 2 changed files with 48 additions and 0 deletions
				
			
		
							
								
								
									
										7
									
								
								config.json
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								config.json
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,7 @@ | ||||||
|  | { | ||||||
|  |     "screen": | ||||||
|  |     { | ||||||
|  |         "res":[1120, 780], | ||||||
|  |         "fullscreen": false | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										41
									
								
								main.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								main.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,41 @@ | ||||||
|  | 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() | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue