def main(): my_hero = Hero(name='Wencakisa', title='Kingslayer', health=100, mana=100, mana_regeneration_rate=2) my_enemy = Enemy(health=100, mana=100, damage=10) my_weapon = Weapon(name='Windcutter', damage=10) my_spell = Spell(name='Fireball', damage=7, mana_cost=4, cast_range=1) my_hero.equip(my_weapon) my_hero.learn(my_spell) while my_hero.is_alive() and my_enemy.is_alive(): print(my_enemy.attack(enemy=my_hero)) my_enemy.take_healing(healing_points=40) print(my_hero.attack(by='spell', enemy=my_enemy)) print(my_hero.attack(by='weapon', enemy=my_enemy))
def main(): level, screen, clock, fps = set_config() group = RenderUpdates() heroine = Hero(20, 140, "elisa", group) keys = { K_LEFT: False, K_RIGHT: False, K_UP: False, K_DOWN: False, K_RETURN: False, 27: False, K_a: False } # obs 27 = 'esc' pygame.display.flip() while True: clock.tick(fps) for e in pygame.event.get([KEYUP, KEYDOWN]): valor = (e.type == KEYDOWN) if e.key in keys.keys(): keys[e.key] = valor if keys[27]: # tecla ESC pygame.quit() sys.exit() if heroine.attacking: heroine.animate_attack() elif keys[K_LEFT]: heroine.move("left") elif keys[K_RIGHT]: heroine.move("right") elif keys[K_UP]: heroine.jump() elif keys[K_DOWN]: heroine.get_down() elif keys[K_a]: heroine.attack() #heroine.is_jumping(gravity) utils.clear_screen(level, screen) pygame.display.update(group.draw(screen))