Development #57
							
								
								
									
										0
									
								
								InfoProjekt.xlsx → .idea/InfoProjekt.xlsx
									
										
									
										generated
									
									
									
								
							
							
						
						
							
								
								
									
										0
									
								
								ideas.txt → .idea/ideas.txt
									
										
									
										generated
									
									
									
								
							
							
						
						
							
								
								
									
										0
									
								
								storyline.txt → .idea/storyline.txt
									
										
									
										generated
									
									
									
								
							
							
						
						| 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 | 
| After Width: | Height: | Size: 629 B | 
| After Width: | Height: | Size: 724 B | 
| After Width: | Height: | Size: 703 B | 
| After Width: | Height: | Size: 651 B | 
| After Width: | Height: | Size: 706 B | 
| After Width: | Height: | Size: 694 B | 
| After Width: | Height: | Size: 731 B | 
| After Width: | Height: | Size: 719 B | 
| After Width: | Height: | Size: 657 B | 
| After Width: | Height: | Size: 974 B | 
| After Width: | Height: | Size: 808 B | 
| After Width: | Height: | Size: 38 KiB | 
| After Width: | Height: | Size: 644 B | 
							
								
								
									
										73
									
								
								classes.py
									
										
									
									
									
								
							
							
						
						|  | @ -34,8 +34,8 @@ fonts = { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| class Button(): | class Button(): | ||||||
|     def __init__(self, x, y, width, height, font, buttonText='Button', onclickFunction=None, onePress=False): |     def __init__(self, x, y, width, height, font, font_size, buttonText='Button', onclickFunction=None, onePress=False): | ||||||
|         font = pygame.font.Font(f'fonts/{fonts[font]}', 48) |         self.font = pygame.font.Font(f'fonts/{fonts[font]}', font_size) | ||||||
|         self.x = x |         self.x = x | ||||||
|         self.y = y |         self.y = y | ||||||
|         self.width = width |         self.width = width | ||||||
|  | @ -51,14 +51,12 @@ class Button(): | ||||||
| 
 | 
 | ||||||
|         self.buttonRect = pygame.Rect(self.x, self.y, self.width, self.height) |         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): |     def process(self, screen): | ||||||
|         mousePos = pygame.mouse.get_pos() |         mousePos = pygame.mouse.get_pos() | ||||||
|         if self.buttonRect.collidepoint(mousePos): |         if self.buttonRect.collidepoint(mousePos): | ||||||
|             #self.buttonSurface.fill(self.fillColors['hover']) |  | ||||||
|             if pygame.mouse.get_pressed(num_buttons=3)[0]: |             if pygame.mouse.get_pressed(num_buttons=3)[0]: | ||||||
|                 #self.buttonSurface.fill(self.fillColors['pressed']) |  | ||||||
|                 if self.onePress: |                 if self.onePress: | ||||||
|                     self.onclickFunction() |                     self.onclickFunction() | ||||||
|                 elif not self.alreadyPressed: |                 elif not self.alreadyPressed: | ||||||
|  | @ -71,3 +69,68 @@ class Button(): | ||||||
|             self.buttonRect.height/2 - self.buttonSurf.get_rect().height/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 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |  | ||||||
							
								
								
									
										77
									
								
								main.py
									
										
									
									
									
								
							
							
						
						|  | @ -27,20 +27,77 @@ def quitGame(): | ||||||
| def uwu(): | def uwu(): | ||||||
|     print('uwu') |     print('uwu') | ||||||
| 
 | 
 | ||||||
| def main(): | def options(screen, clock, running, background, isblack, WIDTH, HEIGHT): | ||||||
|     config = readConfig() |     objects = [] | ||||||
|     screen, clock, running, isblack, background, objects = setUp(config["screen"]) |     # List that is displayed while selecting the window resolution level  | ||||||
|     WIDTH, HEIGHT = screen.get_size() |     resolution = [("1920x1080", "1920x1080"),  | ||||||
|     objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 + 72, 160, 64, 'medieval', "Exit game", quitGame)) |                   ("1920x1200", "1920x1200"),  | ||||||
|     objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2, 160, 64, 'medieval', "Options", uwu)) |                   ("1280x720", "1280x720"),  | ||||||
|     objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 - 72, 160, 64, 'medieval', "Play", uwu)) |                   ("2560x1440", "2560x1440"),  | ||||||
|     print(objects) |                   ("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: |     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  | ||||||
|  |         # 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: |         if not isblack: | ||||||
|             with open(background, 'r') as i: |             with open(background, 'r') as i: | ||||||
|                 bg = pygame.image.load(i) |                 bg = pygame.image.load(i) | ||||||
|  | @ -51,7 +108,11 @@ def main(): | ||||||
|         # RENDER YOUR GAME HERE |         # RENDER YOUR GAME HERE | ||||||
| 
 | 
 | ||||||
|         else: |         else: | ||||||
|  |             selected_option = list1.update(pygame.event.get()) | ||||||
|  |             if selected_option >= 0: | ||||||
|  |                 list1.main = list1.options[selected_option] | ||||||
|             screen.fill('#000000') |             screen.fill('#000000') | ||||||
|  |             list1.draw(screen) | ||||||
|             for obj in objects: |             for obj in objects: | ||||||
|                 obj.process(screen) |                 obj.process(screen) | ||||||
|         # flip() the display to put your work on screen |         # flip() the display to put your work on screen | ||||||
|  |  | ||||||