forked from InfoProjekt/game
		
	Compare commits
	
		
			13 commits
		
	
	
		
			c9a98fb94c
			...
			1b6ccb17b0
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 1b6ccb17b0 | ||
|   | 6034a8382f | ||
|   | 746982641a | ||
| b3c7d87926 | |||
| 41f8b76b90 | |||
| 96c0a691b7 | |||
| 25f04f994f | |||
| e2ec301fce | |||
| 55b50531f9 | |||
| 0564d778a1 | |||
| 96b15fd425 | |||
| 44793f22a5 | |||
| 6fce7e0fd2 | 
					 4 changed files with 566 additions and 571 deletions
				
			
		
							
								
								
									
										
											BIN
										
									
								
								art/images/empty.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								art/images/empty.png
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 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): | ||||||
|  |  | ||||||
							
								
								
									
										4
									
								
								main.py
									
										
									
									
									
								
							
							
						
						
									
										4
									
								
								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,8 +87,7 @@ 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') |  | ||||||
| 
 | 
 | ||||||
|          |          | ||||||
|         else: |         else: | ||||||
|  |  | ||||||
							
								
								
									
										75
									
								
								viecher.py
									
										
									
									
									
								
							
							
						
						
									
										75
									
								
								viecher.py
									
										
									
									
									
								
							|  | @ -44,7 +44,7 @@ class Objects(): | ||||||
|         self.name = name |         self.name = name | ||||||
|         self.speed = ms |         self.speed = ms | ||||||
|         with open(f'art/images/{sprite}') as i: |         with open(f'art/images/{sprite}') as i: | ||||||
|             self.sprite = pg.image.load(i) |             self.sprite = pg.transform.scale2x(pg.image.load(i)) | ||||||
|         self.x = x |         self.x = x | ||||||
|         self.y = y |         self.y = y | ||||||
|         self.hidden = False |         self.hidden = False | ||||||
|  | @ -59,9 +59,9 @@ class Objects(): | ||||||
| 
 | 
 | ||||||
| class NPC(Objects): | class NPC(Objects): | ||||||
|     def __init__(self, name, ms, sprite, convo_act, x, y) -> None: |     def __init__(self, name, ms, sprite, convo_act, x, y) -> None: | ||||||
|         self.talking = False |  | ||||||
|         self.hidden = True |  | ||||||
|         super().__init__(name, ms, sprite, x, y) |         super().__init__(name, ms, sprite, x, y) | ||||||
|  |         self.talking = False | ||||||
|  |         self.hidden = False | ||||||
|         self.conversation = Convo('Hello, you can shoot fireballs with f now.', convo_act, 'person') |         self.conversation = Convo('Hello, you can shoot fireballs with f now.', convo_act, 'person') | ||||||
|      |      | ||||||
|     def talk(self, objects): |     def talk(self, objects): | ||||||
|  | @ -71,36 +71,16 @@ class NPC(Objects): | ||||||
|      |      | ||||||
|     def draw(self, screen): |     def draw(self, screen): | ||||||
|         super().draw(screen) |         super().draw(screen) | ||||||
|         if self.talking == True: |         if self.talking: | ||||||
|             self.conversation.draw(screen) |             self.conversation.draw(screen) | ||||||
|      |      | ||||||
|     def update(self, keys, objects): |     def update(self, keys, 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) | ||||||
|      |      | ||||||
|  | @ -368,7 +336,7 @@ class Weapons(Objects): | ||||||
|         pos = vec(1,0) |         pos = vec(1,0) | ||||||
|         angle = pos.angle_to(moveto) |         angle = pos.angle_to(moveto) | ||||||
|         with open(f'art/images/{sprite}') as i: |         with open(f'art/images/{sprite}') as i: | ||||||
|             self.sprite = pg.transform.rotate(pg.image.load(i), -angle) |             self.sprite = pg.transform.scale2x(pg.transform.rotate(pg.image.load(i), -angle)) | ||||||
|      |      | ||||||
|     def die(self, objects, kills): |     def die(self, objects, kills): | ||||||
|         touches = pg.sprite.spritecollideany(self, objects[0] + objects[1]) |         touches = pg.sprite.spritecollideany(self, objects[0] + objects[1]) | ||||||
|  | @ -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=150) -> 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