Exemplo n.º 1
0
def load_data():  # load all image datas of enemy
    an = animation.Animation()
    an.build_animation('idle', ['items/item1'], 1.5)
    Item.TYPES["power"] = {"id": 1, "animation": an}
    an = animation.Animation()
    an.build_animation('idle', ['items/item2'], 1.5)
    Item.TYPES["point"] = {"id": 2, "animation": an}
    an = animation.Animation()
    an.build_animation('idle', ['items/item3'], 1.5)
    Item.TYPES["starpoint"] = {"id": 3, "animation": an}
    an = animation.Animation()
    an.build_animation('idle', ['items/item4'], 1.5)
    Item.TYPES["largepower"] = {"id": 4, "animation": an}
    an = animation.Animation()
    an.build_animation('idle', ['items/item5'], 1.5)
    Item.TYPES["largepoint"] = {"id": 5, "animation": an}
    an = animation.Animation()
    an.build_animation('idle', ['items/item6'], 1.5)
    Item.TYPES["fullpower"] = {"id": 6, "animation": an}
    an = animation.Animation()
    an.build_animation('idle', ['items/item7'], 1.5)
    Item.TYPES["life"] = {"id": 7, "animation": an}
    an = animation.Animation()
    an.build_animation('idle', ['items/item8'])
    Item.TYPES["smallpoint"] = {"id": 8, "animation": an}
Exemplo n.º 2
0
def initTest():
    startDelTest()
    img_master = image.Image("data/bin>img.png", 1.0)
    img_sub = image.SubImage(img_master)

    share.img = img_sub
    #share.img.moveScreenRect(xdiff=-300, ydiff=-400)
    share.img.moveScreenRect(xdiff=-100, ydiff=-500)
    share.img.moveScreenRect(xdiff=-200, ydiff=100)

    share.label = label.Label("test", share.font)
    share.label.setLabel("test setLabel", share.font)
    share.label.setScreenRectCenter()
    share.label.moveScreenRect(ydiff=100)

    noise = music.Music("data/bin>noise.wav")
    noisec = music.Chunk("data/bin>noise.wav")
    music.bgm.load(noise)
    #music.bgm.play(0)
    music.channel[0].load(noisec)
    #music.channel[0].play(0)

    share.anime_img = image.Image("data/bin>anime.png")
    share.anime = animation.Animation(
        0.5,
        (image.SubImage(share.anime_img, i % 5 * 192, i / 5 * 192, 192, 192)
         for i in xrange(13)))
    share.anime.setScreenRectCenter()
Exemplo n.º 3
0
def load_data():
    '''
    load data
    '''
    an = animation.Animation()
    an.build_animation('idle', ['enemy/margatroid'], 0.8)
    Boss.TYPES["margatroid"] = {"id": 0, "animation": an}
Exemplo n.º 4
0
def load_data():  # load all image datas of enemy
    an = animation.Animation()
    an.build_animation(
        'left', ['enemy/redsprite1', 'enemy/redsprite2', 'enemy/redsprite3'])
    an.build_animation(
        'idle', ['enemy/redsprite4', 'enemy/redsprite5', 'enemy/redsprite6'])
    an.build_animation(
        'right', ['enemy/redsprite7', 'enemy/redsprite8', 'enemy/redsprite9'])
    Enemy.TYPES["redsprite"] = {"id": 0, "animation": an}

    an = animation.Animation()
    an.build_animation('left', ['enemy/bluesprite5'], 1.5)
    an.build_animation('idle', [
        'enemy/bluesprite1', 'enemy/bluesprite2', 'enemy/bluesprite3',
        'enemy/bluesprite4'
    ], 1.5)
    an.build_animation('right', ['enemy/bluesprite5'], 1.5, flip=[True, False])
    Enemy.TYPES["bluesprite"] = {"id": 1, "animation": an}

    an = animation.Animation()
    an.build_animation('left', ['enemy/yellowsprite5'], 1.5)
    an.build_animation('idle', [
        'enemy/yellowsprite1', 'enemy/yellowsprite2', 'enemy/yellowsprite3',
        'enemy/yellowsprite4'
    ], 1.5)
    an.build_animation('right', ['enemy/yellowsprite5'],
                       1.5,
                       flip=[True, False])
    Enemy.TYPES["yellowsprite"] = {"id": 2, "animation": an}

    an = animation.Animation()
    an.build_animation('left', ['enemy/greensprite5'], 1.5)
    an.build_animation('idle', [
        'enemy/greensprite1', 'enemy/greensprite2', 'enemy/greensprite3',
        'enemy/greensprite4'
    ], 1.5)
    an.build_animation('right', ['enemy/greensprite5'],
                       1.5,
                       flip=[True, False])
    Enemy.TYPES["greensprite"] = {"id": 3, "animation": an}

    an = animation.Animation()
    an.build_animation('left', ['ruri/RuriA02'])
    an.build_animation('idle', ['ruri/RuriA02'])
    an.build_animation('right', ['ruri/RuriA-02'])
    Enemy.TYPES["kimonoruri"] = {"id": 4, "animation": an}

    an = animation.Animation()
    an.build_animation('left', ['ruri/RuriB02'])
    an.build_animation('idle', ['ruri/RuriB02'])
    an.build_animation('right', ['ruri/RuriB-02'])
    Enemy.TYPES["katanaruri"] = {"id": 5, "animation": an}

    for i in range(4):
        an = animation.Animation()
        an.build_animation('left', [f'enemy/mess{i+1}'], 1.5)
        an.build_animation('idle', [f'enemy/mess{i+1}'], 1.5)
        an.build_animation('right', [f'enemy/mess{i+1}'], 1.5)
        Enemy.TYPES[f"mess{i+1}"] = {"id": 6, "animation": an}
Exemplo n.º 5
0
def load_data():
    # load data
    an = animation.Animation()
    for i in range(1, 6):
        an.build_animation(f'{i}', [f'effect/circle{i}'])
    Effect.TYPES["circle"] = {"id": 0, "animation": an}

    an = animation.Animation()
    an.build_animation('1', [f'effect/maple'])
    Effect.TYPES['maple'] = {"id": 2, "animation": an}

    an = animation.Animation()
    an.build_animation('1', [f'effect/hp'])
    Effect.TYPES['hp'] = {"id": 3, "animation": an}

    an = animation.Animation()
    for i in range(1, 3):
        an.build_animation(f'{i}', [f'effect/bossback{i}'])
    Effect.TYPES["bossback"] = {"id": 4, "animation": an}

    an = animation.Animation()
    an.build_animation('1', [f'effect/eback'])
    Effect.TYPES['eback'] = {"id": 5, "animation": an}
Exemplo n.º 6
0
    def __init__(self):
        pygame.sprite.Sprite.__init__(self)

        self.actor_type = ACTOR_NONE
        self.can_collide = False
        self.active = False
        self.hitrect = pygame.Rect(0, 0, 0, 0)
        self.hitrect_offset_x = 0
        self.hitrect_offset_y = 0
        self.object_collided_with = self
        self.bound_style = None
        self.animation_list = animation.Animation()
        self.image = None
        self.position = vector.Vector2d(0, 0)
        self.bounds = 0, 0, 0, 0
Exemplo n.º 7
0
    def __init__(self):
        # init
        pygame.sprite.Sprite.__init__(self)

        self.sprite_type = SPRITE_NONE
        self.can_collide = False
        self.active = True
        self.rect = pygame.Rect(0, 0, 0, 0)
        self.hitrect = pygame.Rect(0, 0, 0, 0)
        self.collided_with = self
        self.bound_style = BOUND_BLOCK,
        self.animation = animation.Animation()
        self.image = None
        self.position = vector.objVector(0, 0)
        self.velocity = vector.objVector(0, 0)
        self.acceleration = vector.objVector(0, 0)
        self.bounds = 0, 0, 0, 0
Exemplo n.º 8
0
class Cursor(actor.Actor):
    master_animation_list = animation.Animation()

    def __init__(self):
        actor.Actor.__init__(self)

        self.animation_list = copy.copy(self.master_animation_list)
        self.animation_list.set_parent(self)
        self.animation_list.play('Idle')
        self.rect = self.image.get_rect()
        self.bound_style == BOUND_STYLE_CLAMP
        self.bounds = 32, 32, SCREEN_WIDTH, SCREEN_HEIGHT
        self.position = vector.Vector2d.zero
        self.velocity = vector.Vector2d.zero

    def mouse_over(self):
        pass
Exemplo n.º 9
0
class Hakta(enemy.Enemy):
    death_sound = None
    master_animation_list = animation.Animation()

    def __init__(self, target_object, group_list):
        enemy.Enemy.__init__(self)

        # COMMON VARIABLES
        self.actor_type = ACTOR_TYPE_ENEMY
        self.animation_list = copy.copy(self.master_animation_list)
        self.animation_list.set_parent(self)
        self.animation_list.play('Idle')
        self.rect = self.image.get_rect()
        self.bound_style = BOUND_STYLE_CUSTOM
        self.bounds = 32, 32, SCREEN_WIDTH - 32, SCREEN_HEIGHT - 32
        self.can_collide = True
        self.hitrect = pygame.Rect(0, 0, 106, 104)
        self.position = vector.Vector2d.zero
        self.velocity = vector.Vector2d.zero

        # UNIQUE VARIABLES
        self.speed = 4
        self.target = target_object
        self.powerup_group = group_list[POWERUP_GROUP]
        self.text_group = group_list[TEXT_GROUP]
        self.effects_group = group_list[EFFECTS_GROUP]
        self.health = 2
        self.boss_fight = False
        self.drop_item = False

        #  LEAVE SCREEN VARIABLES
        self.life_timer = 5 * FRAMES_PER_SECOND
        self.leave_screen = False
        done = aitools.spawn_off_screen(self)

    def actor_update(self):
        self.life_timer -= 1
        if not self.life_timer:
            self.leave_screen = True

        if self.active and self.health <= 0:
            self.active = False
            self.die()

        if not self.active and self.health:
            self.active = True

        self.process_ai()

    def process_ai(self):
        if self.leave_screen:
            if self.speed > 5:
                self.speed -= .015

        elif self.speed <= 5:
            self.speed = 13
            aitools.go_to_target(self, self.target)

        else:
            self.speed -= 0.15
            self.velocity = self.velocity.make_normal() * self.speed

    def collide(self):
        if self.object_collided_with.actor_type == ACTOR_PLAYER:
            self.object_collided_with.hurt(1)

    def custom_bounds(self):
        if self.leave_screen:
            self.kill()
Exemplo n.º 10
0
class Moono(enemy.Enemy):
    death_sound = None
    master_animation_list = animation.Animation()

    def __init__(self, target_object, group_list):
        enemy.Enemy.__init__(self)

        # COMMON VARIABLES
        self.actor_type = ACTOR_TYPE_ENEMY
        self.animation_list = copy.copy(self.master_animation_list)
        self.animation_list.set_parent(self)
        self.animation_list.play('Idle')
        self.rect = self.image.get_rect()
        self.bound_style = BOUND_STYLE_KILL
        self.bounds = -32, -32, (SCREEN_WIDTH + 32), (SCREEN_HEIGHT + 32)
        self.can_collide = True
        self.hitrect = pygame.Rect(0, 0, 54, 98)
        self.position = vector.Vector2d.zero
        self.velocity = vector.Vector2d.zero

        # UNIQUE VARIABLES
        self.speed = 3
        self.target = target_object
        self.powerup_group = group_list[POWERUP_GROUP]
        self.text_group = group_list[TEXT_GROUP]
        self.effects_group = group_list[EFFECTS_GROUP]
        self.health = 2

        # BOSS FIGHT VARIABLES
        self.boss_fight = False
        self.drop_item = False
        self.drop_balloon = False
        self.drop_reflect = False

        aitools.spawn_away_from_target(self, self.target)

    def actor_update(self):
        if self.active and self.health <= 0:
            self.active = False
            self.die()

        if not self.active and self.health:
            self.active = True

        self.process_ai()

    def process_ai(self):
        aitools.go_to_target(self, self.target)

    def collide(self):
        if self.object_collided_with.actor_type == ACTOR_PLAYER:
            self.object_collided_with.hurt(1)

    def die(self):
        utility.play_sound(self.death_sound)
        particle.DeathEmitter(self.position, self.effects_group).run()

        if self.drop_balloon:
            self.powerup_group.add(
                balloon.Bonus250(self.position, self.text_group))

        elif self.drop_reflect:
            self.powerup_group.add(gem.Reflect(self.position, self.text_group))

        else:
            self.item_drop()

        self.kill()
        del self
Exemplo n.º 11
0
class Rokubi(enemy.Enemy):
    death_sound = None
    master_animation_list = animation.Animation()

    def __init__(self, target_object, group_list):
        enemy.Enemy.__init__(self)

        # COMMON VARIABLES
        self.no_spawn = False
        self.actor_type = ACTOR_TYPE_ENEMY
        self.animation_list = copy.copy(self.master_animation_list)
        self.animation_list.set_parent(self)
        self.animation_list.play('Idle')
        self.rect = self.image.get_rect()
        self.bound_style = BOUND_STYLE_NONE
        self.bounds = -32, -32, SCREEN_WIDTH + 32, SCREEN_HEIGHT + 32
        self.can_collide = True
        self.hitrect = pygame.Rect(0, 0, 54, 98)
        self.velocity = vector.Vector2d(0, 0)

        # UNIQUE VARIABLES
        self.speed = 7
        self.hide_behind = target_object
        self.target = target_object
        self.powerup_group = group_list[POWERUP_GROUP]
        self.enemy_group = group_list[ENEMY_GROUP]
        self.text_group = group_list[TEXT_GROUP]
        self.effects_group = group_list[EFFECTS_GROUP]
        self.boss_group = group_list[BOSS_GROUP]
        self.health = 1
        self.drop_item = False
        self.boss_fight = False
        self.charging = False
        self.hiding = False

        self.emitter = particle.ParticleEmitter(vector.Vector2d.zero, vector.Vector2d.zero,
                                                self.effects_group,
                                                ['heart'],
                                                270.0, 45.0,
                                                0.0, 0.0,
                                                8.0, 1.0,
                                                -1.0)
        
        self.emitter.mount_to(self)
        aitools.spawn_off_screen(self)

    def actor_update(self):
        self.emitter.update()
        
        if self.active and self.health <= 0:
            self.health = 0
            self.active = False
            self.die()
        else:
            # This can occasionally cause an error if the rokubi has been
            # removed from the group by an outside function, such as when
            # moving on to a new level.
            if (not self.boss_fight or not self.active and not self.charging) and not self.hiding:
                try:
                    self.hide_behind = aitools.get_closest(self, [self.enemy_group, self.boss_group], [ACTOR_TYPE_BAAKE, ACTOR_TYPE_BOSS])
                    if self.hide_behind == self:
                        self.hide_behind = self.target

                except:
                    self.hide_behind = self.target

            self.active = True

        self.process_ai()

    def process_ai(self):
        self.charging = False

        # Find the distance to the player
        distance = (self.target.position - self.position).get_magnitude()

        if self.hide_behind.actor_type == ACTOR_TYPE_BOSS:
            if distance < 450:
                self.speed = 10
                aitools.go_to_target(self, self.target)
                self.charging = True
                self.hiding = False

        else:
            if distance < 325:
                self.speed = 10
                aitools.go_to_target(self, self.target)
                self.charging = True
                self.hiding = False

        if not self.charging:
            self.speed = 7
            self.hiding = True
            aitools.hide(self, self.hide_behind, self.target)

    def collide(self):
        if self.object_collided_with.actor_type == ACTOR_PLAYER:
            self.object_collided_with.hurt(1)
Exemplo n.º 12
0
class Bomb(Sprite):

    ANIMATION_LIST = animation.Animation()

    def __init__(self, parent: object):  # Game
        super().__init__()
        self.sprite_type = SPRITE_BOMB
        self.animation = copy.copy(self.ANIMATION_LIST)
        self.animation.set_parent(self)
        self.animation.play_animation("idle")
        self.rect = self.image.get_rect()
        self.hitrect = self.rect
        self.parent = parent

        self.can_collide = True
        self.collided_with = self
        self.bound_style = BOUND_CUSTOM
        self.bounds = 0, 0, STAGE_WIDTH_HEIGHT[0], STAGE_WIDTH_HEIGHT[1]
        self.active = True

        self.position = vector.objVector(0, 0)
        self.velocity = vector.objVector(0, -300 * MEASURE_UNIT)

        self.timer = 0

        self.rotate_angle = 0
        self.scale = 1

    def custom_update(self):  # bomb acceleration
        self.acceleration = vector.objVector(0, 3 * MEASURE_UNIT)
        self.rotate(self.rotate_angle)
        self.rotate_angle += self.velocity.norm

        if self.parent.boss_group.sprites():
            self.acceleration = vector.objVector(0, 6 * MEASURE_UNIT)
            self.scale -= 0.02
        else:
            self.scale -= 0.01
        self.rescale()

        if self.velocity.y >= 0:
            self.die()

    def rotate(self, angle):  # bomb rotation
        center = self.position.x, self.position.y
        rotated_image = pygame.transform.rotate(self.image, angle)
        self.rect = rotated_image.get_rect(center=center)
        self.image = rotated_image

    def rescale(self):
        center = self.position.x, self.position.y
        scaled_image = pygame.transform.rotozoom(self.image, 1, self.scale)
        self.rect = self.hitrect = scaled_image.get_rect(center=center)
        self.image = scaled_image

    def collide(self):  # bomb collide with eneny
        if self.collided_with.sprite_type == SPRITE_BOSS:
            self.collided_with.health -= 1
        elif self.collided_with.sprite_type == SPRITE_ENEMY:
            self.collided_with.health -= 9999
        elif self.collided_with.sprite_type == SPRITE_BARRAGE:
            d = item.Item(self.parent, "smallpoint")
            d.position = self.collided_with.position
            d.collected = True
            self.collided_with.die()
            self.parent.item_group.add(d)
Exemplo n.º 13
0
class Bullet(Sprite):  #parent

    BULLET_ANIMATION_LIST = animation.Animation()

    def __init__(self, parent, type_id='flow1'):  # parent: Game
        super().__init__()
        self.sprite_type = SPRITE_BULLET
        self.type_id = type_id
        self.animation = copy.copy(self.BULLET_ANIMATION_LIST)
        self.animation.set_parent(self)
        self.animation.play_animation(type_id)
        self.rect = self.image.get_rect()
        self.hitrect = self.rect

        self.parent = parent
        self.can_collide = True
        self.bound_style = BOUND_KILL
        self.bounds = 0, 0, STAGE_WIDTH_HEIGHT[0] + 50, STAGE_WIDTH_HEIGHT[
            1] + 50
        self.active = True

        self.position = vector.objVector(0, 0)
        self.velocity = vector.objVector(0, 0)

        #other attributes
        self.damage = 0
        self.tracked = False

    def custom_update(self):

        if len(self.parent.enemy_group.sprites()) > 0:
            if (self.type_id == 'track1' or self.type_id == 'track2'
                ) and not self.tracked and self.position.y >= self.sort_list(
                    self.parent.enemy_group.sprites())[0].position.y:
                e = self.sort_list(self.parent.enemy_group.sprites())[0]
                try:
                    bdirection = (
                        self.position.x - self.parent.player.position.x
                    ) / abs(self.position.x - self.parent.player.position.x)
                    edirection = (e.position.x - self.parent.player.position.x
                                  ) / abs(e.position.x -
                                          self.parent.player.position.x)
                    if bdirection == edirection:
                        self.tracked = True
                        speed = self.velocity.norm
                        self.velocity = e.position - self.position
                        self.velocity.norm = speed
                        self.auto_rotate()
                except:
                    pass
        else:
            try:
                if (self.type_id == 'track1' or self.type_id == 'track2'):
                    e = self.parent.boss_group.sprites()[0]
                    if STAGE_WIDTH_HEIGHT[
                            0] > e.position.x > 0 and STAGE_WIDTH_HEIGHT[
                                1] > e.position.y > 0:
                        self.tracked = True
                        speed = self.velocity.norm
                        self.velocity = e.position - self.position
                        self.velocity.norm = speed
                        self.auto_rotate()

            except:
                pass

    def auto_rotate(self):
        self.image = pygame.transform.rotate(self.image, self.velocity.angle)

    def sort_list(self, sprites):
        try:
            for i in range(len(sprites) - 1):
                sorted = True
                for j in range(len(sprites) - i - 1):
                    if sprites[j].postion.y < sprites[j + 1].position.y:
                        ships[j], ships[j + 1] = sprites[j + 1], sprites[j]
                        sorted = False

                if sorted == True:
                    break
        except:
            pass

        return sprites

    def collide(self):
        if self.type_id != 'flow2':
            self.die()
Exemplo n.º 14
0
class Haoya(enemy.Enemy):
    death_sound = None
    master_animation_list = animation.Animation()

    def __init__(self, target_object, group_list):
        enemy.Enemy.__init__(self)

        # COMMON VARIABLES
        self.actor_type = ACTOR_TYPE_ENEMY
        self.animation_list = copy.copy(self.master_animation_list)
        self.animation_list.set_parent(self)
        self.animation_list.play('Idle')
        self.rect = self.image.get_rect()
        self.bound_style = BOUND_STYLE_CUSTOM
        self.bounds = 32, 32, SCREEN_WIDTH - 32, SCREEN_HEIGHT - 32
        self.can_collide = True
        self.hitrect = pygame.Rect(0, 0, 54, 58)
        self.hitrect_offset_y = 6
        self.velocity = vector.Vector2d.zero

        # UNIQUE VARIABLES
        self.speed = 2
        self.target = target_object
        self.powerup_group = group_list[POWERUP_GROUP]
        self.text_group = group_list[TEXT_GROUP]
        self.effects_group = group_list[EFFECTS_GROUP]
        self.health = 3
        self.boss_fight = False
        self.drop_item = False

        self.death_emitter = particle.ParticleEmitter(vector.Vector2d.zero,
                                                      self.effects_group,
                                                      ['puff'], 0.0, 360.0,
                                                      5.0, 0.0, 1.0, 4.0, -1.0)

        self.death_emitter.mount_to(self)

        #  LEAVE SCREEN VARIABLES
        self.life_timer = 10 * FRAMES_PER_SECOND
        self.leave_screen = False

        aitools.spawn_off_screen(self)

    def process_ai(self):
        if self.leave_screen:
            pass

        elif self.active:
            # Find the distance to the player
            magnitude = self.target.position - self.position
            if magnitude.get_magnitude() < 250:
                # If the player is within x distance then charge the player.
                self.speed = 7
            else:
                self.speed = 2

            aitools.go_to_target(self, self.target)

    def actor_update(self):
        self.life_timer -= 1

        if not self.life_timer:
            self.leave_screen = True
            self.speed = 7
            aitools.go_to_point(self, aitools.point_off_screen())

        if self.active and self.health <= 0:
            self.active = False
            self.die()

        if not self.active and self.health:
            self.active = True

        self.process_ai()

    def custom_bounds(self):
        if self.leave_screen:
            self.kill()

    def collide(self):
        if self.object_collided_with.actor_type == ACTOR_PLAYER:
            self.object_collided_with.hurt(1)