storyline #79
					 4 changed files with 30 additions and 12 deletions
				
			
		
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 68 B After Width: | Height: | Size: 87 B | 
|  | @ -85,6 +85,7 @@ class Label(): | ||||||
|         self.font_color = font_color |         self.font_color = font_color | ||||||
|         self.text = text |         self.text = text | ||||||
|         self.hidden = False |         self.hidden = False | ||||||
|  |         self.sprite = sprite | ||||||
|         with open(f'art/images/box/{sprite}', 'r') as tb: |         with open(f'art/images/box/{sprite}', 'r') as tb: | ||||||
|             self.box = pygame.image.load(tb) |             self.box = pygame.image.load(tb) | ||||||
|             self.box = pygame.transform.scale(self.box, (width, height)) |             self.box = pygame.transform.scale(self.box, (width, height)) | ||||||
|  | @ -93,6 +94,9 @@ class Label(): | ||||||
|     def draw(self, screen): |     def draw(self, screen): | ||||||
|         if self.hidden: |         if self.hidden: | ||||||
|             return |             return | ||||||
|  |         with open(f'art/images/box/{self.sprite}', 'r') as tb: | ||||||
|  |             self.box = pygame.image.load(tb) | ||||||
|  |             self.box = pygame.transform.scale(self.box, (self.width,self.height)) | ||||||
|         self.labelRect = pygame.Rect(self.x, self.y, self.width, self.height) |         self.labelRect = pygame.Rect(self.x, self.y, self.width, self.height) | ||||||
|         self.labelSurf = self.font.render(self.text, True, self.font_color) |         self.labelSurf = self.font.render(self.text, True, self.font_color) | ||||||
|         self.box.blit(self.labelSurf, [ |         self.box.blit(self.labelSurf, [ | ||||||
|  |  | ||||||
							
								
								
									
										2
									
								
								main.py
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								main.py
									
										
									
									
									
								
							|  | @ -42,7 +42,7 @@ def genRooms(WIDTH, HEIGHT, type:str, objects:list): | ||||||
|          |          | ||||||
| def play(screen, clock, running, background, isblack, WIDTH, HEIGHT): | def play(screen, clock, running, background, isblack, WIDTH, HEIGHT): | ||||||
|     main = [herbert] |     main = [herbert] | ||||||
|     mobs = [Skeleton(i, random.randint(40, 60), random.randint(50, WIDTH - 50), random.randint(50, HEIGHT - 50), 5, 1, 1, 1, 200) for i in range(0,random.randint(2, 8))]+[Zombie(i, random.randint(40, 60), random.randint(50, WIDTH-50), random.randint(50, HEIGHT-50), 5, 1, 1, 1, 100) for i in range(0,random.randint(2, 8))] |     mobs = [Skeleton(i, random.randint(40, 60), random.randint(50, WIDTH - 50), random.randint(50, HEIGHT - 50), 5, 1, 1, 1, 200) for i in range(0,random.randint(2, 5))]+[Zombie(i, random.randint(40, 60), random.randint(50, WIDTH-50), random.randint(50, HEIGHT-50), 5, 1, 1, 1, 25) for i in range(0,random.randint(2, 5))] | ||||||
|     weapons = [] |     weapons = [] | ||||||
|     others = [] |     others = [] | ||||||
|     npcs = [] |     npcs = [] | ||||||
|  |  | ||||||
							
								
								
									
										36
									
								
								viecher.py
									
										
									
									
									
								
							
							
						
						
									
										36
									
								
								viecher.py
									
										
									
									
									
								
							|  | @ -33,7 +33,7 @@ fonts = { | ||||||
|     'spacy': 'nasalization-rg.otf', |     'spacy': 'nasalization-rg.otf', | ||||||
|     'sci-fi': 'neuropol.otf', |     'sci-fi': 'neuropol.otf', | ||||||
|     'hollow_big_edge': 'papercut.ttf', |     'hollow_big_edge': 'papercut.ttf', | ||||||
|     'space_shuttle': 'pdark.ttf', |     'f_shuttle': 'pdark.ttf', | ||||||
|     'thin': 'PixelFJVerdana12pt.ttf', |     'thin': 'PixelFJVerdana12pt.ttf', | ||||||
|     'random': 'Seattle Avenue.ttf', |     'random': 'Seattle Avenue.ttf', | ||||||
|     'pixel': 'yoster.ttf' |     'pixel': 'yoster.ttf' | ||||||
|  | @ -75,13 +75,13 @@ class NPC(Objects): | ||||||
|             self.conversation.draw(screen) |             self.conversation.draw(screen) | ||||||
|      |      | ||||||
|     def update(self, keys, objects):  |     def update(self, keys, objects):  | ||||||
|         if  self.lastUpdate + 200 < pg.time.get_ticks(): |         if self.lastUpdate + 150 < pg.time.get_ticks(): | ||||||
|             if self.talking: |             if self.talking: | ||||||
|                 self.conversation.update(keys, objects) |                 self.conversation.update(keys, objects) | ||||||
|                 self.lastUpdate = pg.time.get_ticks() |                 self.lastUpdate = pg.time.get_ticks() | ||||||
|             else: |             else: | ||||||
|                 touches = pg.sprite.spritecollideany(self, objects[0]) |                 touches = pg.sprite.spritecollideany(self, objects[0]) | ||||||
|                 if touches is not None and keys[pg.K_SPACE] and isinstance(touches, MainCharacter): |                 if touches is not None and keys[pg.K_f] and isinstance(touches, MainCharacter): | ||||||
|                     self.talk(objects)  |                     self.talk(objects)  | ||||||
|                     self.lastUpdate = pg.time.get_ticks() |                     self.lastUpdate = pg.time.get_ticks() | ||||||
| 
 | 
 | ||||||
|  | @ -93,28 +93,31 @@ class Convo(Label): | ||||||
|         self.npc = npc |         self.npc = npc | ||||||
|         self.convo_scene = convo_scene |         self.convo_scene = convo_scene | ||||||
|         self.convos = [ |         self.convos = [ | ||||||
|             ['oldlady', 0, ['Hello', 'How are you?']], |             ['oldlady', 0, ['There are so many rats here.', 'I wish someone would to something against that','An experienced fighter could just kill them.', 'For them it only takes a mouseclick.']], | ||||||
|  |             ['oldlady', 1, ['Oh, did you kill all the rats?', 'You must be the chosen one', 'It would be nice if you would go and talk to the old wise man in the house.']], | ||||||
|             ['oldman', 0, ['Please help', 'there are so many bad people']] |             ['oldman', 0, ['Please help', 'there are so many bad people']] | ||||||
|         ] |         ] | ||||||
| 
 | 
 | ||||||
|     def draw(self, screen): |     def draw(self, screen): | ||||||
|         self.text = self.findConversation()[self.convo_act] |         self.text = self.findConversation()[2][self.convo_act] | ||||||
|         super().draw(screen) |         super().draw(screen) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     def findConversation(self): |     def findConversation(self): | ||||||
|         for convo in self.convos: |         for convo in self.convos: | ||||||
|             if convo[0] == self.npc.name and convo[1] == self.convo_scene: |             if convo[0] == self.npc.name and convo[1] == self.convo_scene: | ||||||
|                 return convo[2] |                 return convo | ||||||
|         return ['ERROR'] |         return ['ERROR'] | ||||||
| 
 | 
 | ||||||
|     def update(self, keys, objects): |     def update(self, keys, objects): | ||||||
|         if keys[pg.K_SPACE]: |         if keys[pg.K_f]: | ||||||
|             convo = self.findConversation() |             convo = self.findConversation() | ||||||
|             if self.convo_act+1 < len(convo): |             if self.convo_act+1 < len(convo[2]): | ||||||
|                 self.text = convo[self.convo_act] |                 self.text = convo[2][self.convo_act] | ||||||
|                 self.convo_act += 1 |                 self.convo_act += 1 | ||||||
|             else: |             else: | ||||||
|  |                 if convo[0] == 'oldlady' and convo[1] == 0: | ||||||
|  |                     objects[1].append(Rat('r1', 200, 1000, 350, 1, 1, 1, 100, 25)) | ||||||
|                 self.convo_act = 0 |                 self.convo_act = 0 | ||||||
|                 self.npc.talking = False |                 self.npc.talking = False | ||||||
|                 objects[0][0].talking = False |                 objects[0][0].talking = False | ||||||
|  | @ -138,7 +141,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, 150, 40, f'will to live: {level}%', 'simple', 20, ) |         self.level = Level(1000, 38, 150, 40, level, 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) | ||||||
|         self.thinks = Thinks(self.x+20, self.y-50, 150, 100, 'brr Im freezing') |         self.thinks = Thinks(self.x+20, self.y-50, 150, 100, 'brr Im freezing') | ||||||
|         self.freezing = True |         self.freezing = True | ||||||
|  | @ -301,8 +304,9 @@ class Hearts(): | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class Level(Label): | class Level(Label): | ||||||
|     def __init__(self, x, y, width, height, text, font='simple', font_size=20, font_color='#1e90ff', sprite='label.png') -> None: |     def __init__(self, x, y, width, height, level, text, font='simple', font_size=20, font_color='#1e90ff', sprite='label.png') -> None: | ||||||
|         super().__init__(x, y, width, height, text, font, font_size, font_color, sprite) |         super().__init__(x, y, width, height, text, font, font_size, font_color, sprite) | ||||||
|  |         self.level = level | ||||||
| 
 | 
 | ||||||
| class Thinks(Label): | class Thinks(Label): | ||||||
|     def __init__(self, x, y, width, height, text, font='simple', font_size=15, font_color='#000000', sprite='thinks.png') -> None: |     def __init__(self, x, y, width, height, text, font='simple', font_size=15, font_color='#000000', sprite='thinks.png') -> None: | ||||||
|  | @ -438,6 +442,16 @@ class Zombie(Mobs): | ||||||
|             obj[3].append(Punch('punch', 100, self.x, self.y, moveto, self.damage)) |             obj[3].append(Punch('punch', 100, self.x, self.y, moveto, self.damage)) | ||||||
|             self.lastAttack = pg.time.get_ticks() |             self.lastAttack = pg.time.get_ticks() | ||||||
| 
 | 
 | ||||||
|  | class Rat(Mobs): | ||||||
|  |     def __init__(self, name, ms, x, y, health, damage, level, asp, atr, sprite='people/rat.png', drops=0) -> None: | ||||||
|  |         super().__init__(name, ms, sprite, x, y, health, damage, level, asp, atr, drops) | ||||||
|  |      | ||||||
|  |      | ||||||
|  |     def attack(self, moveto, obj): | ||||||
|  |         if self.lastAttack + self.attack_speed * 1000 < pg.time.get_ticks(): | ||||||
|  |             obj[3].append(Punch('punch', 100, self.x, self.y, moveto, self.damage)) | ||||||
|  |             self.lastAttack = pg.time.get_ticks() | ||||||
|  | 
 | ||||||
| class Weapons(Objects): | class Weapons(Objects): | ||||||
|     def __init__(self, name, ms, sprite, x, y, moveto, damage, life_ticks) -> None: |     def __init__(self, name, ms, sprite, x, y, moveto, damage, life_ticks) -> None: | ||||||
|         super().__init__(name, ms, sprite, x, y) |         super().__init__(name, ms, sprite, x, y) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue