forked from InfoProjekt/game
		
	startscreen added
also some buttons added to be completed button class initalized Signed-off-by: SpagettiFisch <63868515+SpagettiFisch@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									418ae5ee7b
								
							
						
					
					
						commit
						51a287ba66
					
				
					 8 changed files with 43 additions and 9 deletions
				
			
		
							
								
								
									
										
											BIN
										
									
								
								art/exit.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								art/exit.png
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 738 B | 
							
								
								
									
										
											BIN
										
									
								
								art/new_game.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								art/new_game.png
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 974 B | 
							
								
								
									
										
											BIN
										
									
								
								art/options.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								art/options.png
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 808 B | 
							
								
								
									
										
											BIN
										
									
								
								art/textbox.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								art/textbox.png
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 607 B | 
							
								
								
									
										25
									
								
								classes.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								classes.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,25 @@ | ||||||
|  | import pygame | ||||||
|  | 
 | ||||||
|  | font = pygame.font.SysFont('Arial', 40) | ||||||
|  | 
 | ||||||
|  | class Button(): | ||||||
|  |     def __init__(self, x, y, width, height, buttonText='Button', onclickFunction=None, onePress=False): | ||||||
|  |         self.x = x | ||||||
|  |         self.y = y | ||||||
|  |         self.width = width | ||||||
|  |         self.height = height | ||||||
|  |         self.onclickFunction = onclickFunction | ||||||
|  |         self.onePress = onePress | ||||||
|  |         self.alreadyPressed = False | ||||||
|  | 
 | ||||||
|  |         self.fillColors = { | ||||||
|  |             'normal': '#ffffff', | ||||||
|  |             'hover': '#666666', | ||||||
|  |             'pressed': '#333333', | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         self.buttonSurface = pygame.Surface((self.width, self.height)) | ||||||
|  |         self.buttonRect = pygame.Rect(self.x, self.y, self.width, self.height) | ||||||
|  | 
 | ||||||
|  |         self.buttonSurf = font.render(buttonText, True, (20, 20, 20)) | ||||||
|  |         return self | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| { | { | ||||||
|     "screen": |     "screen": | ||||||
|     { |     { | ||||||
|         "res":[1120, 780], |         "res":[1280, 720], | ||||||
|         "fullscreen": false |         "fullscreen": false | ||||||
|     } |     } | ||||||
| } | } | ||||||
							
								
								
									
										25
									
								
								main.py
									
										
									
									
									
								
							
							
						
						
									
										25
									
								
								main.py
									
										
									
									
									
								
							|  | @ -10,8 +10,9 @@ def setUp(config): | ||||||
|     else: |     else: | ||||||
|         screen = pygame.display.set_mode(config["res"]) |         screen = pygame.display.set_mode(config["res"]) | ||||||
|     clock = pygame.time.Clock() |     clock = pygame.time.Clock() | ||||||
|     running = True |     with open('art/textbox.png', 'r') as tb: | ||||||
|     return screen, clock, running |         box = pygame.image.load(tb) | ||||||
|  |     return screen, clock, True, True, "start.png", box | ||||||
| 
 | 
 | ||||||
| def readConfig(): | def readConfig(): | ||||||
|     with open('config.json', 'r') as c: |     with open('config.json', 'r') as c: | ||||||
|  | @ -20,20 +21,28 @@ def readConfig(): | ||||||
| 
 | 
 | ||||||
| def main(): | def main(): | ||||||
|     config = readConfig() |     config = readConfig() | ||||||
|     screen, clock, running = setUp(config["screen"]) |     screen, clock, running, background, isblack, box = setUp(config["screen"]) | ||||||
|  |      | ||||||
|     while running: |     while running: | ||||||
|         for event in pygame.event.get(): |         for event in pygame.event.get(): | ||||||
|             if event.type == pygame.QUIT: |             if event.type == pygame.QUIT: | ||||||
|                 running = False  |                 running = False  | ||||||
|  |          | ||||||
|  |         if not isblack: | ||||||
|  |             with open(background, 'r') as i: | ||||||
|  |                 bg = pygame.image.load(i) | ||||||
|  |                 bg = pygame.transform.scale(bg, screen.get_size()) | ||||||
|             # fill the screen with a color to wipe away anything from last frame |             # fill the screen with a color to wipe away anything from last frame | ||||||
|             screen.fill("purple") |             screen.blit(bg, (0, 0)) | ||||||
| 
 | 
 | ||||||
|             # RENDER YOUR GAME HERE |         # RENDER YOUR GAME HERE | ||||||
| 
 | 
 | ||||||
|             # flip() the display to put your work on screen |         else: | ||||||
|             pygame.display.flip() |             screen.fill('#000000') | ||||||
|  |         # flip() the display to put your work on screen | ||||||
|  |         pygame.display.flip() | ||||||
| 
 | 
 | ||||||
|             clock.tick(60)  # limits FPS to 60 |         clock.tick(60)  # limits FPS to 60 | ||||||
| 
 | 
 | ||||||
|     pygame.quit() |     pygame.quit() | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										
											BIN
										
									
								
								test.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								test.png
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 529 KiB | 
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 SpagettiFisch
						SpagettiFisch