forked from InfoProjekt/game
		
	Development #8
					 4 changed files with 561 additions and 566 deletions
				
			
		
							
								
								
									
										
											BIN
										
									
								
								art/images/empty.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								art/images/empty.png
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 68 B After Width: | Height: | Size: 68 B | 
							
								
								
									
										24
									
								
								classes.py
									
										
									
									
									
								
							
							
						
						
									
										24
									
								
								classes.py
									
										
									
									
									
								
							|  | @ -75,6 +75,30 @@ class Button(): | ||||||
|         ]) |         ]) | ||||||
|         screen.blit(self.box, self.buttonRect) |         screen.blit(self.box, self.buttonRect) | ||||||
| 
 | 
 | ||||||
|  | class Label(): | ||||||
|  |     def __init__(self, x, y, width, height, text, font='simple', font_size=20, font_color = '#1E90FF', sprite = 'label.png') -> None: | ||||||
|  |         self.x = x | ||||||
|  |         self.y = y | ||||||
|  |         self.width = width | ||||||
|  |         self.height = height | ||||||
|  |         self.font = pygame.font.Font(f'fonts/{fonts[font]}', font_size) | ||||||
|  |         self.hidden = False | ||||||
|  |         with open(f'art/images/{sprite}', 'r') as tb: | ||||||
|  |             self.box = pygame.image.load(tb) | ||||||
|  |             self.box = pygame.transform.scale(self.box, (width, height)) | ||||||
|  |         self.labelRect = pygame.Rect(self.x, self.y, self.width, self.height) | ||||||
|  |         self.labelSurf = self.font.render(text, True, font_color) | ||||||
|  | 
 | ||||||
|  |     def draw(self, screen): | ||||||
|  |         if self.hidden: | ||||||
|  |             return | ||||||
|  |         self.box.blit(self.labelSurf, [ | ||||||
|  |             self.labelRect.width / 2 - self.labelSurf.get_rect().width / 2, | ||||||
|  |             self.labelRect.height / 2 - self.labelSurf.get_rect().height / 2 | ||||||
|  |         ]) | ||||||
|  |         screen.blit(self.box, self.labelRect) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| class DropDown(): | class DropDown(): | ||||||
|     def __init__(self, x, y, width, height, font, font_size, color_menu, color_option, main, options): |     def __init__(self, x, y, width, height, font, font_size, color_menu, color_option, main, options): | ||||||
|  |  | ||||||
							
								
								
									
										2
									
								
								main.py
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								main.py
									
										
									
									
									
								
							|  | @ -14,7 +14,6 @@ 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() | ||||||
|      |  | ||||||
|     return screen, clock, True, True, "start.png", [] |     return screen, clock, True, True, "start.png", [] | ||||||
| 
 | 
 | ||||||
| def readConfig(): | def readConfig(): | ||||||
|  | @ -88,7 +87,6 @@ def play(screen, clock, running, background, isblack, WIDTH, HEIGHT): | ||||||
|                 npc.update(pygame.key.get_pressed(), objects) |                 npc.update(pygame.key.get_pressed(), objects) | ||||||
|                 npc.draw(screen) |                 npc.draw(screen) | ||||||
|              |              | ||||||
|             if objects[1] ==[]: |  | ||||||
|             objects[0][0].book.addspell('windslash') |             objects[0][0].book.addspell('windslash') | ||||||
| 
 | 
 | ||||||
|          |          | ||||||
|  |  | ||||||
							
								
								
									
										65
									
								
								viecher.py
									
										
									
									
									
								
							
							
						
						
									
										65
									
								
								viecher.py
									
										
									
									
									
								
							|  | @ -78,29 +78,9 @@ class NPC(Objects): | ||||||
|         if self.talking: |         if self.talking: | ||||||
|             self.conversation.update(keys, objects) |             self.conversation.update(keys, objects) | ||||||
| 
 | 
 | ||||||
| class Convo(): | class Convo(Label): | ||||||
|     def __init__(self, text, convo_act, person, x = 140, y = 600, width = 1000, height = 100, font='simple', font_size = 20) -> None: |     def __init__(self, text, convo_act, person, x = 140, y = 600, width = 1000, height = 100, font='simple', font_size = 20) -> None: | ||||||
|         self.x = x |         super().__init__(x, y, width, height, text, font, font_size) | ||||||
|         self.y = y |  | ||||||
|         self.width = width |  | ||||||
|         self.height = height |  | ||||||
|         self.hidden = False |  | ||||||
|         self.font = pg.font.Font(f'fonts/{fonts[font]}', font_size) |  | ||||||
|         with open('art/images/label.png', 'r') as tb: |  | ||||||
|             self.box = pg.image.load(tb) |  | ||||||
|             self.box = pg.transform.scale(self.box, (width, height)) |  | ||||||
|         self.labelRect = pg.Rect(self.x, self.y, self.width, self.height) |  | ||||||
|         self.labelSurf = self.font.render(text, True, '#1E90FF') |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|     def draw(self, screen): |  | ||||||
|         if self.hidden: |  | ||||||
|             return |  | ||||||
|         self.box.blit(self.labelSurf, [ |  | ||||||
|             self.labelRect.width/2 - self.labelSurf.get_rect().width/2, |  | ||||||
|             self.labelRect.height/2 - self.labelSurf.get_rect().height/2 |  | ||||||
|         ]) |  | ||||||
|         screen.blit(self.box, self.labelRect) |  | ||||||
|      |      | ||||||
|     def update(self, keys, objects): |     def update(self, keys, objects): | ||||||
|         if keys[pg.K_SPACE]: |         if keys[pg.K_SPACE]: | ||||||
|  | @ -130,7 +110,7 @@ class MainCharacter(Fighter): | ||||||
|         super().__init__(name, ms, sprite, x, y, health, damage, level, asp, atr) |         super().__init__(name, ms, sprite, x, y, health, damage, level, asp, atr) | ||||||
|         self.book = Book(0, 0, [], None, None) |         self.book = Book(0, 0, [], None, None) | ||||||
|         self.talking = False |         self.talking = False | ||||||
|         self.level = Level(1000, 38, level, 150, 40, f'will to live: {level}%', 'simple', 20) |         self.level = Level(1000, 38, 150, 40, f'will to live: {level}%', 'simple', 20) | ||||||
|         self.health = Hearts(health, sprite=['fullheart.png', 'fullheart.png', 'fullheart.png', 'fullheart.png', 'fullheart.png'], x=900, y= 50, hurtCooldown=self.hurtCooldown) |         self.health = Hearts(health, sprite=['fullheart.png', 'fullheart.png', 'fullheart.png', 'fullheart.png', 'fullheart.png'], x=900, y= 50, hurtCooldown=self.hurtCooldown) | ||||||
|      |      | ||||||
|     def draw(self, screen): |     def draw(self, screen): | ||||||
|  | @ -267,27 +247,9 @@ class Hearts(): | ||||||
|                 self.sprite.append(pg.image.load(i)) |                 self.sprite.append(pg.image.load(i)) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class Level(): | class Level(Label): | ||||||
|     def __init__(self, x, y, level, width, height, text, font, font_size) -> None: |     def __init__(self, x, y, width, height, text, font, font_size) -> None: | ||||||
|         self.x = x |         super().__init__(x, y, width, height, text, font, font_size) | ||||||
|         self.y = y |  | ||||||
|         self.level = level |  | ||||||
|         self.width = width |  | ||||||
|         self.height = height |  | ||||||
|         self.font = pg.font.Font(f'fonts/{fonts[font]}', font_size) |  | ||||||
|         self.hidden = False |  | ||||||
|         with open('art/images/label.png', 'r') as tb: |  | ||||||
|             self.box = pg.image.load(tb) |  | ||||||
|             self.box = pg.transform.scale(self.box, (width, height)) |  | ||||||
|         self.labelRect = pg.Rect(self.x, self.y, self.width, self.height) |  | ||||||
|         self.labelSurf = self.font.render(text, True, '#1E90FF') |  | ||||||
| 
 |  | ||||||
|     def draw(self, screen): |  | ||||||
|         self.box.blit(self.labelSurf, [ |  | ||||||
|             self.labelRect.width / 2 - self.labelSurf.get_rect().width / 2, |  | ||||||
|             self.labelRect.height / 2 - self.labelSurf.get_rect().height / 2 |  | ||||||
|         ]) |  | ||||||
|         screen.blit(self.box, self.labelRect) |  | ||||||
| 
 | 
 | ||||||
| class Book(): | class Book(): | ||||||
|     def __init__(self, x, y, spells, current_spell, current_shield) -> None: |     def __init__(self, x, y, spells, current_spell, current_shield) -> None: | ||||||
|  | @ -300,14 +262,20 @@ class Book(): | ||||||
|         self.rect = pg.Rect(self.x, self.y, self.sprite.get_width(), self.sprite.get_height()) |         self.rect = pg.Rect(self.x, self.y, self.sprite.get_width(), self.sprite.get_height()) | ||||||
|         self.sp_list = spells |         self.sp_list = spells | ||||||
|         self.current_sp = current_spell |         self.current_sp = current_spell | ||||||
|  |         self.labels = [Label(100, 100, 500, 50, "Dear User, ", font_color='#000000', sprite='empty.png'), | ||||||
|  |                        Label(100, 150, 500, 50, "this book will help you to survive.", font_color='#000000', sprite='empty.png'), | ||||||
|  |                        Label(100, 200, 500, 50, "Click on a picture to choose your spell.", font_color='#000000', sprite='empty.png'), | ||||||
|  |                        Label(100, 250, 500, 50, "Talk to fairies to unlock new spells!", font_color='#000000', sprite='empty.png')] | ||||||
|         self.buttons=[] |         self.buttons=[] | ||||||
|         self.buttons_height = 150 |         self.buttons_height = 400 | ||||||
|      |      | ||||||
|     def draw(self, screen): |     def draw(self, screen): | ||||||
|         if self.hidden: |         if self.hidden: | ||||||
|             return |             return | ||||||
|         self.rect.x, self.rect.y = self.x, self.y |         self.rect.x, self.rect.y = self.x, self.y | ||||||
|         screen.blit(self.sprite, self.rect) |         screen.blit(self.sprite, self.rect) | ||||||
|  |         for label in self.labels: | ||||||
|  |             label.draw(screen) | ||||||
|         for button in self.buttons: |         for button in self.buttons: | ||||||
|             button.update(screen) |             button.update(screen) | ||||||
|      |      | ||||||
|  | @ -398,13 +366,18 @@ class Fireball(Spells): | ||||||
|         self.die(objects, Mobs) |         self.die(objects, Mobs) | ||||||
| 
 | 
 | ||||||
| class Windslash(Spells): | class Windslash(Spells): | ||||||
|     def __init__(self, name, ms, x, y, moveto, damage, sprite = 'windslash.png', life_ticks=250) -> None: |     def __init__(self, name, ms, x, y, moveto, damage, sprite = 'windslash.png', life_ticks=500) -> None: | ||||||
|         super().__init__(name, ms, sprite, x, y, moveto, damage, life_ticks) |         super().__init__(name, ms, sprite, x, y, moveto, damage, life_ticks) | ||||||
|      |      | ||||||
|     def update(self, objects): |     def update(self, objects): | ||||||
|         self.move(objects) |         self.move(objects) | ||||||
|         self.die(objects, Mobs) |         self.die(objects, Mobs) | ||||||
|      |      | ||||||
|  |     def move(self, objects): | ||||||
|  |         super().move(objects) | ||||||
|  |         self.moveto = self.moveto.rotate(5) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| class Arrow(Weapons): | class Arrow(Weapons): | ||||||
|     def __init__(self, name, ms, x, y, moveto, damage, sprite = 'arrow.png', life_ticks=5000) -> None: |     def __init__(self, name, ms, x, y, moveto, damage, sprite = 'arrow.png', life_ticks=5000) -> None: | ||||||
|         super().__init__(name, ms, sprite, x, y, moveto, damage, life_ticks) |         super().__init__(name, ms, sprite, x, y, moveto, damage, life_ticks) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue