forked from InfoProjekt/game
		
	Compare commits
	
		
			2 commits
		
	
	
		
			51a287ba66
			...
			5123b19cb0
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 5123b19cb0 | ||
|   | f8e491f2a5 | 
					 46 changed files with 78 additions and 15 deletions
				
			
		
							
								
								
									
										
											BIN
										
									
								
								art/textbox.png
									
										
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								art/textbox.png
									
										
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 607 B After Width: | Height: | Size: 644 B | 
							
								
								
									
										68
									
								
								classes.py
									
										
									
									
									
								
							
							
						
						
									
										68
									
								
								classes.py
									
										
									
									
									
								
							|  | @ -1,9 +1,41 @@ | ||||||
| import pygame | import pygame | ||||||
| 
 | 
 | ||||||
| font = pygame.font.SysFont('Arial', 40) | pygame.font.init() | ||||||
|  | fonts = { | ||||||
|  |     'medieval': 'medieval.ttf', | ||||||
|  |     'minecraft': 'Minecraft Evenings.otf', | ||||||
|  |     '3dpixel': '3D-Pixel.ttf', | ||||||
|  |     '8bit': '8bitlim.ttf', | ||||||
|  |     '8bito': '8blimro.ttf', | ||||||
|  |     'arcade': 'ARCADECLASSIC.ttf', | ||||||
|  |     'modern_game': 'astron boy video.otf', | ||||||
|  |     'modern': 'astron boy.otf', | ||||||
|  |     'wonder': 'Beyond Wonderland.ttf', | ||||||
|  |     'curved': 'Digitag.ttf', | ||||||
|  |     'simple': 'DisposableDroidBB.ttf', | ||||||
|  |     'rounded': 'dpcomic.ttf', | ||||||
|  |     'playfull': 'Endalian Script.ttf', | ||||||
|  |     'blocky': 'FREAKSOFNATURE.ttf', | ||||||
|  |     'catchy': 'Future TimeSplitters.otf', | ||||||
|  |     'simple_wide': 'Halo3.ttf', | ||||||
|  |     'simple_fat': 'INVASION2000.ttf', | ||||||
|  |     'very_gamy': 'ka1.ttf', | ||||||
|  |     'simple_round': 'Karma Suture.otf', | ||||||
|  |     'mono': 'manaspc.ttf', | ||||||
|  |     'damaged': 'Merchant Copy.ttf', | ||||||
|  |     'big_natural': 'MorialCitadel.TTF', | ||||||
|  |     'spacy': 'nasalization-rg.otf', | ||||||
|  |     'sci-fi': 'neuropol.otf', | ||||||
|  |     'hollow_big_edge': 'papercut.ttf', | ||||||
|  |     'space_shuttle': 'pdark.ttf', | ||||||
|  |     'thin': 'PixelFJVerdana12pt.ttf', | ||||||
|  |     'random': 'Seattle Avenue.ttf', | ||||||
|  |     'pixel': 'yoster.ttf' | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| class Button(): | class Button(): | ||||||
|     def __init__(self, x, y, width, height, buttonText='Button', onclickFunction=None, onePress=False): |     def __init__(self, x, y, width, height, font, buttonText='Button', onclickFunction=None, onePress=False): | ||||||
|  |         font = pygame.font.Font(f'fonts/{fonts[font]}', 48) | ||||||
|         self.x = x |         self.x = x | ||||||
|         self.y = y |         self.y = y | ||||||
|         self.width = width |         self.width = width | ||||||
|  | @ -12,14 +44,30 @@ class Button(): | ||||||
|         self.onePress = onePress |         self.onePress = onePress | ||||||
|         self.alreadyPressed = False |         self.alreadyPressed = False | ||||||
| 
 | 
 | ||||||
|         self.fillColors = { |         with open('art/textbox.png', 'r') as tb: | ||||||
|             'normal': '#ffffff', |             self.box = pygame.image.load(tb) | ||||||
|             'hover': '#666666', |             self.box = pygame.transform.scale(self.box, (width, height)) | ||||||
|             'pressed': '#333333', | 
 | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|         self.buttonSurface = pygame.Surface((self.width, self.height)) |  | ||||||
|         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, (20, 20, 20)) |         self.buttonSurf = font.render(buttonText, True, '#baab80') | ||||||
|         return self | 
 | ||||||
|  |     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: | ||||||
|  |                     self.onclickFunction() | ||||||
|  |                     self.alreadyPressed = True | ||||||
|  |             else: | ||||||
|  |                 self.alreadyPressed = False | ||||||
|  |         self.box.blit(self.buttonSurf, [ | ||||||
|  |             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) | ||||||
							
								
								
									
										
											BIN
										
									
								
								fonts/3D-Pixel.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/3D-Pixel.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/8bitlim.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/8bitlim.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/8bitlimo.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/8bitlimo.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/8bitlimr.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/8bitlimr.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/8blimro.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/8blimro.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/ARCADECLASSIC.TTF
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/ARCADECLASSIC.TTF
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/Beyond Wonderland.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/Beyond Wonderland.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/Digitag.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/Digitag.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/DisposableDroidBB.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/DisposableDroidBB.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/DisposableDroidBB_bld.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/DisposableDroidBB_bld.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/DisposableDroidBB_bldital.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/DisposableDroidBB_bldital.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/DisposableDroidBB_ital.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/DisposableDroidBB_ital.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/Endalian Script.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/Endalian Script.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/FREAKSOFNATURE.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/FREAKSOFNATURE.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/FREAKSOFNATUREMASSIVE.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/FREAKSOFNATUREMASSIVE.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/Future TimeSplitters.otf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/Future TimeSplitters.otf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/Halo3.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/Halo3.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/INVASION2000.TTF
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/INVASION2000.TTF
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/Karma Future.otf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/Karma Future.otf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/Karma Suture.otf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/Karma Suture.otf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/Merchant Copy Doublesize.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/Merchant Copy Doublesize.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/Merchant Copy Wide.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/Merchant Copy Wide.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/Merchant Copy.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/Merchant Copy.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/Minecraft Evenings.otf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/Minecraft Evenings.otf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/MoriaCitadel.TTF
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/MoriaCitadel.TTF
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/PixelFJVerdana12pt.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/PixelFJVerdana12pt.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/Seattle Avenue.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/Seattle Avenue.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/SeattleAvenue.otf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/SeattleAvenue.otf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/astron boy italic.otf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/astron boy italic.otf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/astron boy video.otf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/astron boy video.otf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/astron boy wonder.otf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/astron boy wonder.otf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/astron boy.otf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/astron boy.otf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/dpcomic.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/dpcomic.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/ka1.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/ka1.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/kirbyss.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/kirbyss.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/manaspc.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/manaspc.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/medieval.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/medieval.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/nasalization-rg.otf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/nasalization-rg.otf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/neuropol.otf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/neuropol.otf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/papercut.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/papercut.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/pcsenior.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/pcsenior.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/pdark.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/pdark.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								fonts/yoster.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								fonts/yoster.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										25
									
								
								main.py
									
										
									
									
									
								
							
							
						
						
									
										25
									
								
								main.py
									
										
									
									
									
								
							|  | @ -2,6 +2,7 @@ import pygame | ||||||
| import sys | import sys | ||||||
| import json | import json | ||||||
| import time | import time | ||||||
|  | from classes import * | ||||||
| 
 | 
 | ||||||
| def setUp(config): | def setUp(config): | ||||||
|     pygame.init() |     pygame.init() | ||||||
|  | @ -10,18 +11,30 @@ 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() | ||||||
|     with open('art/textbox.png', 'r') as tb: |      | ||||||
|         box = pygame.image.load(tb) |     return screen, clock, True, True, "start.png", [] | ||||||
|     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: | ||||||
|         json_data = c.read() |         json_data = c.read() | ||||||
|     return json.loads(json_data) |     return json.loads(json_data) | ||||||
| 
 | 
 | ||||||
|  | def quitGame(): | ||||||
|  |     #save progress somehow, if needed | ||||||
|  |     pygame.quit() | ||||||
|  |     sys.exit() | ||||||
|  | 
 | ||||||
|  | def uwu(): | ||||||
|  |     print('uwu') | ||||||
|  | 
 | ||||||
| def main(): | def main(): | ||||||
|     config = readConfig() |     config = readConfig() | ||||||
|     screen, clock, running, background, isblack, box = setUp(config["screen"]) |     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) | ||||||
|      |      | ||||||
|     while running: |     while running: | ||||||
|         for event in pygame.event.get(): |         for event in pygame.event.get(): | ||||||
|  | @ -31,7 +44,7 @@ def main(): | ||||||
|         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) | ||||||
|                 bg = pygame.transform.scale(bg, screen.get_size()) |                 bg = pygame.transform.scale(bg, (WIDTH, HEIGHT)) | ||||||
|             # 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.blit(bg, (0, 0)) |             screen.blit(bg, (0, 0)) | ||||||
| 
 | 
 | ||||||
|  | @ -39,6 +52,8 @@ def main(): | ||||||
| 
 | 
 | ||||||
|         else: |         else: | ||||||
|             screen.fill('#000000') |             screen.fill('#000000') | ||||||
|  |             for obj in objects: | ||||||
|  |                 obj.process(screen) | ||||||
|         # flip() the display to put your work on screen |         # flip() the display to put your work on screen | ||||||
|         pygame.display.flip() |         pygame.display.flip() | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue