Development #2
							
								
								
									
										
											BIN
										
									
								
								art/images/arrow.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 255 B | 
							
								
								
									
										
											BIN
										
									
								
								art/images/dreiviertelheart.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 450 B | 
							
								
								
									
										
											BIN
										
									
								
								art/images/fullheart.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 433 B | 
							
								
								
									
										
											BIN
										
									
								
								art/images/halfheart.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 462 B | 
							
								
								
									
										
											BIN
										
									
								
								art/images/label.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 635 B | 
							
								
								
									
										
											BIN
										
									
								
								art/images/noheart.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 438 B | 
							
								
								
									
										
											BIN
										
									
								
								art/images/oldman.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 674 B | 
							
								
								
									
										
											BIN
										
									
								
								art/images/viertelheart.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 441 B | 
							
								
								
									
										
											BIN
										
									
								
								art/sprite files/oldmanattack.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 5.9 KiB | 
							
								
								
									
										
											BIN
										
									
								
								art/sprite files/oldmanwalk.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 2.1 KiB | 
							
								
								
									
										59
									
								
								classes.py
									
										
									
									
									
								
							
							
						
						|  | @ -1,5 +1,4 @@ | |||
| import pygame | ||||
| import inspect | ||||
| 
 | ||||
| pygame.font.init() | ||||
| fonts = { | ||||
|  | @ -139,69 +138,23 @@ class DropDown(): | |||
| 
 | ||||
| 
 | ||||
| class GameObjects(): | ||||
|     def __init__(self, name:str, _type:str, bg, objects:list, WIDTH, HEIGHT) -> None: | ||||
|     def __init__(self, name:str, _type:str, bg, objects:list) -> None: | ||||
|         self.name = name | ||||
|         self.type = _type | ||||
|         if bg != None: | ||||
|             with open(bg, 'r') as bg: | ||||
|                 self.background = pygame.transform.scale(pygame.image.load(bg), [WIDTH, HEIGHT]) | ||||
|         self.background = bg | ||||
|         self.objects = objects | ||||
| 
 | ||||
| 
 | ||||
| class Scene(GameObjects): | ||||
|     def __init__(self, name:str, _type:str, bg, objects:list | None, WIDTH, HEIGHT, level:list) -> None: | ||||
|         super().__init__(name, _type, bg, objects, WIDTH, HEIGHT) | ||||
|         self.level = level | ||||
|         self.current_level = 0 | ||||
|     def __init__(self, name:str, _type:str, bg, objects:list) -> None: | ||||
|         super().__init__(name, _type, bg, objects) | ||||
| 
 | ||||
|     def update(self, change:bool): | ||||
|         if change: | ||||
|             self.current_level += 1 | ||||
|         self.level[self.current_level].update() | ||||
|         for obj in self.objects: | ||||
|             obj.update() | ||||
|          | ||||
|     def draw(self, screen): | ||||
|         for obj in self.objects: | ||||
|             obj.draw(screen) | ||||
|         self.level[self.current_level].draw(screen) | ||||
|          | ||||
| 
 | ||||
| class Level(GameObjects): | ||||
|     def __init__(self, name: str, _type: str, bg, objects: list, WIDTH, HEIGHT, stage:str, rooms:list) -> None: | ||||
|         super().__init__(name, _type, bg, objects, WIDTH, HEIGHT) | ||||
|         self.stage = stage | ||||
|         self.rooms = rooms | ||||
|         self.current = 0 | ||||
|      | ||||
|     def update(self): | ||||
|         for room in self.rooms: | ||||
|             if room.id == self.current: | ||||
|                 room.update() | ||||
|         keys = pygame.key.get_pressed() | ||||
|         if keys[pygame.K_RIGHT]: | ||||
|             self.current += 1 | ||||
|         if self.current >= len(self.rooms): | ||||
|             return 1 | ||||
| 
 | ||||
|     def draw(self, screen): | ||||
|         for room in self.rooms: | ||||
|             if room.id == self.current: | ||||
|                 room.draw(screen) | ||||
| 
 | ||||
| class Room(GameObjects): | ||||
|     def __init__(self, name:str, _type:str, bg, objects:list, WIDTH, HEIGHT, exits:list, id:int) -> None: | ||||
|         super().__init__(name, _type, bg, objects, WIDTH, HEIGHT) | ||||
|     def __init__(self, name:str, _type:str, bg, objects:list, exits:list) -> None: | ||||
|         super().__init__(name, _type, bg, objects) | ||||
|         self.exits = exits | ||||
|         self.id = id | ||||
|         if self.type == 'normal' or self.type == 'boss': | ||||
|             self.locked = True | ||||
|         else: | ||||
|             self.locked = False | ||||
| 
 | ||||
|     def update(self): | ||||
|         pass | ||||
| 
 | ||||
|     def draw(self, screen): | ||||
|         screen.blit(self.background, (0, 0)) | ||||
|          | ||||
							
								
								
									
										22
									
								
								ideas.txt
									
										
									
									
									
										Normal file
									
								
							
							
						
						|  | @ -0,0 +1,22 @@ | |||
| Game: | ||||
|     Rogue-like Game mit Story | ||||
|     Pixel | ||||
| 
 | ||||
|     viele Gegner: | ||||
|         Skelette | ||||
|         Zombies | ||||
| 
 | ||||
| Story: | ||||
|     Homeless guy in Berlin (oder so) im Winter in einer Stadtbibliothek, weil warm und Shelter. | ||||
|         er hasst eigentlich Bücher, aber aus Langeweile durchstöbert er die Bibo | ||||
|         findet cool aussehendes antikes/magisches Buch, nimmt es aus dem Regal, blättert es auf und wird ohnmächtig | ||||
|         -> Erwacht als magische Person in magischer Welt wieder | ||||
|             Buch dient als Skillbaum (verschiedene Kapitel) | ||||
|                 Kampfmagier | ||||
|                 Heilender Magier -> Priester? | ||||
|                 Elementmagier(?) | ||||
|                 maybe noch irgendwas 4. | ||||
| 
 | ||||
|     Ziel(e) | ||||
|         -> Zurückkommen | ||||
|         -> Happy werden (?) | ||||
							
								
								
									
										59
									
								
								main.py
									
										
									
									
									
								
							
							
						
						|  | @ -2,6 +2,7 @@ import pygame | |||
| import sys | ||||
| import json | ||||
| import time | ||||
| import random | ||||
| from classes import * | ||||
| from viecher import * | ||||
| fps = 60 | ||||
|  | @ -27,8 +28,11 @@ def quitGame(): | |||
|     quit() | ||||
| 
 | ||||
| def play(screen, clock, running, background, isblack, WIDTH, HEIGHT): | ||||
|     objects = [[], [], []] #0 - maincharacter stuff; 1 - mobs; 2 - npcs | ||||
|     objects[0].append(MainCharacter('Herbert', 100, 'reddy.png', 125, 5, 1, 1, 50)) | ||||
|     main = [MainCharacter('Herbert', 100, 'oldman.png', 500, 500, 20, 5, 1, 1, 50)] | ||||
|     mobs=[Skeleton(i, 50, 'reddy.png', random.randint(20,1000), random.randint(20,700), 125, 1, 1, 1, 200) for i in range(0,random.randint(2,8))] | ||||
|     others = [] | ||||
|     objects = [main, mobs, others] | ||||
| 
 | ||||
|     while running: | ||||
|         screen.fill('#000000') | ||||
|         events = pygame.event.get() | ||||
|  | @ -42,9 +46,20 @@ def play(screen, clock, running, background, isblack, WIDTH, HEIGHT): | |||
|         # fill the screen with an image to clear the screen | ||||
|         screen.blit(bg, (0, 0)) | ||||
| """  | ||||
|         for obj in objects: | ||||
|             obj.update(pygame.key.get_pressed()) | ||||
|             obj.draw(screen) | ||||
|         for thing in objects[0]: | ||||
|             if thing.update(pygame.key.get_pressed()) ==False: | ||||
|                 menu(screen, clock, running, background, isblack, WIDTH, HEIGHT) | ||||
|             thing.draw(screen) | ||||
|          | ||||
|         for mob in objects[1]: | ||||
|             mob.update(objects) | ||||
|             mob.draw(screen) | ||||
|          | ||||
|         for thing in objects[2]: | ||||
|             thing.update(objects) | ||||
|             thing.draw(screen) | ||||
| 
 | ||||
|          | ||||
|         # flip() the display to put your work on screen | ||||
|         pygame.display.flip() | ||||
| 
 | ||||
|  | @ -103,7 +118,6 @@ def menu(screen, clock, running, background, isblack, WIDTH, HEIGHT): | |||
|             bg = pygame.transform.scale(bg, (WIDTH, HEIGHT)) | ||||
|         # fill the screen with an image to clear the screen | ||||
|         screen.blit(bg, (0, 0)) | ||||
|          | ||||
|         for obj in objects: | ||||
|             obj.process(screen, clock, running, background, isblack, WIDTH, HEIGHT) | ||||
| 
 | ||||
|  | @ -112,38 +126,6 @@ def menu(screen, clock, running, background, isblack, WIDTH, HEIGHT): | |||
| 
 | ||||
|         clock.tick(60)  # limits FPS to 60 | ||||
| 
 | ||||
| def test(screen, clock, running, background, isblack, WIDTH, HEIGHT): | ||||
|     level = [] | ||||
|     level.append(Level('blau', 'normal', None, [], WIDTH, HEIGHT, 'blue', [ | ||||
|         Room('blau1', 'normal', 'art/images/blau1.png', [], WIDTH, HEIGHT, [True, True, True, False], 0), | ||||
|         Room('blau2', 'normal', 'art/images/blau2.png', [], WIDTH, HEIGHT, [True, True, True, False], 1), | ||||
|         Room('blau3', 'normal', 'art/images/blau3.png', [], WIDTH, HEIGHT, [True, True, True, False], 2), | ||||
|             ])) | ||||
|      | ||||
|     level.append(Level('rot', 'normal', None, [], WIDTH, HEIGHT, 'red', [ | ||||
|         Room('red1', 'normal', 'art/images/rot1.png', [], WIDTH, HEIGHT, [True, True, True, False], 0), | ||||
|         Room('red2', 'normal', 'art/images/rot2.png', [], WIDTH, HEIGHT, [True, True, True, False], 1), | ||||
|         Room('red3', 'normal', 'art/images/rot3.png', [], WIDTH, HEIGHT, [True, True, True, False], 2), | ||||
|             ])) | ||||
|      | ||||
|     scene = Scene('test', 'normal', None, None, WIDTH, HEIGHT, level) | ||||
| 
 | ||||
|     # RENDER YOUR GAME HERE | ||||
|     while True: | ||||
|         for event in pygame.event.get(): | ||||
|             if event.type == pygame.QUIT: | ||||
|                 running = False | ||||
|                 quitGame() | ||||
|              | ||||
|             scene.update() | ||||
|             scene.draw(screen) | ||||
|         # flip() the display to put your work on screen | ||||
|         pygame.display.flip() | ||||
| 
 | ||||
|         clock.tick(60)  # limits FPS to 60 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| def main(): | ||||
|     config = readConfig() | ||||
|     screen, clock, running, isblack, background, objects = setUp(config["screen"]) | ||||
|  | @ -151,7 +133,6 @@ def main(): | |||
|     #objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 - 72, 160, 64, 'medieval', 48, "Play", play)) | ||||
|     #objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2, 160, 64, 'medieval', 48, "Options", uwu)) | ||||
|     #objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 + 72, 160, 64, 'medieval', 48, "Exit game", quitGame)) | ||||
|     test(screen, clock, running, background, isblack, WIDTH, HEIGHT) | ||||
|     menu(screen, clock, running, background, isblack, WIDTH, HEIGHT) | ||||
|     """while running: | ||||
|         for event in pygame.event.get(): | ||||
|  |  | |||
							
								
								
									
										235
									
								
								viecher.py
									
										
									
									
									
								
							
							
						
						|  | @ -1,17 +1,52 @@ | |||
| import pygame | ||||
| import pygame as pg | ||||
| vec = pg.math.Vector2 | ||||
| fps = 60 | ||||
| 
 | ||||
| class Character(): | ||||
|     def __init__(self, name, ms, sprite) -> None: | ||||
| 
 | ||||
| pg.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 Objects(): | ||||
|     def __init__(self, name, ms, sprite, x, y) -> None: | ||||
|         self.name = name | ||||
|         self.speed = ms | ||||
|         with open(f'art/images/{sprite}') as i: | ||||
|             self.sprite = pygame.image.load(i) | ||||
|         self.x = 524 | ||||
|         self.y = 524 | ||||
|             self.sprite = pg.image.load(i) | ||||
|         self.x = x | ||||
|         self.y = y | ||||
|         self.hidden = False | ||||
| 
 | ||||
|         self.rect = pygame.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()) | ||||
|      | ||||
|     def draw(self, screen): | ||||
|         if self.hidden: | ||||
|  | @ -20,37 +55,191 @@ class Character(): | |||
|         screen.blit(self.sprite, self.rect) | ||||
| 
 | ||||
| 
 | ||||
| class NPC(Character): | ||||
| class NPC(Objects): | ||||
|     pass | ||||
| 
 | ||||
| 
 | ||||
| class Fighter(Character): | ||||
|     def __init__(self, name, ms, sprite, health, damage, level, asp, atr) -> None: | ||||
|         super().__init__(name, ms, sprite) | ||||
| class Fighter(Objects): | ||||
|     def __init__(self, name, ms, sprite, x, y, health, damage, level, asp, atr) -> None: | ||||
|         super().__init__(name, ms, sprite, x, y) | ||||
|         self.health = health | ||||
|         self.damage = damage | ||||
|         self.level = level | ||||
|         self.attack_speed = asp | ||||
|         self.attack_range = atr | ||||
|         self.lastHurt = pg.time.get_ticks() | ||||
|         self.lastAttack = pg.time.get_ticks() | ||||
|         self.hurtCooldown = 1000 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| class MainCharacter(Fighter): | ||||
|     def __init__(self, name, ms, sprite, health, damage, level, asp, atr, weapon=None, shield=None) -> None: | ||||
|         super().__init__(name, ms, sprite, health, damage, level, asp, atr) | ||||
|     def __init__(self, name, ms, sprite, x, y, health, damage, level, asp, atr, weapon=None, shield=None) -> None: | ||||
|         super().__init__(name, ms, sprite, x, y, health, damage, level, asp, atr) | ||||
|         self.attack_spell = weapon | ||||
|         self.shield_spell = shield | ||||
|         self.talking = False | ||||
|         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) | ||||
|      | ||||
|     def draw(self, screen): | ||||
|         if self.hidden: | ||||
|             return | ||||
|         self.rect.x, self.rect.y = self.x, self.y | ||||
|         screen.blit(self.sprite, self.rect) | ||||
|         self.health.draw(screen) | ||||
|         self.level.draw(screen) | ||||
| 
 | ||||
|     def hurt(self,damage): | ||||
|         self.health.hurt(damage) | ||||
|      | ||||
|     def walk(self,keys): | ||||
|         moveto=vec(0,0) | ||||
|         if keys[pg.K_w] or keys[pg.K_UP]: | ||||
|             moveto += vec(0,-1) | ||||
|         if keys[pg.K_a] or keys[pg.K_LEFT]: | ||||
|             moveto += vec(-1,0) | ||||
|         if keys[pg.K_s] or keys[pg.K_DOWN]: | ||||
|             moveto += vec(0,1) | ||||
|         if keys[pg.K_d] or keys[pg.K_RIGHT]: | ||||
|             moveto += vec(1,0) | ||||
|         if not moveto == vec(0,0): | ||||
|             moveto.scale_to_length(self.speed) | ||||
|         self.x += moveto[0] / fps | ||||
|         self.y += moveto[1] / fps | ||||
| 
 | ||||
|     def update(self, keys): | ||||
|         if keys[pygame.K_w]: | ||||
|             self.y -= self.speed / fps | ||||
|         if keys[pygame.K_a]: | ||||
|             self.x -= self.speed / fps | ||||
|         if keys[pygame.K_s]: | ||||
|             self.y += self.speed / fps | ||||
|         if keys[pygame.K_d]: | ||||
|             self.x += self.speed / fps | ||||
|         self.walk(keys) | ||||
|         if self.health.health <= 0: | ||||
|             return False | ||||
|         else: | ||||
|             return True | ||||
| 
 | ||||
| class Hearts(): | ||||
|     def __init__(self, health, sprite, x, y) -> None: | ||||
|         self.x = x | ||||
|         self.y = y | ||||
|         self.health = health | ||||
|         self.lastHurt = pg.time.get_ticks() | ||||
|         self.hurtCooldown = 1000 | ||||
|         self.hidden = False | ||||
|         self.sprite=[] | ||||
|         for parts in sprite: | ||||
|             with open(f'art/images/{parts}') as i: | ||||
|                 self.sprite.append(pg.image.load(i)) | ||||
|         self.rect=[] | ||||
|         for each in self.sprite: | ||||
|             self.rect.append(pg.Rect(self.x, self.y, each.get_width(), each.get_height())) | ||||
|          | ||||
|     def hurt(self,damage): | ||||
|         if self.lastHurt + self.hurtCooldown < pg.time.get_ticks(): | ||||
|             self.health -= damage | ||||
|             self.lastHurt = pg.time.get_ticks() | ||||
|             self.update() | ||||
| 
 | ||||
|     def draw(self, screen): | ||||
|         if self.hidden: | ||||
|             return | ||||
|         for i in range(0,5): | ||||
|             self.rect[i].x, self.rect[i].y = self.x+i*20, self.y | ||||
|             screen.blit(self.sprite[i], self.rect[i]) | ||||
|      | ||||
|     def update(self): | ||||
|         sprite = [] | ||||
|         for i in range(0,5): | ||||
|             if self.health >= 4+4*i: | ||||
|                 sprite.append('fullheart.png') | ||||
|             elif self.health == 3+4*i: | ||||
|                 sprite.append('dreiviertelheart.png') | ||||
|             elif self.health >= 2+4*i: | ||||
|                 sprite.append('halfheart.png') | ||||
|             elif self.health >= 1+4*i: | ||||
|                 sprite.append('viertelheart.png') | ||||
|             elif self.health <= 4*i: | ||||
|                 sprite.append('noheart.png')   | ||||
|         self.sprite=[] | ||||
|         for parts in sprite: | ||||
|             with open(f'art/images/{parts}') as i: | ||||
|                 self.sprite.append(pg.image.load(i)) | ||||
| 
 | ||||
| 
 | ||||
| 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 Mobs(Fighter): | ||||
|     def __init__(self, name, ms, sprite, health, damage, level, asp, atr, drops) -> None: | ||||
|         super().__init__(name, ms, sprite, health, damage, level, asp, atr) | ||||
|     def __init__(self, name, ms, sprite, x, y, health, damage, level, asp, atr, drops) -> None: | ||||
|         super().__init__(name, ms, sprite, x, y, health, damage, level, asp, atr) | ||||
|         self.drops = drops * (self.level / 2) | ||||
| 
 | ||||
| class Skeleton(Mobs): | ||||
|     def __init__(self, name, ms, sprite, x, y, health, damage, level, asp, atr, drops=0) -> None: | ||||
|         super().__init__(name, ms, sprite, x, y, health, damage, level, asp, atr, drops) | ||||
|      | ||||
|     def chase(self,obj): | ||||
|         x=obj[0][0].x | ||||
|         y=obj[0][0].y | ||||
|         moveto = vec(x,y) - vec(self.x,self.y) | ||||
|         if not (moveto).length()<=self.attack_range: | ||||
|             moveto.scale_to_length(self.speed) | ||||
|             self.x += moveto[0]/fps | ||||
|             self.y += moveto[1]/fps | ||||
|         else: | ||||
|             self.attack(moveto,obj) | ||||
| 
 | ||||
|     def attack(self,moveto,obj): | ||||
|         if self.lastAttack+self.attack_speed*1000<pg.time.get_ticks(): | ||||
|             obj[1].append(Arrow("arrow",200,self.x,self.y,moveto, self.damage)) | ||||
|             self.lastAttack=pg.time.get_ticks() | ||||
| 
 | ||||
|     def update(self,obj): | ||||
|         self.chase(obj) | ||||
| 
 | ||||
| 
 | ||||
| class Weapons(Objects): | ||||
|     def __init__(self, name, ms, sprite, x, y, moveto, damage) -> None: | ||||
|         super().__init__(name, ms, sprite, x, y) | ||||
|         self.moveto = moveto | ||||
|         self.damage = damage | ||||
| 
 | ||||
| 
 | ||||
| class Arrow(Weapons): | ||||
|     def __init__(self, name, ms, x, y, moveto, damage, sprite="arrow.png") -> None: | ||||
|         super().__init__(name, ms, sprite, x, y, moveto, damage) | ||||
|         pos = vec(1,0) | ||||
|         angle = pos.angle_to(moveto) | ||||
|         with open(f'art/images/{sprite}') as i: | ||||
|             self.sprite = pg.transform.rotate(pg.image.load(i), angle) | ||||
| 
 | ||||
|     def move(self): | ||||
|         self.moveto.scale_to_length(self.speed) | ||||
|         self.x += self.moveto[0]/fps | ||||
|         self.y += self.moveto[1]/fps | ||||
|      | ||||
|     def die(self,objects): | ||||
|         touches=pg.sprite.spritecollideany(self,objects[0]) | ||||
|         if  touches is not None and isinstance(touches, MainCharacter): | ||||
|             touches.hurt(self.damage) | ||||
|             self.hidden=True | ||||
|      | ||||
|     def update(self,objects): | ||||
|         self.move() | ||||
|         self.die(objects) | ||||