forked from InfoProjekt/game
Compare commits
No commits in common. "1b6ccb17b08a207c617d067c9ff909f3ddbfeec9" and "c9a98fb94ce22a29881beca8339473dd8c6ce12d" have entirely different histories.
1b6ccb17b0
...
c9a98fb94c
4 changed files with 571 additions and 566 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')
|
||||
|
||||
|
||||
|
|
|
|||
75
viecher.py
75
viecher.py
|
|
@ -44,7 +44,7 @@ class Objects():
|
|||
self.name = name
|
||||
self.speed = ms
|
||||
with open(f'art/images/{sprite}') as i:
|
||||
self.sprite = pg.transform.scale2x(pg.image.load(i))
|
||||
self.sprite = pg.image.load(i)
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.hidden = False
|
||||
|
|
@ -59,9 +59,9 @@ class Objects():
|
|||
|
||||
class NPC(Objects):
|
||||
def __init__(self, name, ms, sprite, convo_act, x, y) -> None:
|
||||
super().__init__(name, ms, sprite, x, y)
|
||||
self.talking = False
|
||||
self.hidden = False
|
||||
self.hidden = True
|
||||
super().__init__(name, ms, sprite, x, y)
|
||||
self.conversation = Convo('Hello, you can shoot fireballs with f now.', convo_act, 'person')
|
||||
|
||||
def talk(self, objects):
|
||||
|
|
@ -71,16 +71,36 @@ class NPC(Objects):
|
|||
|
||||
def draw(self, screen):
|
||||
super().draw(screen)
|
||||
if self.talking:
|
||||
if self.talking == True:
|
||||
self.conversation.draw(screen)
|
||||
|
||||
def update(self, keys, 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)
|
||||
|
||||
|
|
@ -336,7 +368,7 @@ class Weapons(Objects):
|
|||
pos = vec(1,0)
|
||||
angle = pos.angle_to(moveto)
|
||||
with open(f'art/images/{sprite}') as i:
|
||||
self.sprite = pg.transform.scale2x(pg.transform.rotate(pg.image.load(i), -angle))
|
||||
self.sprite = pg.transform.rotate(pg.image.load(i), -angle)
|
||||
|
||||
def die(self, objects, kills):
|
||||
touches = pg.sprite.spritecollideany(self, objects[0] + objects[1])
|
||||
|
|
@ -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