def __init__(self, x, y, color):
        super(Actor, self).__init__('img/ball.png', color=color)
        pos = eu.Vector2(x, y)
        self.position = pos
        self.cshape = cm.CircleShape(pos, self.width / 2)

        self.speed = 200
Ejemplo n.º 2
0
 def __init__(self):
     self.acts = [
         get_ani('stand'),
         get_ani('jmp'),
         get_ani('atk'),
         get_ani('jatk')
     ]
     self.acts += [get_ani('walk')]
     super(Ziji, self).__init__(self.acts[0][0], position=(400, 300))
     self.type, self.friend = 0, 0
     self.ori = self.image
     self.speed, self.direction = 300, 1
     self.ldrt = 1
     self.dx, self.dy = 0, 0
     self.schedule(self.run)
     self.cshape = cm.CircleShape(eu.Vector2(self.x, self.y),
                                  self.width // 2)
     self.atking, self.jmping, self.magicing = 0, 0, 0
     self.status, self.pt, self.next_sta = 0, 0, 0
     self.cds = [0] * 10
     self.magic = [0, 0]
     self.magic[0] = ['saj']
     self.magic[1] = ['sdj']
     for j in xrange(2):
         for i in xrange(len(self.magic[j])):
             self.magic[j][i] = map(lambda x: ord(x),
                                    list(self.magic[j][i]))
Ejemplo n.º 3
0
 def __init__(self):
     super().__init__('sprites/shipspace.png')
     self.scale = 0.2
     self.position = 100, 100
     self.velocity = (300, 300)
     self.cshape = cm.CircleShape(eu.Vector2(*self.position), self.width)
     self.do(Repeat(MoveTo((900, 400), 2) + MoveTo((900, 700), 2) + MoveTo((900, 100), 1) + RotateBy(360, 1)))
Ejemplo n.º 4
0
 def __init__(self, image, x, y):
     super(Actor, self).__init__(image)
     pos = eu.Vector2(x, y)
     self.position = pos
     # the cshape will be a private property
     # with a special getter
     self._cshape = cm.CircleShape(pos, self.width * 0.5)
Ejemplo n.º 5
0
    def update(self, game):
        if self.position[1] < 0:
            game.loosePoint()
            self.reset()

        center_x, center_y = self.position
        self.cshape = cm.CircleShape(eu.Vector2(center_x, center_y), 32)
Ejemplo n.º 6
0
    def set_hitbox(self):
        if self.hitbox_type == 'CircleShape':
            self.cshape = cm.CircleShape(eu.Vector2(self.x, self.y),
                                         self.hitbox_size)

        elif self.hitbox_type == 'RectShape':
            pass
Ejemplo n.º 7
0
 def __init__(self, x, y, color):
     super(Actor, self).__init__(
         'ball.png', color=color
     )  #Sprite uses this image and color can be defined later
     #try saving a different png and using it here instead.
     self.position = pos = eu.Vector2(x, y)  #Sets the x,y position
     self.cshape = cm.CircleShape(pos, self.width / 2)
Ejemplo n.º 8
0
Archivo: llama.py Proyecto: mre/llama
 def __init__(self, x, y):
     super(Lama, self).__init__(
         pyglet.image.load_animation("assets/img/lama_jump.gif"))
     self.position = pos = eu.Vector2(x, y)
     self.cshape = cm.CircleShape(pos, self.width / 2 - 10)
     self.speed = 1.0
     self.strength = 1.0
Ejemplo n.º 9
0
 def __init__(self, x, y, model):
     super(PingPong, self).__init__('SoccerBall.png', scale=.4)
     self.model = model
     self.postion = x, y
     center = eu.Vector2(x, y)
     self.cshape = cm.CircleShape(center, self.width/2)
     self.init()
Ejemplo n.º 10
0
 def __init__(self, image, position):
     super(Asteroid, self).__init__(image)
     self.image = image
     self.position = position
     self.velocity = (0, 0)
     self.cshape = cm.CircleShape(eu.Vector2(self.position), 16)
     self.type = 'asteroid'
Ejemplo n.º 11
0
 def __init__(self, position, hotkey):
     super(HotkeyLabel, self).__init__(hotkey.imageOutline)
     self.hotkeyPos = hotkey.position
     self.scale = 0.7
     self.position = euclid.Vector2(float(position[0]), float(position[1]))
     self.cshape = collision_model.CircleShape(
         euclid.Vector2(x=self.position[0], y=self.position[1]), 14)
Ejemplo n.º 12
0
 def __init__(self, x, y, color):
     super(Actor, self).__init__('img/ball.png', color=color)
     pos = eu.Vector2(x, y)
     self.position = pos
     self.cshape = cm.CircleShape(pos, self.width / 2)
     # player moves at 100 pixels per second
     # the pickups don't move at all
     self.speed = 100
Ejemplo n.º 13
0
 def __init__(self, img, position=(0, 0), scale=1, rotation=0):
     super(Actor, self).__init__(img,
                                 position,
                                 scale=scale,
                                 rotation=rotation)
     self.cshape = cm.CircleShape(self.position, self.width * 0.5)
     self.cshape.center = eu.Vector2(self.position[0], self.position[1])
     self.isDead = False
Ejemplo n.º 14
0
 def __init__(self, cx, cy, radius, btype, img, vel=None):
     super(Player, self).__init__(img)
     self.scale = (radius * 1.05) * scale_x / (self.image.width / 2.0)
     self.btype = btype
     self.cshape = colmod.CircleShape(euc.Vector2(cx, cy), radius)
     self.update_center(self.cshape.center)
     if vel is None:
         vel = euc.Vector2(0.0, 0.0)
     self.vel = vel
Ejemplo n.º 15
0
    def create_sprite(self, file_name, size):
        self.sprite = cocos.sprite.Sprite(file_name)
        self.sprite.position = self.pos.vec
        self.sprite.scale = size
        self.sprite.rotation = self.rot

        self.radius = (self.sprite.height + self.sprite.width) / 4
        self.cshape = cm.CircleShape(eu.Vector2(self.pos.x, self.pos.y),
                                     self.radius)
Ejemplo n.º 16
0
    def __init__(self, x_pos: float, y_pos: float):
        """La comida de Quetzalcoatl debe aparecer en una posición aleatoria dentro del escenario.

        Args:
            x_pos (float): posición inicial del objeto sobre el escenario en el eje horizontal.
            y_pos (float): posición inicial del objeto sobre el escenario en el eje vertical.
        """
        super().__init__(image=Resources.get_heart_animation())
        self.position = x_pos, y_pos
        self.cshape = cm.CircleShape(Vector2(x_pos, y_pos), self.width / 2)
Ejemplo n.º 17
0
 def __init__(self):
     super(Diji, self).__init__('res/pics/zl.png', position=(500, 400))
     self.cshape = cm.CircleShape(eu.Vector2(self.x, self.y),
                                  self.width // 2)
     self.type, self.friend = 1, 1
     self.do(MoveBy((0, -200), 0.5))
     self.schedule(self.run)
     self.ox = self.x
     self.harm_s = set()
     self.life = 100
Ejemplo n.º 18
0
 def __init__(self, cx, cy, radius, btype, img, vel=None):
     super(Actor, self).__init__(img)
     # the 1.05 so that visual radius a bit greater than collision radius
     self.scale = (radius * 1.05) * scale_x / (self.image.width / 2.0)
     self.btype = btype
     self.color = self.palette[btype]
     self.cshape = cm.CircleShape(eu.Vector2(cx, cy), radius)
     self.update_center(self.cshape.center)
     if vel is None:
         vel = eu.Vector2(0.0, 0.0)
     self.vel = vel
Ejemplo n.º 19
0
    def __init__(self, speed=200, position=None):
        Sprite.__init__(self, 'img/ball_64x64.png')
        self.__speed = speed

        if not position:
            self.position = self.randomPosition()
        else:
            self.position = position

        center_x, center_y = self.position
        self.cshape = cm.CircleShape(eu.Vector2(center_x, center_y), 32)
Ejemplo n.º 20
0
 def __init__(self, img, x, y, friend=0, speed=500, harm=1):
     super(Danmu_goken, self).__init__('res/pics/danmu/' + img + '.png',
                                       position=(x, y))
     self.type = 3
     self.x, self.y, self.friend, self.speed, self.harm = x, y, friend, speed, harm
     self.img, self.cd, self.t = img, 0, 0
     self.schedule(self.run)
     self.rotation = -135
     self.do(RotateTo(45, 0.5))
     self.cshape = cm.CircleShape(eu.Vector2(self.x, self.y),
                                  self.width // 2)
Ejemplo n.º 21
0
    def __init__(self, position:Vector2, direction):
        """La posición inical de cada segmento dependerá del tamaño del cuerpo.

        Args:
            position (Vector2): Posición inicial del segmento dentro del escenario.
            speed (Vector2): Velocidad a la que se desplaza el segmento del cuerpo.
            direction: Dirección en la que se dirige el segmento.
        """
        super().__init__(image = Resources.get_segment_image())
        self.position = position
        self.direction = direction
        self.cshape = cm.CircleShape(position, self.width * 0.5)
Ejemplo n.º 22
0
 def __init__(self, position, asPosition, color, scale, building=False):
     super(MiniMapCircle, self).__init__(os.path.join("images",
                                                      "maps", "minimap_circle.png"))
     self.color = color
     self.scale = scale
     self.position = euclid.Vector2(float(position[0]), float(position[1]))
     self.asPosition = asPosition  # position of AS associated with this circle
     # self.cshape = aabb_to_aa_rect(self.get_AABB())
     self.cshape = collision_model.CircleShape(
         euclid.Vector2(x=self.position[0], y=self.position[1]), 14)
     if building:
         self.building = Sprite(os.path.join(
             'images', 'maps', 'minimap_building.png'), position=euclid.Vector2(float(position[0]), float(position[1])))
Ejemplo n.º 23
0
 def __init__(self, img, x, y, drt, friend=1, speed=250, harm=1):
     super(Danmu_0, self).__init__('res/pics/danmu/' + img + '.png',
                                   position=(x, y))
     self.cshape = cm.CircleShape(eu.Vector2(self.x, self.y),
                                  self.width // 2)
     self.friend, self.speed, self.harm = friend, speed, harm
     self.hid = harm_id.next()
     self.ox = self.x
     self.type = 2
     self.t = 0
     self.rotation = -drt
     drt *= math.pi / 180
     self.dx, self.dy = speed * math.cos(drt), speed * math.sin(drt)
     self.schedule(self.run)
Ejemplo n.º 24
0
 def __init__(self, *args, **kwargs):
     """same params as Sprite plus kwargs
             'rx', 'ry' for collision cshape
             'desired_width' """
     rx = kwargs.pop('rx', None)
     ry = kwargs.pop('ry', None)
     desired_width = kwargs.pop('desired_width', None)
     super(Actor, self).__init__(*args, **kwargs)
     if desired_width is None:
         desired_width = self.image.width
     desired_width = float(desired_width)
     self.scale = desired_width / self.width
     if rx is None:
         rx = 0.8 * desired_width / 2.0
     if ry is None:
         ry = 0.8 * self.image.height / self.image.width * desired_width / 2.0
     #self.cshape = cm.AARectShape(eu.Vector2(0.0, 0.0), rx, ry)
     self.cshape = cm.CircleShape(eu.Vector2(0.0, 0.0), rx)  #, ry)
Ejemplo n.º 25
0
    def __init__(self, cx, cy, radius, btype, img, removable=False):
        super(Collidable, self).__init__(img)

        # TODO: Inheritable moving items `velocity=None`

        self.palette = config.settings['view']['palette']

        self.radius = radius
        # the 1.05 so that visual radius a bit greater than collision radius
        # FIXME: Both `scale_x` and `scale_y`
        self.scale = (self.radius *
                      1.05) * config.scale_x / (self.image.width / 2.0)
        self.btype = btype
        self.color = self.palette[btype]
        self.cshape = cm.CircleShape(eu.Vector2(cx, cy), self.radius)
        self.update_center(self.cshape.center)

        self.removable = removable
Ejemplo n.º 26
0
    def update(self, delta):
        self.vel = self.vel + self.acc * delta
        self.pos = self.pos + self.vel * delta

        value, plane = self.is_out()
        if value:
            if plane == 'x1':
                self.pos.x = WIDTH
            elif plane == 'x2':
                self.pos.x = 0
            elif plane == 'y1':
                self.pos.y = HEIGHT
            elif plane == 'y2':
                self.pos.y = 0

        self.cshape = cm.CircleShape(eu.Vector2(self.pos.x, self.pos.y),
                                     self.radius)
        self.sprite.position = self.pos.vec
        self.sprite.rotation = math.degrees(self.rot)
Ejemplo n.º 27
0
 def __init__(self, image, center_x, center_y, radius):
     super(CollidableSprite, self).__init__(image)
     self.cshape = cm.CircleShape(eu.Vector2(center_x, center_y), radius)
Ejemplo n.º 28
0
Archivo: llama.py Proyecto: mre/llama
 def __init__(self, x, y, pic):
     super(Block, self).__init__(pic)
     self.position = pos = eu.Vector2(x, y)
     self.cshape = cm.CircleShape(pos, self.width / 2 - 10)
Ejemplo n.º 29
0
 def update_in_collision_manager(self):
     collision_manager.remove_tricky(self)
     self.cshape = cm.CircleShape(
         eu.Vector2(self.position[0], self.position[1]), 25)
     collision_manager.add(self)
Ejemplo n.º 30
0
 def __init__(self, image, cx, cy, radius):
     super(CollidableSprite, self).__init__(image)
     self.position = (cx, cy)
     self.cshape = cm.CircleShape(eu.Vector2(cx, cy), 25)