edited file structure
Signed-off-by: SpagettiFisch <63868515+SpagettiFisch@users.noreply.github.com>
							
								
								
									
										0
									
								
								InfoProjekt.xlsx → .idea/InfoProjekt.xlsx
									
										
									
										generated
									
									
									
								
							
							
						
						
							
								
								
									
										0
									
								
								ideas.txt → .idea/ideas.txt
									
										
									
										generated
									
									
									
								
							
							
						
						
							
								
								
									
										0
									
								
								storyline.txt → .idea/storyline.txt
									
										
									
										generated
									
									
									
								
							
							
						
						| Before Width: | Height: | Size: 738 B After Width: | Height: | Size: 738 B | 
							
								
								
									
										
											BIN
										
									
								
								art/image files/field.kra
									
										
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								art/image files/field.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 544 B | 
| Before Width: | Height: | Size: 629 B After Width: | Height: | Size: 629 B | 
| Before Width: | Height: | Size: 724 B After Width: | Height: | Size: 724 B | 
| Before Width: | Height: | Size: 703 B After Width: | Height: | Size: 703 B | 
| Before Width: | Height: | Size: 651 B After Width: | Height: | Size: 651 B | 
| Before Width: | Height: | Size: 706 B After Width: | Height: | Size: 706 B | 
| Before Width: | Height: | Size: 694 B After Width: | Height: | Size: 694 B | 
| Before Width: | Height: | Size: 731 B After Width: | Height: | Size: 731 B | 
| Before Width: | Height: | Size: 719 B After Width: | Height: | Size: 719 B | 
| Before Width: | Height: | Size: 657 B After Width: | Height: | Size: 657 B | 
| Before Width: | Height: | Size: 974 B After Width: | Height: | Size: 974 B | 
| Before Width: | Height: | Size: 808 B After Width: | Height: | Size: 808 B | 
| Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB | 
| Before Width: | Height: | Size: 644 B After Width: | Height: | Size: 644 B | 
							
								
								
									
										75
									
								
								classes.py
									
										
									
									
									
								
							
							
						
						|  | @ -34,8 +34,8 @@ fonts = { | |||
| } | ||||
| 
 | ||||
| class Button(): | ||||
|     def __init__(self, x, y, width, height, font, buttonText='Button', onclickFunction=None, onePress=False): | ||||
|         font = pygame.font.Font(f'fonts/{fonts[font]}', 48) | ||||
|     def __init__(self, x, y, width, height, font, font_size, buttonText='Button', onclickFunction=None, onePress=False): | ||||
|         self.font = pygame.font.Font(f'fonts/{fonts[font]}', font_size) | ||||
|         self.x = x | ||||
|         self.y = y | ||||
|         self.width = width | ||||
|  | @ -51,14 +51,12 @@ class Button(): | |||
| 
 | ||||
|         self.buttonRect = pygame.Rect(self.x, self.y, self.width, self.height) | ||||
| 
 | ||||
|         self.buttonSurf = font.render(buttonText, True, '#baab80') | ||||
|         self.buttonSurf = self.font.render(buttonText, True, '#baab80') | ||||
| 
 | ||||
|     def process(self, screen): | ||||
|         mousePos = pygame.mouse.get_pos() | ||||
|         if self.buttonRect.collidepoint(mousePos): | ||||
|             #self.buttonSurface.fill(self.fillColors['hover']) | ||||
|             if pygame.mouse.get_pressed(num_buttons=3)[0]: | ||||
|                 #self.buttonSurface.fill(self.fillColors['pressed']) | ||||
|                 if self.onePress: | ||||
|                     self.onclickFunction() | ||||
|                 elif not self.alreadyPressed: | ||||
|  | @ -70,4 +68,69 @@ class Button(): | |||
|             self.buttonRect.width/2 - self.buttonSurf.get_rect().width/2, | ||||
|             self.buttonRect.height/2 - self.buttonSurf.get_rect().height/2 | ||||
|         ]) | ||||
|         screen.blit(self.box, self.buttonRect) | ||||
|         screen.blit(self.box, self.buttonRect) | ||||
| 
 | ||||
| 
 | ||||
| class DropDown(): | ||||
|     def __init__(self, x, y, width, height, font, font_size, color_menu, color_option, main, options): | ||||
|         self.rect = pygame.Rect(x, y, width, height) | ||||
|         self.font = pygame.font.Font(f'fonts/{fonts[font]}', font_size) | ||||
|         self.main = main | ||||
|         self.options = options | ||||
|         self.draw_menu = False | ||||
|         self.menu_active = False | ||||
|         self.active_option = -1 | ||||
| 
 | ||||
|         with open('art/textbox.png', 'r') as tb: | ||||
|             self.box = pygame.image.load(tb) | ||||
|             self.box = pygame.transform.scale(self.box, (width, height)) | ||||
| 
 | ||||
|     def draw(self, screen): | ||||
|         #pygame.draw.rect(screen, self.color_menu[self.menu_active], self.rect, 0) | ||||
|         surface = self.font.render(self.main, 1, (0, 0, 0)) | ||||
|         self.box.blit(surface, [ | ||||
|             self.rect.width/2 - surface.get_rect().width/2, | ||||
|             self.rect.height/2 - surface.get_rect().height/2 | ||||
|         ]) | ||||
|         screen.blit(self.box, surface.get_rect(center = self.rect.center)) | ||||
| 
 | ||||
|         if self.draw_menu: | ||||
|             for i, text in enumerate(self.options): | ||||
|                 rect = self.rect.copy() | ||||
|                 rect.y += (i+1) * self.rect.height | ||||
|                 rect.x = self.rect.x | ||||
|                 #pygame.draw.rect(screen, self.color_option[1 if i == self.active_option else 0], rect, 0) | ||||
|                 #msg = self.font.render(text, 1, (0, 0, 0)) | ||||
|                 #screen.blit(msg, msg.get_rect(center = rect.center)) | ||||
|                 surface = self.font.render(text, 1, (0, 0, 0)) | ||||
|                 self.box.blit(surface, [ | ||||
|                     rect.width/2 - surface.get_rect().width/2, | ||||
|                     rect.height/2 - surface.get_rect().height/2 | ||||
|                 ]) | ||||
|                 screen.blit(self.box, rect) | ||||
| 
 | ||||
|     def update(self, event_list): | ||||
|         mpos = pygame.mouse.get_pos() | ||||
|         self.menu_active = self.rect.collidepoint(mpos) | ||||
|         self.active_option = -1 | ||||
|         for i in range(len(self.options)): | ||||
|             rect = self.rect.copy() | ||||
|             rect.y += (i+1) * self.rect.height | ||||
|             if rect.collidepoint(mpos): | ||||
|                 self.active_option = i | ||||
|                 break | ||||
| 
 | ||||
|         if not self.menu_active and self.active_option == -1: | ||||
|             self.draw_menu = False | ||||
|         #self.draw_menu = True | ||||
|         #return -1 | ||||
|         if pygame.mouse.get_pressed(num_buttons=3)[0]: | ||||
|             if self.menu_active: | ||||
|                 self.draw_menu = not self.draw_menu | ||||
|             elif self.draw_menu and self.active_option >= 0: | ||||
|                 self.draw_menu = False | ||||
|                 return self.active_option | ||||
|         return -1 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										79
									
								
								main.py
									
										
									
									
									
								
							
							
						
						|  | @ -27,20 +27,77 @@ def quitGame(): | |||
| def uwu(): | ||||
|     print('uwu') | ||||
| 
 | ||||
| def main(): | ||||
|     config = readConfig() | ||||
|     screen, clock, running, isblack, background, objects = setUp(config["screen"]) | ||||
|     WIDTH, HEIGHT = screen.get_size() | ||||
|     objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 + 72, 160, 64, 'medieval', "Exit game", quitGame)) | ||||
|     objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2, 160, 64, 'medieval', "Options", uwu)) | ||||
|     objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 - 72, 160, 64, 'medieval', "Play", uwu)) | ||||
|     print(objects) | ||||
| def options(screen, clock, running, background, isblack, WIDTH, HEIGHT): | ||||
|     objects = [] | ||||
|     # List that is displayed while selecting the window resolution level  | ||||
|     resolution = [("1920x1080", "1920x1080"),  | ||||
|                   ("1920x1200", "1920x1200"),  | ||||
|                   ("1280x720", "1280x720"),  | ||||
|                   ("2560x1440", "2560x1440"),  | ||||
|                   ("3840x2160", "3840x2160")] | ||||
|      | ||||
|     # This function displays the currently selected options  | ||||
| 
 | ||||
|     def printSettings():  | ||||
|         print("\n\n")  | ||||
|         # getting the data using "get_input_data" method of the Menu class  | ||||
|         settingsData = settings.get_input_data()  | ||||
| 
 | ||||
|         for key in settingsData.keys():  | ||||
|             print(f"{key}\t:\t{settingsData[key]}")  | ||||
|      | ||||
|     while running: | ||||
|         for event in pygame.event.get(): | ||||
|             if event.type == pygame.QUIT: | ||||
|                 running = False  | ||||
|          | ||||
|         # RENDER YOUR GAME HERE | ||||
|         with open(background, 'r') as i: | ||||
|             bg = pygame.image.load(i) | ||||
|             bg = pygame.transform.scale(bg, (WIDTH, HEIGHT)) | ||||
|         # fill the screen with an image to clear the screen | ||||
|         screen.blit(bg, (0, 0)) | ||||
|         for obj in objects: | ||||
|             obj.process(screen) | ||||
| 
 | ||||
|         # flip() the display to put your work on screen | ||||
|         pygame.display.flip() | ||||
| 
 | ||||
|         clock.tick(60)  # limits FPS to 60 | ||||
| 
 | ||||
| def menu(screen, clock, running, background, isblack, WIDTH, HEIGHT): | ||||
|     objects = [] | ||||
|     objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 + 72, 160, 64, 'medieval', 48, "Exit game", quitGame)) | ||||
|     objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2, 160, 64, 'medieval', 48, "Options", uwu)) | ||||
|     objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 - 72, 160, 64, 'medieval', 48, "Play", uwu)) | ||||
|     while running: | ||||
|         for event in pygame.event.get(): | ||||
|             if event.type == pygame.QUIT: | ||||
|                 running = False  | ||||
|         # RENDER YOUR GAME HERE | ||||
|         with open(background, 'r') as i: | ||||
|             bg = pygame.image.load(i) | ||||
|             bg = pygame.transform.scale(bg, (WIDTH, HEIGHT)) | ||||
|         # fill the screen with an image to clear the screen | ||||
|         screen.blit(bg, (0, 0)) | ||||
|         for obj in objects: | ||||
|             obj.process(screen) | ||||
| 
 | ||||
|         # flip() the display to put your work on screen | ||||
|         pygame.display.flip() | ||||
| 
 | ||||
|         clock.tick(60)  # limits FPS to 60 | ||||
| 
 | ||||
| def main(): | ||||
|     config = readConfig() | ||||
|     screen, clock, running, isblack, background, objects = setUp(config["screen"]) | ||||
|     WIDTH, HEIGHT = screen.get_size() | ||||
|     list1 = DropDown(50, 50, 128, 48, 'simple', 32, ['#881188', '#220044'], ['#991122', '#33ff11'], 'Test', ['Test 2', 'Test 17', '982']) | ||||
|      | ||||
|     while running: | ||||
|         for event in pygame.event.get(): | ||||
|             if event.type == pygame.QUIT: | ||||
|                 running = False  | ||||
|         #menu(screen, clock, running, background, isblack, WIDTH, HEIGHT) | ||||
|         if not isblack: | ||||
|             with open(background, 'r') as i: | ||||
|                 bg = pygame.image.load(i) | ||||
|  | @ -51,7 +108,11 @@ def main(): | |||
|         # RENDER YOUR GAME HERE | ||||
| 
 | ||||
|         else: | ||||
|             selected_option = list1.update(pygame.event.get()) | ||||
|             if selected_option >= 0: | ||||
|                 list1.main = list1.options[selected_option] | ||||
|             screen.fill('#000000') | ||||
|             list1.draw(screen) | ||||
|             for obj in objects: | ||||
|                 obj.process(screen) | ||||
|         # flip() the display to put your work on screen | ||||
|  |  | |||
 SpagettiFisch
						SpagettiFisch