Compare commits
	
		
			No commits in common. "b3c7d879269422be9738f73ebffbf45a45eb2678" and "55b50531f91f42799897cca874969ef59862158c" have entirely different histories.
		
	
	
		
			b3c7d87926
			...
			55b50531f9
		
	
		
					 4 changed files with 934 additions and 929 deletions
				
			
		
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 68 B | 
							
								
								
									
										24
									
								
								classes.py
									
										
									
									
									
								
							
							
						
						
									
										24
									
								
								classes.py
									
										
									
									
									
								
							|  | @ -75,30 +75,6 @@ class Button(): | |||
|         ]) | ||||
|         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(): | ||||
|     def __init__(self, x, y, width, height, font, font_size, color_menu, color_option, main, options): | ||||
|  |  | |||
							
								
								
									
										2
									
								
								main.py
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								main.py
									
										
									
									
									
								
							|  | @ -14,6 +14,7 @@ def setUp(config): | |||
|     else: | ||||
|         screen = pygame.display.set_mode(config["res"]) | ||||
|     clock = pygame.time.Clock() | ||||
|      | ||||
|     return screen, clock, True, True, "start.png", [] | ||||
| 
 | ||||
| def readConfig(): | ||||
|  | @ -87,6 +88,7 @@ def play(screen, clock, running, background, isblack, WIDTH, HEIGHT): | |||
|                 npc.update(pygame.key.get_pressed(), objects) | ||||
|                 npc.draw(screen) | ||||
|              | ||||
|             if objects[1] ==[]: | ||||
|                 objects[0][0].book.addspell('windslash') | ||||
| 
 | ||||
|          | ||||
|  |  | |||
							
								
								
									
										65
									
								
								viecher.py
									
										
									
									
									
								
							
							
						
						
									
										65
									
								
								viecher.py
									
										
									
									
									
								
							|  | @ -78,9 +78,29 @@ class NPC(Objects): | |||
|         if self.talking: | ||||
|             self.conversation.update(keys, objects) | ||||
| 
 | ||||
| class Convo(Label): | ||||
| class Convo(): | ||||
|     def __init__(self, text, convo_act, person, x = 140, y = 600, width = 1000, height = 100, font='simple', font_size = 20) -> None: | ||||
|         super().__init__(x, y, width, height, text, font, font_size) | ||||
|         self.x = x | ||||
|         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): | ||||
|         if keys[pg.K_SPACE]: | ||||
|  | @ -110,7 +130,7 @@ class MainCharacter(Fighter): | |||
|         super().__init__(name, ms, sprite, x, y, health, damage, level, asp, atr) | ||||
|         self.book = Book(0, 0, [], None, None) | ||||
|         self.talking = False | ||||
|         self.level = Level(1000, 38, 150, 40, f'will to live: {level}%', 'simple', 20) | ||||
|         self.level = Level(1000, 38, level, 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) | ||||
|      | ||||
|     def draw(self, screen): | ||||
|  | @ -247,9 +267,27 @@ class Hearts(): | |||
|                 self.sprite.append(pg.image.load(i)) | ||||
| 
 | ||||
| 
 | ||||
| class Level(Label): | ||||
|     def __init__(self, x, y, width, height, text, font, font_size) -> None: | ||||
|         super().__init__(x, y, width, height, text, font, font_size) | ||||
| class Level(): | ||||
|     def __init__(self, x, y, level, width, height, text, font, font_size) -> None: | ||||
|         self.x = x | ||||
|         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(): | ||||
|     def __init__(self, x, y, spells, current_spell, current_shield) -> None: | ||||
|  | @ -262,20 +300,14 @@ class Book(): | |||
|         self.rect = pg.Rect(self.x, self.y, self.sprite.get_width(), self.sprite.get_height()) | ||||
|         self.sp_list = spells | ||||
|         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_height = 400 | ||||
|         self.buttons_height = 150 | ||||
|      | ||||
|     def draw(self, screen): | ||||
|         if self.hidden: | ||||
|             return | ||||
|         self.rect.x, self.rect.y = self.x, self.y | ||||
|         screen.blit(self.sprite, self.rect) | ||||
|         for label in self.labels: | ||||
|             label.draw(screen) | ||||
|         for button in self.buttons: | ||||
|             button.update(screen) | ||||
|      | ||||
|  | @ -366,18 +398,13 @@ class Fireball(Spells): | |||
|         self.die(objects, Mobs) | ||||
| 
 | ||||
| class Windslash(Spells): | ||||
|     def __init__(self, name, ms, x, y, moveto, damage, sprite = 'windslash.png', life_ticks=500) -> None: | ||||
|     def __init__(self, name, ms, x, y, moveto, damage, sprite = 'windslash.png', life_ticks=150) -> None: | ||||
|         super().__init__(name, ms, sprite, x, y, moveto, damage, life_ticks) | ||||
|      | ||||
|     def update(self, objects): | ||||
|         self.move(objects) | ||||
|         self.die(objects, Mobs) | ||||
| 
 | ||||
|     def move(self, objects): | ||||
|         super().move(objects) | ||||
|         self.moveto = self.moveto.rotate(5) | ||||
| 
 | ||||
| 
 | ||||
| class Arrow(Weapons): | ||||
|     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) | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue