示例#1
0
def main():
    enemy = Goblin()
    hero = Hero()

    while enemy.alive() and hero.alive():
        hero.print_status()
        enemy.print_status()
        print()
        print("What do you want to do?")
        print("1. fight enemy")
        print("2. do nothing")
        print("3. flee")
        print("> ", )
        response = input()
        if response == "1":
            # Hero attacks enemy
            hero.attack(enemy)
        elif response == "2":
            pass
        elif response == "3":
            print("Goodbye.")
            break
        else:
            print("Invalid input %r" % input)

        if enemy.alive():
            # enemy attacks hero
            enemy.attack(hero)
示例#2
0
def main():
    hero = Hero()
    goblin = Goblin()

    while hero.alive() and goblin.alive():
        hero.print_status()
        goblin.print_status()
        print()
        print("What do you want to do?")
        print("1. fight goblin")
        print("2. do nothing")
        print("3. flee")
        print("> ", )
        user_input = input()
        if user_input == "1":
            # Hero attacks goblin
            hero.attack(goblin)
        elif user_input == "2":
            pass
        elif user_input == "3":
            print("Goodbye.")
            break
        else:
            print("Invalid input %r. Enter 1, 2 or 3." % user_input)

        if goblin.health > 0:
            # Goblin attacks hero
            goblin.attack(hero)
示例#3
0
def main():
    hero = Hero('Matt', 10, 5)
    goblin = Goblin('Goblin', 6, 2)
    while goblin.alive() and hero.alive():
        print()
        print("What do you want to do?")
        print("1. fight %s" % (goblin.name))
        print("2. do nothing")
        print("3. flee")
        print("> ", )
        user_input = input()
        if user_input == "1":
            # Hero attacks enemy
            hero.attack(goblin)
            print("You do %d damage to the %s." % (hero.power, goblin.name))
            if goblin.health <= 0:
                print("The %s is dead." % (goblin.name))
        elif user_input == "2":
            goblin.attack(hero)
            hero.print_status()
        elif user_input == "3":
            print("Goodbye.")
        else:
            print("Invalid input %r" % user_input)
        if hero.health <= 0:
            print("You are dead.")
示例#4
0
def main():
    hero = Hero(10, 5)
    goblin = Goblin(6, 2)
    # hero_health = 10
    # hero_power = 5
    # goblin_health = 6
    # goblin_power = 2

    while goblin.alive() and hero.alive():
        #print("You have %d health and %d power." % (hero.health, hero.power))
        hero.print_status()
        #print("The goblin has %d health and %d power." % (goblin.health, goblin.power))
        goblin.print_status()
        print()
        print("What do you want to do?")
        print("1. fight goblin")
        print("2. do nothing")
        print("3. flee")
        print("> ", )
        user_input = input()
        if user_input == "1":
            # Hero attacks goblin
            # goblin_health -= hero_power
            # print("You do %d damage to the goblin." % hero_power)
            hero.attack(goblin)
            if not goblin.alive():
                print("The goblin is dead.")
        elif user_input == "2":
            pass
        elif user_input == "3":
            print("Goodbye.")
            break
        else:
            print("Invalid input %r" % user_input)

        if goblin.alive():
            # Goblin attacks hero
            # hero_health -= goblin_power
            # print("The goblin does %d damage to you." % goblin_power)
            goblin.attack(hero)
            if not hero.alive():
                print("You are dead.")
示例#5
0
def main():
    my_hero = Hero()
    goblin = Goblin()
    zombie = Zombie()
    medic = Medic()
    shadow = Shadow()

    while (goblin.alive() or zombie.alive()) and my_hero.alive():
        my_hero.print_status()
        print()
        print("What do you want to do?")
        print("1. fight goblin")
        print("2. fight zombie")
        print("3. fight medic")
        print("4. fight shadow")
        print("5. do nothing")
        print("6. flee")
        print("> ",)
        user_input = input()
        if user_input == "1":
            goblin.print_status()
            # my_hero attacks goblin
            my_hero.attack(goblin)
            if goblin.health > 0:
            # Goblin attacks my_hero
                goblin.attack(my_hero)
        elif user_input == "2":
            zombie.print_status()
            my_hero.attack(zombie)
            zombie.attack(my_hero)
            zombie.alive()   
        elif user_input == "3":
            medic.print_status()
            my_hero.attack(medic)
            medic.attack(my_hero)
            medic.alive()
        elif user_input == "4":
            shadow.print_status()
            shadow.attack(my_hero)
            my_hero.attack(shadow)
            shadow.alive()
        elif user_input == "5":
            pass
        elif user_input == "6":
            print("Goodbye.")
            break
        else:
            print("Invalid input %r" % user_input)
示例#6
0
                elif (key == K_RIGHT):
                    x, y = map.collission(check(enemy.X + settings.SPEED),
                                          enemy.Y, box, bombs, hero, enemy)
                if (x != None):
                    enemy.X, enemy.Y = x, y
    if gameState:
        hero.takeLoot(box)
        enemy.takeLoot(box)
        for i in explosion:
            if i.explode:
                explosion.remove(i)
        Draw()
        # hero.smoothMove(grid, surface, clock, bombs)
    if (gameState == True and (hero.alive == False or enemy.alive == False)):
        KillThreads()
        Draw()
        rect = pygame.Surface((settings.WIDTH, settings.HEIGHT),
                              pygame.SRCALPHA)
        rect.fill((0, 0, 0, 128))
        rect.blit(surface, (0, 0))
        pygame.display.update()
        text = gameOver.render(Winner(), False, (2, 180, 180))
        surface.blit(text, (250, 250))
        pygame.display.update()
        gameState = False
    if step > 10000:
        hero.alive = False
        enemy.alive = False
    clock.tick(60)
    step += 1