Compare commits

..

No commits in common. "baa592d9214b7712159e01e0b1aba349022c2822" and "690a00b7182dedcf95fff305571b5a8dc1e9d2a5" have entirely different histories.

2 changed files with 14 additions and 141 deletions

View file

@ -138,12 +138,10 @@ class HealthBar(Label):
self.box[i] = pygame.image.load(tb)
if not self.filling_is <= self.filling_should:
self.filling_is -= 1.5
if self.filling_should >= self.filling_is:
self.filling_is += 1.5
self.box[i] = pygame.transform.scale(self.box[i], (self.filling_is, self.height))
self.labelRect = pygame.Rect(self.x, self.y, self.width, self.height)
self.labelSurf = self.font.render(f'{self.text}: {round(self.percentage, 1)}%', True, self.font_color)
self.labelSurf = self.font.render(f'{self.text}: {self.percentage}%', True, self.font_color)
self.box[-1].blit(self.labelSurf, [
self.labelRect.width / 2 - self.labelSurf.get_rect().width / 2,
self.labelRect.height / 2 - self.labelSurf.get_rect().height / 2
@ -381,14 +379,13 @@ class Room(GameObjects):
def update(self, objects):
if objects is not None:
self.objects = objects
if self.type == 'boss' and not self.objects:
if not self.objects[1]:
if self.type == 'boss':
print('yeahhh, you killed the boss')
self.objects[0][0].level.level = 100
if len(self.objects[1]) <= 3:
self.locked = False
for door in self.doors:
door.update(False)
#Tür Sound
return
def draw(self, screen):
@ -537,55 +534,6 @@ class Convo(Label):
self.npc.talking = False
objects[0][0].talking = False
class Drops():
def __init__(self, type, level, mult) -> None:
table = {
'boss': {
'xp': 150,
'gold': 500,
'artifacts': [
100, #drop-chance
20, #common
30, #uncommon
35, #rare
14, #epic
1 #legendary
],
'will': 5
},
'mob': {
'xp': 5,
'gold': 20,
'artifacts': [
10, #drop-chance
65, #common
25, #uncommon
7.5, #rare
2.25, #epic
0.25 #legendary
],
'will': 0.1
},
'add': {
'xp': 0,
'gold': 3,
'artifacts': [
1, #drop-chance
90, #common
9.9, #uncommon
0.1, #rare
0, #epic
0 #legendary
],
'will': 0
}
}
self.table = table[type]
self.multiplicator = level * mult
def drop(self, main):
main.skill_xp += self.table['xp'] * self.multiplicator
main.gold += self.table['gold'] * self.multiplicator
class Fighter(Objects):
def __init__(self, name, ms, sprite, x, y, health, damage, level, asp, atr) -> None:
@ -605,7 +553,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, level, f'will to live: {round(level, 1)}%', '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.thinks = Thinks(self.x + 20, self.y - 50, 150, 100, 'brr I\'m freezing')
self.freezing = True
@ -616,8 +564,6 @@ class MainCharacter(Fighter):
self.last_frame_update = pygame.time.get_ticks()
self.rect = pygame.Rect(x, y, self.walk_frames[0].get_width(), self.walk_frames[0].get_height())
self.is_attacking = False
self.skill_xp = 0
self.gold = 0
def load_frames(self, walk_sprite_sheet, attack_sprite_sheet):
self.walk_frames = self.load_animation_frames(walk_sprite_sheet, frame_width=40, frame_height=66)
@ -628,7 +574,7 @@ class MainCharacter(Fighter):
animation_frames = []
if frame_width == 40:
frames_coordinates = [
(frame_width, 0),
(frame_width, 0),
(frame_width*2, 0),
(frame_width*3, 0),
(frame_width*4, 0),
@ -652,6 +598,7 @@ class MainCharacter(Fighter):
animation_frames.append(frame)
return animation_frames
def draw(self, screen):
if self.hidden:
return
@ -863,7 +810,7 @@ class Level(Label):
super().__init__(x, y, width, height, text, font, font_size, font_color, sprite)
self.level = level
def draw(self, screen):
self.text = f'will to live: {round(self.level)}%'
self.text = f'will to live: {self.level}%'
super().draw(screen)
class Thinks(Label):
@ -952,14 +899,14 @@ class Book():
class Mobs(Fighter):
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('mob', self.level, drops)
self.drops = drops * (self.level / 2)
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(int(self.speed))
moveto.scale_to_length(self.speed)
self.x += moveto[0] / fps
self.y += moveto[1] / fps
touches = pygame.sprite.spritecollideany(self, obj[4])
@ -988,15 +935,15 @@ class Mobs(Fighter):
if self.health <= 0:
objects[0][0].killed.append(self.name)
self.hidden = True
self.drops.drop(objects[0][0])
objects[1].remove(self)
def update(self, obj):
self.chase(obj)
class Skeleton(Mobs):
def __init__(self, name, ms, x, y, health, damage, level, asp, atr, sprite = 'people/skeleton.png', drops=2) -> None:
def __init__(self, name, ms, x, y, health, damage, level, asp, atr, sprite = 'people/skeleton.png', drops=0) -> None:
super().__init__(name, ms, sprite, x, y, health, damage, level, asp, atr, drops)
def attack(self, moveto, obj):
@ -1009,7 +956,7 @@ class Skeleton(Mobs):
class Zombie(Mobs):
def __init__(self, name, ms, x, y, health, damage, level, asp, atr, sprite_sheet='people/zombiewalk.png', drops=1) -> None:
def __init__(self, name, ms, x, y, health, damage, level, asp, atr, sprite_sheet='people/zombiewalk.png', drops=0) -> None:
super().__init__(name, ms, sprite_sheet, x, y, health, damage, level, asp, atr, drops)
self.load_frames(f'art/images/{sprite_sheet}')
self.current_frame = 0
@ -1053,7 +1000,7 @@ class Zombie(Mobs):
self.lastAttack = pygame.time.get_ticks()
class Rat(Mobs):
def __init__(self, name, ms, x, y, health, damage, level, asp, atr, sprite='people/rat.png', drops=1) -> None:
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):
@ -1061,22 +1008,9 @@ class Rat(Mobs):
obj[3].append(Punch('punch', 100, self.x, self.y, moveto, self.damage, MainCharacter))
self.lastAttack = pygame.time.get_ticks()
class Adds(Mobs):
def __init__(self, name, ms, sprite, health, damage, level, asp, atr, drops, x, y) -> None:
super().__init__(name, ms, sprite, x, y, health, damage, level, asp, atr, drops)
self.drops = Drops('add', self.level, drops)
def attack(self, moveto, obj):
pass
class Boss(Mobs):
def __init__(self, name, ms, x, y, health, damage, level, asp, atr, sprite='people/reddy.png', drops=1) -> None:
def __init__(self, name, ms, x, y, health, damage, level, asp, atr, sprite='people/reddy.png', drops=0) -> None:
super().__init__(name, ms, sprite, x, y, health, damage, level, asp, atr, drops)
self.max_hp = health
self.drops = Drops('boss', self.level, drops)
self.adds = SpawnAdds(15, ['add', '125', sprite, 3, 0.5, 1, 1.5, 250, 1], [3, 7])
self.ability = Heal(10, 25, 5)
self.adds.last_used = pygame.time.get_ticks() - 12500
def attack(self, moveto, obj):
reddyattack_sound = mixer.Sound('audio/soundeffects/reddyattack.mp3')
@ -1094,63 +1028,7 @@ class Boss(Mobs):
objects[0][0].killed.append(self.name)
self.hidden = True
objects[1].remove(self)
def update(self, obj):
super().update(obj)
self.adds.spawn(obj)
event = self.ability.cast(obj)
if event.type == 'heal':
self.health += event.num
if self.health > self.max_hp:
self.health = self.max_hp
elif self.health < 0:
self.health = 0
class Event():
def __init__(self, _type: str, num: int) -> None:
self.type = _type
self.num = num
class Ability():
def __init__(self, cd, stage = 0) -> None:
self.cooldown = cd
self.stage = stage
self.last_used = 0
def cast(self, objects):
if self.last_used + self.cooldown * 1000 <= pygame.time.get_ticks():
self.last_used = pygame.time.get_ticks()
class SpawnAdds(Ability):
def __init__(self, cd, add:list, count:list, stage=0) -> None:
super().__init__(cd, stage)
self.add = add
self.count = count
def spawn(self, objects):
if self.last_used + self.cooldown * 1000 <= pygame.time.get_ticks():
for i in range(random.randint(*self.count)):
objects[1].append(Adds(*self.add, random.randint(32, 1888), random.randint(32, 1048)))
self.last_used = pygame.time.get_ticks()
class Heal(Ability):
def __init__(self, cd, amount, time, stage=0) -> None:
super().__init__(cd, stage)
self.amount = amount
self.time = time
def cast(self, objects):
if self.time * 1000 + self.last_used > pygame.time.get_ticks():
return Event('heal', (self.amount / self.time / 1000))
elif self.time * 1000 + self.last_used == pygame.time.get_ticks():
self.last_used = pygame.time.get_ticks()
return Event('heal', (self.amount / self.time / 1000))
elif random.randint(0, 88) % 5 == 0:
if self.last_used + self.cooldown * 1000 <= pygame.time.get_ticks():
self.last_used = pygame.time.get_ticks()
# else:
# self.last_used
return Event('None', 0)
class Weapons(Objects):
def __init__(self, name, ms, sprite, x, y, moveto, damage, life_ticks) -> None:
@ -1239,9 +1117,6 @@ class Punch(Weapons):
def __init__(self, name, ms, x, y, moveto, damage, kills, sprite = 'weapons/empty.png', life_ticks=100) -> None:
super().__init__(name, ms, sprite, x, y, moveto, damage, life_ticks)
self.kills = kills
# if self.kills == Mobs:
# self.rect.width *= 2
# self.rect.height *= 2
def update(self, objects):
self.move(objects)

View file

@ -41,7 +41,6 @@ def genRooms(WIDTH, HEIGHT, type:str, objects:list):
Room(type, 'normal', room_backgrounds[random.randint(0, 0)], [objects[0], objects[1], objects[2], objects[3], objects[4] + [room_objects[random.randint(0, 0)] for _ in range(0, random.randint(0, 1))]], WIDTH - 64, HEIGHT - 64, j)
for j in range(random.randint(5, 10))
]
print(objects)
rooms.append(Room(type, 'boss', room_backgrounds[random.randint(0, 0)], [objects[0], objects[1], [], [], objects[4] + [room_objects[random.randint(0, 0)] for i in range(0, random.randint(0, 1))]], WIDTH - 64, HEIGHT - 64, 88))
#rooms = [Room(type, 'boss', room_backgrounds[random.randint(0, 0)], [objects[0], objects[1], [], [], objects[4] + [room_objects[random.randint(0, 0)] for i in range(0, random.randint(0, 1))]], WIDTH - 64, HEIGHT - 64, 88)]
#rooms =Room(type, 'normal', room_backgrounds[random.randint(0, 4)], [objects[0], objects[1], objects[2], [room_objects[random.randint(0, len(room_objects) - 1)] for i in range(0, random.randint(0, 1))]], WIDTH - 64, HEIGHT - 64, [True, True, True, True], j)
@ -106,7 +105,6 @@ def play(screen, clock, running, background, isblack, WIDTH, HEIGHT):
if objects[0][0].level.level >= 100:
isblack = True
if isinstance(result, str):
print(result)
if result == 'village':
village(screen, clock, running, background, isblack, WIDTH, HEIGHT)
elif result == 'play':