Exemplo n.º 1
0
    def __init__(self):
        """Constructor"""

        # Partes del cuerpo
        self.__bounds = py.Rect(118, 431, 0, 0)
        self.__feet = py.Rect(0, 0, 18, 4)
        self.__body = py.Rect(0, 0, 16, 28)

        # Refertente a animator
        self.__animator = Animator()
        self.__animator.add_animation("idle", 0, "mario/mario_idle", 1, 2)
        self.__bounds.width, self.__bounds.height = self.__animator.add_animation(
            "walk", 150, "mario/mario_walk", 2, 2)
        self.__animator.add_animation("onStairs", 100, "mario/mario_stair", 2,
                                      2)
        self.__bounds.y -= self.__bounds.height

        # Velocidad actual
        self.__vx, self.__vy = 0, 0

        # Velocidad total
        self.__hSpeed = 2
        self.__vSpeed = 7

        # Referente a las plataformas
        self.__onGround = False
        self.__gravity = 1
        self.__onLadder = False

        # Referente a los gráficos
        self.__facingLeft = False

        # Indica si el objeto está vivo
        self.__alive = True
Exemplo n.º 2
0
    def __init__(self):
        """Constructor"""
        self.__inimator = Animator()

        self.__bounds = Rect(250, 0, 0, 0)
        self.__bounds.size = self.__inimator.add_animation(
            "moving", 500, "peach/peach", 2, 2)
        self.__bounds.bottom = 79

        # Elementos necesarios para mostrar el mensaje de HELP cada cierto tiempo
        self.__timer = Timer(550)
        self.__help = load_img("misc/help", 2)
        self.__showHelp = True
Exemplo n.º 3
0
    def __init__(self):
        """Constructor"""
        random.seed()

        # Configuración del cuerpo del objeto.
        self.__bounds = Rect(85, 0, 0, 0)
        self.__bounds.bottom = 127

        # Configuración del objeto 'Animator'.
        self.__animator = Animator()
        self.__bounds.width, self.__bounds.height = self.__animator.add_animation(
            "angry", 500, "kong/kong_angry", 2, 2)
        self.__animator.add_animation("take_barrel", 750,
                                      "kong/kong_take_barrel", 2, 2)
        self.__animator.add_animation("idle", 0, "kong/kong_idle", 1, 2)
        self.__animator.play_animation("angry", 1)

        # Array de barriles.
        self.__barrels = Array()
Exemplo n.º 4
0
    def __init__(self, _x, _y):
        # Crea un nuevo objeto del tipo 'Animator' del motor PixelSmash
        self.__animator = Animator()

        # Crea un nuevo cuerpo para el objecto con la posición que hemos pasado
        # como parámetro, pero aún no le damos un tamaño.
        self.__bounds = Rect(_x, _y, 0, 0)

        # Añadimos una nueva animación al objecto animador y usamos el tamaño
        # del objeto devuelvo para terminar de configurar el cuerpo de nuestro
        # objecto.
        self.__bounds.size = self.__animator.add_animation(
            "fall", 300, "barrel/barrel_fall", 2, 2)

        # Añadimos una nueva animación a nuestro objeto animador, aunque esta vez
        # no necesitamos actualizar el tamaño de nuestro objeto.
        self.__animator.add_animation("move", 300, "barrel/barrel_move", 2, 2)

        # Velocidad que tendrá el objeto.
        #	VX -- Velocidad actual horizontal
        #	VY -- Velocidad actual vertical
        self.__vx, self.__vy = 1, 0

        # Constante para modificar la velocidad actual del objeto
        self.__speed = 3

        # Gravedad que se aplicará al objeto
        self.__gravity = 1

        # La velocidad vertical del objeto no podrá ser superior
        # a la velocidad máxima
        self.__maxFallSpeed = 5

        # Comprueba si el objeto sobre alguna plataforma
        self.__onGround = False

        # Guarda la plataforma que está tocando el objeto
        self.__oldPlatform = None

        # Si el objeto no está vivo, el sistema lo borrará
        self.__alive = True
Exemplo n.º 5
0
    def __init__(self):
        self.played_new_animation = False

        # An object of type animator is created
        self.animator = Animator()

        # In order to render the animation, a 'body' is needed. This body, among
        # other things, will indicate the area where you want the animation to be
        # redrawn and will also serve to check for collisions with other objects.
        self.bounds = py.Rect(WIDTH // 2, HEIGHT // 2, 0, 0)

        # We add two animations to the object (We add two animations because it
        # would not make sense to try an animation manager with only one animation.
        # You wouldn't even need an animation manager for a single animation).
        self.bounds.width, self.bounds.height = self.animator.add_animation(
            "animation_1", 250, "image", 2, 2)

        self.animator.add_animation("animation_2", 1000, "mario_flip", 2, 2)

        # Play animation #1
        self.animator.play_animation("animation_1", 1)