Пример #1
0
def new_cyclops(game_state):
    cyclops = Composite()
    set_monster_components(cyclops, game_state)
    set_humanoid_components(cyclops)
    cyclops.set_child(EntityMessages("The eye of the cyclops watches at you.",
                                     "The cyclops is dead."))
    cyclops.set_child(Description("Cyclops",
                                  "A Giant with a single disgusting eye, it's looking for prey."))
    cyclops.set_child(GraphicChar(None, colors.LIGHT_ORANGE, icon.CYCLOPS))
    cyclops.set_child(Health(45))
    cyclops.set_child(DataPoint(DataTypes.MOVEMENT_SPEED, gametime.single_turn))
    cyclops.set_child(DataPoint(DataTypes.THROW_SPEED, gametime.double_turn))
    cyclops.set_child(DataPoint(DataTypes.STRENGTH, 21))
    cyclops.set_child(DataPoint(DataTypes.EVASION, 7))
    cyclops.set_child(DataPoint(DataTypes.ACCURACY, 9))
    cyclops.set_child(DataPoint(DataTypes.ARMOR, 6))
    cyclops.set_child(DataPoint(DataTypes.AWARENESS, 3))
    cyclops.set_child(DataPoint(DataTypes.MOVEMENT_SPEED, gametime.one_and_half_turn))
    cyclops.set_child(DataPoint(DataTypes.THROW_SPEED, gametime.double_turn))
    cyclops.set_child(DataPoint(DataTypes.MELEE_DAMAGE_MULTIPLIER, 0.5))
    cyclops.set_child(ThrowRockAttacker())

    cyclops.set_child(MonsterThrowRockAction(900))
    cyclops.set_child(DataPoint(DataTypes.MINIMUM_DEPTH, 5))
    return cyclops
Пример #2
0
 def __init__(self, pos):
     super().__init__(
         "https://raw.githubusercontent.com/CalhamZeKoala/GameImg/master/bluecircle.png",
         (50, 50), pos, 1)
     self.cooldown = randint(100, 140)
     self.cooldown_max = self.cooldown
     self.radius = 25
     self.border = 1
     self.dazeCount = 0
     self.health = Health()
Пример #3
0
 def __init__(self, pos):
     super().__init__(
         "https://raw.githubusercontent.com/CalhamZeKoala/GameImg/master/fancycircle.png",
         (50, 50), pos, 1)
     self.radius = 25
     self.border = 1
     self.dazeCount = 0
     self.count = 0
     self.health = Health()
     self.currentlyAttacking = True
     self.attackCount = 0
Пример #4
0
def create_player(x, y):
    return Entity(
        Player(),
        Position(x, y, Position.ORDER_PLAYER),
        Actor(100, player_act),
        FOV(10),
        Movement(),
        Renderable(player_tex),
        Blocker(blocks_movement=True),
        Health(100),
        Fighter(1, 0),
        Inventory(),
    )
Пример #5
0
def create_random_monster(x, y):
    name, tex = get_random_monster_params()
    monster = Entity(
        Actor(80, monster_act),
        Position(x, y, Position.ORDER_CREATURES),
        Movement(),
        Renderable(tex),
        Blocker(blocks_movement=True, bump_function=monster_bump),
        Health(2),
        Fighter(1, 0),
        CorpseGenerator(),
        InFOV(),
        Description(name),
    )
    return monster
Пример #6
0
def new_training_dummy(gamestate):
    monster = Composite()
    set_monster_components(monster, gamestate)

    monster.set_child(Description("Training Dummy", "A Man hybrid, it looks hostile."))
    monster.set_child(EntityMessages("The monster looks at you.", "The monster falls dead."))
    monster.set_child(GraphicChar(None, colors.CHAMPAGNE, icon.STATUE))

    monster.set_child(Health(80))
    monster.set_child(DataPoint(DataTypes.STRENGTH, 3))
    monster.set_child(DataPoint(DataTypes.EVASION, 8))
    monster.set_child(DataPoint(DataTypes.ACCURACY, 13))
    monster.set_child(DataPoint(DataTypes.ARMOR, 100))
    monster.set_child(DataPoint(DataTypes.AWARENESS, 5))
    monster.set_child(DataPoint(DataTypes.MINIMUM_DEPTH, 99999))
    monster.set_child(DoNothingActor())
    return monster
Пример #7
0
def new_worm(gamestate):
    worm = Composite()
    set_monster_components(worm, gamestate)

    worm.set_child(Description("Worm", "It's a giant earth worm."))
    worm.set_child(EntityMessages("The worm wiggles at you.", "The worm stops moving."))
    worm.set_child(GraphicChar(None, colors.PINK, icon.BLOOD7 + 4))

    worm.set_child(Health(4))
    worm.set_child(DataPoint(DataTypes.STRENGTH, 3))
    worm.set_child(DataPoint(DataTypes.EVASION, 6))
    worm.set_child(DataPoint(DataTypes.ACCURACY, 5))
    worm.set_child(DataPoint(DataTypes.ARMOR, 2))
    worm.set_child(DataPoint(DataTypes.AWARENESS, 3))
    worm.set_child(DataPoint(DataTypes.MOVEMENT_SPEED, gametime.one_and_half_turn))

    return worm
Пример #8
0
    def __init__(self, player_number):
        self.__player_number = player_number
        # def classes objects
        self.__scenario_obj = Scenario()
        self.__professions_obj = Professions()
        self.__health_obj = Health()
        self.__bio_characteristic_obj = BIO()
        self.__additional_info_obj = AInfo()
        self.__personality_trains_obj = PTrains()
        self.__hobbies_obj = Hobbies()
        self.__phobias_obj = Phobias()
        self.__special_info_obj = SInfo()

        self.__load_data()
        self.__shuffle_data()
        self.__create_players()
        self.__make_players_files()
Пример #9
0
 def get_treasure(cls, treasure):  # treasure is the treasure as string
     kind = treasure.split(':')[0].rstrip(
         ' ')  # ':' splits the kind of treasure and it's description
     descr = treasure.split(':')[1]
     if kind == "weapon":
         from weapon import Weapon
         return Weapon.create_weapon(descr)
     if kind == "spell":
         from spell import Spell
         return Spell.create_spell(descr)
     elif kind == "mana":
         from mana import Mana
         return Mana(int(descr))
     elif kind == "health":
         from health import Health
         return Health(int(descr))
     else:
         raise ValueError("Not correct kind of treasure.")
Пример #10
0
def new_dust_demon(gamestate):
    demon = Composite()
    set_monster_components(demon, gamestate)
    set_humanoid_components(demon)

    demon.set_child(Description("Dust Demon", "The demon constantly creates dust clouds."))
    demon.set_child(EntityMessages("The dust demon notices you.", "The demon falls to the ground."))
    demon.set_child(GraphicChar(None, colors.GRAY, icon.DEMON))

    demon.set_child(Health(12))
    demon.set_child(DataPoint(DataTypes.STRENGTH, 5))
    demon.set_child(DataPoint(DataTypes.EVASION, 8))
    demon.set_child(DataPoint(DataTypes.ACCURACY, 10))
    demon.set_child(DataPoint(DataTypes.ARMOR, 8))
    demon.set_child(DataPoint(DataTypes.AWARENESS, 4))

    demon.set_child(MakeDustClouds())
    demon.set_child(DataPoint(DataTypes.MINIMUM_DEPTH, 4))
    return demon
Пример #11
0
def GetHealth_api():
    mongo = PyMongo(app)
    datatype = request.args.get('type', 0)
    duration = request.args.get('duration')
    time = request.args.get('time', 0)
    day = int(time.split('/',2)[1])
    month = int(time.split('/',2)[0])

    if current_user.is_active:
        user = current_user.id
        person = mongo.db.Select_People.find({'username': user})[0]['person']
        health = Health(person)
        #處理天
        if duration != 'false':
            x_time,y_data = health.Day(datatype,day,month)
        #處理週
        else:
            x_time,y_data = health.Week(datatype)
    return jsonify(x_time,y_data)
Пример #12
0
def new_slime(game_state):
    slime = Composite()
    set_monster_components(slime, game_state)
    set_slime_components(slime)

    slime.set_child(SlimeCanShareTileEntityMover())
    slime.set_child(DissolveEntitySlimeShareTileEffect())
    slime.set_child(EntityMessages("The slime seems to wobble with happiness.", "The slime melts away."))
    slime.set_child(Description("Slime",
                                "Slime, slime, slime. Ugh, I hate Slimes." "The slime seem to sense at you..."))
    slime.set_child(GraphicChar(None, colors.GREEN, icon.SLIME))
    slime.set_child(Health(35))
    slime.set_child(DataPoint(DataTypes.STRENGTH, 2))
    slime.set_child(DataPoint(DataTypes.EVASION, 6))
    slime.set_child(DataPoint(DataTypes.ACCURACY, 12))
    slime.set_child(DataPoint(DataTypes.ARMOR, 3))
    slime.set_child(DataPoint(DataTypes.AWARENESS, 5))
    slime.set_child(DataPoint(DataTypes.MINIMUM_DEPTH, 3))
    slime.set_child(DataPoint(DataTypes.CLONE_FUNCTION, new_slime))
    return slime
Пример #13
0
def new_skeleton(gamestate):
    skeleton = Composite()
    set_monster_components(skeleton, gamestate)
    set_skeleton_components(skeleton)

    skeleton.set_child(LeaveCorpseTurnIntoEntityOnDeath(new_skeleton, 0.5))

    skeleton.set_child(Description("Skeleton", "An undead skeleton it looks hostile."))
    skeleton.set_child(EntityMessages("The skeleton turns to you.", "The skeleton falls in a pile of bones."))
    skeleton.set_child(GraphicChar(None, colors.WHITE, icon.SKELETON_WARRIOR))

    skeleton.set_child(Health(10))
    skeleton.set_child(DataPoint(DataTypes.STRENGTH, 6))
    skeleton.set_child(DataPoint(DataTypes.EVASION, 11))
    skeleton.set_child(DataPoint(DataTypes.ACCURACY, 10))
    skeleton.set_child(DataPoint(DataTypes.ARMOR, 12))
    skeleton.set_child(DataPoint(DataTypes.AWARENESS, 4))

    skeleton.set_child(DataPoint(DataTypes.MINIMUM_DEPTH, 4))
    return skeleton
Пример #14
0
def new_floating_eye(game_state):
    c = Composite()
    set_monster_components(c, game_state)
    c.set_child(StatusFlags([StatusFlags.IS_ALIVE, StatusFlags.FLYING]))
    c.set_child(DataPoint(DataTypes.INTELLIGENCE, IntelligenceLevel.PLANT))

    c.set_child(EntityMessages("The eye looks intently.", "The eye falls to the ground."))
    c.set_child(Description("Floating Eye",
                            "A giant eye floating in mid-air How is this even possible?"
                            "The eye stairs at you..."))
    c.set_child(GraphicChar(None, colors.WHITE, icon.EYE))
    c.set_child(Health(20))
    c.set_child(DataPoint(DataTypes.STRENGTH, 4))
    c.set_child(DataPoint(DataTypes.EVASION, 8))
    c.set_child(DataPoint(DataTypes.ACCURACY, 12))
    c.set_child(DataPoint(DataTypes.ARMOR, 0))
    c.set_child(DataPoint(DataTypes.MOVEMENT_SPEED, gametime.one_and_half_turn))
    c.set_child(DataPoint(DataTypes.AWARENESS, 10))
    c.set_child(ParalyzeOnStare(0, c.sight_radius.value, 100))
    c.set_child(KeepPlayerAtDistanceActor(3))
    return c
Пример #15
0
def new_ghost(gamestate):
    ghost = Composite()
    set_monster_components(ghost, gamestate)
    set_ghost_components(ghost)

    ghost.set_child(EntityMessages("The ghost sees you.", "The ghost fades away."))
    ghost.set_child(Description("Ghost", "A spirit of a hunted creature."))
    ghost.set_child(GraphicChar(None, colors.LIGHT_BLUE, icon.GHOST))
    ghost.set_child(Health(1))
    ghost.set_child(DataPoint(DataTypes.STRENGTH, 2))
    ghost.set_child(DataPoint(DataTypes.EVASION, 14))
    ghost.set_child(DataPoint(DataTypes.ACCURACY, 9))
    ghost.set_child(DataPoint(DataTypes.ARMOR, 0))
    ghost.set_child(DataPoint(DataTypes.MOVEMENT_SPEED, gametime.single_turn + gametime.one_third_turn))
    ghost.set_child(DataPoint(DataTypes.AWARENESS, 8))

    ghost.set_child(KeepPlayerAtDistanceActor(4))
    ghost.set_child(SpiritMissile(150))
    ghost.set_child(AddGhostReviveToSeenEntities())
    ghost.set_child(DataPoint(DataTypes.MINIMUM_DEPTH, 2))
    return ghost
Пример #16
0
def new_ratman(gamestate):
    ratman = Composite()
    set_monster_components(ratman, gamestate)
    set_humanoid_components(ratman)

    ratman.set_child(Description("Ratman", "A Rat/Man hybrid, it looks hostile."))
    ratman.set_child(EntityMessages("The ratman looks at you.", "The ratman falls dead."))
    ratman.set_child(GraphicChar(None, colors.ORANGE, icon.RATMAN))

    ratman.set_child(Health(10))
    ratman.set_child(DataPoint(DataTypes.STRENGTH, 3))
    ratman.set_child(DataPoint(DataTypes.EVASION, 10))
    ratman.set_child(DataPoint(DataTypes.ACCURACY, 6))
    ratman.set_child(DataPoint(DataTypes.ARMOR, 4))
    ratman.set_child(DataPoint(DataTypes.AWARENESS, 5))

    ratman.set_child(MonsterThrowStoneAction(20))
    ratman.set_child(ThrowRockAttacker())

    ratman.set_child(DataPoint(DataTypes.MINIMUM_DEPTH, 1))
    return ratman
Пример #17
0
def new_spider(gamestate):
    spider = Composite()
    set_monster_components(spider, gamestate)
    set_insect_components(spider)

    spider.set_child(Description("Spider", "A giant spider, its attacks are poisonous."))
    spider.set_child(EntityMessages("The spider looks at you.", "The spider stops moving."))
    spider.set_child(GraphicChar(None, colors.CHAMPAGNE_D, icon.SPIDER))

    spider.set_child(Health(9))
    spider.set_child(DataPoint(DataTypes.STRENGTH, 1))
    spider.set_child(DataPoint(DataTypes.EVASION, 8))
    spider.set_child(DataPoint(DataTypes.ACCURACY, 5))
    spider.set_child(DataPoint(DataTypes.ARMOR, 7))
    spider.set_child(DataPoint(DataTypes.AWARENESS, 5))

    spider.set_child(MakeSpiderWebs())
    spider.set_child(Flag(Immunities.SPIDER_WEB))
    #spider.set_child(UnArmedHitTargetEntityEffectFactory(PoisonEntityEffectFactory(spider, random.randrange(4, 8), 2, 20)))
    spider.set_child(PoisonAttackEffect(1.0))
    spider.set_child(DataPoint(DataTypes.MINIMUM_DEPTH, 3))
    return spider
Пример #18
0
def new_giant_amoeba(game_state):
    amoeba = Composite()
    set_monster_components(amoeba, game_state)
    amoeba.set_child(StatusFlags([StatusFlags.IS_ALIVE]))
    amoeba.set_child(DataPoint(DataTypes.INTELLIGENCE, IntelligenceLevel.PLANT))

    amoeba.set_child(EntityMessages("The amoeba seems to wobble with happiness.", "The amoeba melts away."))
    amoeba.set_child(Description("Giant Amoeba",
                                 "A giant amoeba... How is this even possible?"
                                 "The amoeba seems to wobble in your direction..."))
    amoeba.set_child(GraphicChar(None, colors.LIGHT_GREEN, "0"))
    amoeba.set_child(Health(20))
    amoeba.set_child(DataPoint(DataTypes.STRENGTH, 4))
    amoeba.set_child(DataPoint(DataTypes.EVASION, 5))
    amoeba.set_child(DataPoint(DataTypes.ACCURACY, 12))
    amoeba.set_child(DataPoint(DataTypes.ARMOR, 4))
    amoeba.set_child(DataPoint(DataTypes.MOVEMENT_SPEED, gametime.single_turn + gametime.one_third_turn))
    amoeba.set_child(DataPoint(DataTypes.AWARENESS, 5))

    amoeba.set_child(DataPoint(DataTypes.CLONE_FUNCTION, new_giant_amoeba))
    amoeba.set_child(NaturalHealthRegain())
    amoeba.set_child(SplitAtFullHealth())
    return amoeba
Пример #19
0
def new_pixie(gamestate):
    pixie = Composite()
    set_monster_components(pixie, gamestate)
    set_humanoid_components(pixie)
    pixie.set_child(StatusFlags([StatusFlags.CAN_OPEN_DOORS, StatusFlags.FLYING,
                                 StatusFlags.IS_ALIVE, StatusFlags.HAS_HEART]))

    pixie.set_child(EntityMessages("The pixie sees you.", "The pixie falls."))
    pixie.set_child(Description("Pixie", "A small humanoid with insect wings."))
    pixie.set_child(GraphicChar(None, colors.PINK, icon.PIXIE))
    pixie.set_child(Health(12))
    pixie.set_child(DataPoint(DataTypes.STRENGTH, 2))
    pixie.set_child(DataPoint(DataTypes.EVASION, 12))
    pixie.set_child(DataPoint(DataTypes.ACCURACY, 10))
    pixie.set_child(DataPoint(DataTypes.ARMOR, 2))
    pixie.set_child(DataPoint(DataTypes.MOVEMENT_SPEED, gametime.two_thirds_turn))
    pixie.set_child(DataPoint(DataTypes.AWARENESS, 8))

    pixie.set_child(KeepPlayerAtDistanceActor(4))
    pixie.set_child(MonsterHealTargetEntityEffect(50))
    pixie.set_child(MonsterTripTargetEffect(50))
    pixie.set_child(DataPoint(DataTypes.MINIMUM_DEPTH, 6))
    return pixie
Пример #20
0
def new_armored_beetle(gamestate):
    beetle = Composite()
    set_insect_components(beetle)
    set_monster_components(beetle, gamestate)

    beetle.set_child(
        Description("Armored Beetle", "A giant armored beetle, it looks like it wouldn't budge for anything."))
    beetle.set_child(EntityMessages("The armored beetle notices you.", "The armored beetle is dead."))
    beetle.set_child(GraphicChar(None, colors.PURPLE, icon.BEETLE))

    beetle.set_child(Health(17))
    beetle.set_child(DataPoint(DataTypes.STRENGTH, 2))
    beetle.set_child(DataPoint(DataTypes.EVASION, 5))
    beetle.set_child(DataPoint(DataTypes.ACCURACY, 12))
    beetle.set_child(DataPoint(DataTypes.ARMOR, 15))
    beetle.set_child(DataPoint(DataTypes.AWARENESS, 2))

    beetle.set_child(DataPoint(DataTypes.MOVEMENT_SPEED, gametime.single_turn + gametime.one_third_turn))
    beetle.set_child(DataPoint(DataTypes.MINIMUM_DEPTH, 4))

    beetle.set_child(PushBackAttacker())

    return beetle
Пример #21
0
def new_salamander(gamestate):
    salamander = Composite()
    set_monster_components(salamander, gamestate)
    set_beast_components(salamander)

    salamander.set_child(Description("Salamander", "A salamander, it can start small fires."))
    salamander.set_child(EntityMessages("The salamander looks at you.", "The salamander stops moving."))
    salamander.set_child(GraphicChar(None, colors.RED, icon.SALAMANDER))

    salamander.set_child(Health(20))
    salamander.set_child(DataPoint(DataTypes.STRENGTH, 3))
    salamander.set_child(DataPoint(DataTypes.EVASION, 8))
    salamander.set_child(DataPoint(DataTypes.ACCURACY, 10))
    salamander.set_child(DataPoint(DataTypes.ARMOR, 4))
    salamander.set_child(DataPoint(DataTypes.AWARENESS, 5))

    salamander.set_child(NaturalHealthRegain())
    salamander.set_child(PutAdjacentTilesOnFire())
    salamander.set_child(FireImmunity())
    salamander.set_child(TolerateDamage(DamageTypes.FIRE))
    salamander.set_child(DataPoint(DataTypes.MINIMUM_DEPTH, 4))

    return salamander
Пример #22
0
def new_ratman_mystic(gamestate):
    ratman = Composite()
    set_monster_components(ratman, gamestate)
    set_humanoid_components(ratman)

    ratman.set_child(Description("Ratman Mystic", "A Rat/Man hybrid, it looks hostile."))
    ratman.set_child(EntityMessages("The ratman looks at you.", "The ratman falls dead."))
    ratman.set_child(GraphicChar(None, colors.PURPLE, icon.RATMAN))

    ratman.set_child(Health(7))
    ratman.set_child(DataPoint(DataTypes.STRENGTH, 2))
    ratman.set_child(DataPoint(DataTypes.EVASION, 10))
    ratman.set_child(DataPoint(DataTypes.ACCURACY, 8))
    ratman.set_child(DataPoint(DataTypes.ARMOR, 3))
    ratman.set_child(DataPoint(DataTypes.AWARENESS, 6))

    ratman.set_child(SpiritMissile(15))
    ratman.set_child(SummonEntityMonsterAction(new_worm, 5, 20))
    ratman.set_child(DataPoint(DataTypes.MOVEMENT_SPEED, gametime.single_turn + gametime.quarter_turn))

    ratman.set_child(KeepPlayerAtDistanceActor(4))

    ratman.set_child(DataPoint(DataTypes.MINIMUM_DEPTH, 3))
    return ratman
Пример #23
0
def singleplayer_screen():
    player_sprites_list = pygame.sprite.Group()
    player2_sprites_list = pygame.sprite.Group()
    enemy_sprites_list = pygame.sprite.Group()
    bullet_sprites_list = pygame.sprite.Group()
    health_sprites_list = pygame.sprite.Group()

    num_health = 3
    num_health2 = 7
    hearts = []
    hearts2 = []

    for count in range(num_health):
        elem = Health(WHITE, 20, 20)
        health_sprites_list.add(elem)
        elem.rect.x = count * 64
        elem.rect.y = 0
        hearts.append(elem)
        hearts2.append(elem)

    main_player = Player(RED, 64, 64)
    player2 = Player(RED, 80, 80)

    player_sprites_list.add(main_player)
    player2_sprites_list.add(player2)

    main_player.rect.x = 20
    main_player.rect.y = HEIGHT / 2

    player2.rect.x = 20
    player2.rect.y = HEIGHT / 2

    invincible = False  # After-hit invincibility state
    running = True
    start_time = pygame.time.get_ticks()

    horizon = list(
        pygame.image.load("Assets/Backgrounds/horizon.png").get_rect().size)
    borders = [WIDTH, HEIGHT, horizon[1]]
    bck_image_width = horizon[0]

    background = pygame.image.load(
        "Assets/Backgrounds/background.png").convert_alpha()
    background_horizon = pygame.image.load(
        "Assets/Backgrounds/horizon.png").convert_alpha()

    offset = 0
    offset2 = -bck_image_width

    game_loop = True
    while game_loop:

        # Main event loop
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                game_loop = False
            elif event.type == INVINCIBILITY_END:
                invincible = False
                pygame.time.set_timer(INVINCIBILITY_END, 0)

            elif event.type == pygame.USEREVENT:
                if event.dict["subtype"] == PLAYERS_CAN_SHOOT:
                    for player in player_sprites_list:
                        player.can_shoot = True

                elif event.dict["subtype"] == BASIC_ZOMBIE_SPAWN:
                    new_enemy = BasicZombie(64, 64)
                    new_enemy.rect.x = WIDTH - 64
                    new_enemy.rect.y = random.randint(64, borders[1] - 64)
                    enemy_sprites_list.add(new_enemy)

                elif event.dict["subtype"] == FLYING_ZOMBIE_SPAWN:
                    new_enemy = FlyingZombie(64, 64)
                    new_enemy.rect.x = WIDTH - 64
                    new_enemy.rect.y = random.randint(0, borders[2] - 64)
                    enemy_sprites_list.add(new_enemy)

        keys = pygame.key.get_pressed()
        # Movement event
        if keys[keybindings['left']]:
            main_player.moveLeft()
        if keys[keybindings['right']]:
            main_player.moveRight(borders)
        if keys[keybindings['up']]:
            main_player.moveUp(borders)
        if keys[keybindings['down']]:
            main_player.moveDown(borders)

        if keys[keybindings['left2']]:
            player2.moveLeft()
        if keys[keybindings['right2']]:
            player2.moveRight(borders)
        if keys[keybindings['up2']]:
            player2.moveUp(borders)
        if keys[keybindings['down2']]:
            player2.moveDown(borders)

        # Fire event
        if keys[keybindings['fire']]:
            bullet = main_player.shoot()
            if bullet:
                bullet_sprites_list.add(bullet)

        if keys[keybindings['acidspit']]:
            spit = player2.shoot()
            if spit:
                bullet_sprites_list.add(spit)

        counting_time = pygame.time.get_ticks() - start_time

        # change milliseconds into minutes, seconds, milliseconds
        counting_minutes = 5 - (counting_time / 60000)
        counting_seconds = int(60 - (counting_time % 60000) / 1000)

        counting_string = "%d:%d" % (counting_minutes, counting_seconds)

        # counting_rect = counting_text.get_rect(midtop=screen.get_rect().midtop)
        counting_text = debug_font.render(str(counting_string), 1,
                                          (255, 255, 255))
        counting_rect = counting_text.get_rect(midtop=screen.get_rect().midtop)

        screen.blit(counting_text, counting_rect)
        if int(counting_minutes) == 0 and counting_seconds == 0:
            game_loop = False
        # screen.blit(counting_text, counting_rect)
        # pygame.display.update()

        # Game logic
        # Kills enemy when they collide with player
        for enemy in pygame.sprite.groupcollide(bullet_sprites_list,
                                                enemy_sprites_list, 1, 1):
            pass

        for player in pygame.sprite.groupcollide(player_sprites_list,
                                                 enemy_sprites_list, 0, 0):
            if not invincible:
                current = hearts[-1]
                current.kill()
                del hearts[-1]
                invincible = True
                pygame.time.set_timer(INVINCIBILITY_END,
                                      INVINCIBILITY_DURATION)

        for player in pygame.sprite.groupcollide(player_sprites_list,
                                                 player2_sprites_list, 0, 0):
            if not invincible:
                current = hearts[-1]
                current.kill()
                del hearts[-1]
                invincible = True
                pygame.time.set_timer(INVINCIBILITY_END,
                                      INVINCIBILITY_DURATION)

        for player in pygame.sprite.groupcollide(player2_sprites_list,
                                                 player_sprites_list, 0, 0):
            if not invincible:
                current = hearts[-1]
                current.kill()
                del hearts[-1]
                invincible = True
                pygame.time.set_timer(INVINCIBILITY_END,
                                      INVINCIBILITY_DURATION)

        if not hearts:
            pygame.sprite.groupcollide(player_sprites_list, enemy_sprites_list,
                                       1, 0)

        if not hearts2:
            pygame.sprite.groupcollide(player2_sprites_list,
                                       player_sprites_list, 1, 0)

        player_sprites_list.update()
        player2_sprites_list.update()
        enemy_sprites_list.update()
        bullet_sprites_list.update()
        health_sprites_list.update()

        # Drawing logic
        offset += 1
        offset2 += 1
        screen.blit(background, (-offset, 0))
        screen.blit(background_horizon, (-offset, 0))

        screen.blit(background, (-offset2, 0))
        screen.blit(background_horizon, (-offset2, 0))

        if offset > bck_image_width:
            offset = -bck_image_width
        if offset2 > bck_image_width:
            offset2 = -bck_image_width

        # FPS counter
        fps_str = "".join(["FPS: ", str(int(clock.get_fps()))])
        fps = debug_font.render(fps_str, True, WHITE)
        screen.blit(fps, (50, 50))

        # Timer counter
        counting_text = timer_font.render(str(counting_string), True, WHITE)
        screen.blit(counting_text, (WIDTH / 2, 10))

        player_sprites_list.draw(screen)
        player2_sprites_list.draw(screen)
        enemy_sprites_list.draw(screen)
        bullet_sprites_list.draw(screen)
        health_sprites_list.draw(screen)

        # Screen update
        pygame.display.flip()
        clock.tick(60)

        # Timer updates
        generate_time_based_events()

    def multiplayer_screen():
        pass

    def options_screen():
        pass

    def help_screen():
        pass
Пример #24
0
    def __init__(self, screen, endless = False):
        self.screen = screen

        self.sharks = []
        self.shark_sprites = pygame.sprite.Group()

        self.player = Steamboat()
        self.player_sprite = pygame.sprite.Group()
        self.player_sprite.add(self.player)

        self.health = Health()
        self.health_sprite = pygame.sprite.Group()
        self.health_sprite.add(self.health)

        self.damage_count = 0

        self.t = 0

        self.water = Water.global_water
        #Water.global_water = self.water
        self.water_sprite = pygame.sprite.Group()
        self.water_sprite.add(self.water)

        if not Game.sky:
            Game.sky = util.load_image("taivas")
            Game.sky = pygame.transform.scale(self.sky, (SCREEN_WIDTH, SCREEN_HEIGHT))

        self.cannonballs = []
        self.cannonball_sprites = pygame.sprite.Group()

        self.pirates = []
        self.pirate_sprites = pygame.sprite.Group()

        self.titanic = None
        self.titanic_sprite = pygame.sprite.Group()

        self.seagulls = []
        self.seagull_sprites = pygame.sprite.Group()

        self.particles = Particles()
        self.particle_sprite = pygame.sprite.Group()
        self.particle_sprite.add(self.particles)

        self.mines = []
        self.mine_sprites = pygame.sprite.Group()

        self.score = Score()
        self.score_sprite = pygame.sprite.Group()
        self.score_sprite.add(self.score)

        self.powerups = []
        self.powerup_sprites = pygame.sprite.Group()

        self.level = Level(endless)

        self.lastshot = MIN_FIRE_DELAY + 1

        self.gameover = False
        self.gameover_image = None
        self.gameover_rect = None
        self.done = False

        self.pause = False
        self.pause_image = util.bigfont.render("Pause", Variables.alpha, (0,0,0))
        self.pause_rect = self.pause_image.get_rect()
        self.pause_rect.center = self.screen.get_rect().center

        self.spacepressed = None
Пример #25
0
# === Create skeleton object ===

enemyGroup = pygame.sprite.Group()

for _ in range(1, 3):
    surface2 = pygame.Surface([10, 20], pygame.SRCALPHA)
    skeleton = Bones(surface2, False, False, random.randint(10, 20))
    skeleton.rect.x = random.randint(500, 1000)
    skeleton.rect.y = 407
    enemyGroup.add(skeleton)
    all_sprites_list.add(skeleton)

# === Create heart object ===
surface3 = pygame.Surface([1100, 650], pygame.SRCALPHA)
heart = Health(surface3)
heart.rect.x = 1100
heart.rect.y = 650
itemsGroup = pygame.sprite.Group(heart)
all_sprites_list.add(heart)

itemsGroup.update()
characterGroup.update()

Menu(screen, menuFont, Width)

# creating 2d array
grid = [[n] * 25 for n in range(15)]

# moon
grid[0][3] = -4