Exemple #1
0
    def slowdown(self, color=True):
        # EFECTO DE COLOR
        if color:
            try:
                self.animate(self.turnred_anim)
            except ValueError:
                self.stop_all_animations()
                self.stop_all_animations()
                a = (spyral.Animation(
                    "R", spyral.easing.Linear(self.R, 128), duration=3)
                     & spyral.Animation(
                         "G", spyral.easing.Linear(self.G, 32), duration=3)
                     & spyral.Animation(
                         "B", spyral.easing.Linear(self.B, 0), duration=3))

                a.property = "turnred"
                self.animate(a)

        try:
            self.animate(self.slowdown_anim)
        except ValueError:
            self.stop_all_animations()
            self.stop_all_animations()
            a = spyral.Animation("speed",
                                 spyral.easing.Linear(self.speed, self.low),
                                 duration=1)
            self.animate(a)
Exemple #2
0
    def set_caminar_y(self, y, disparar=False):
        if self.estado in ["caminando"]:
            self.stop_all_animations()

        # Calculamos el tiempo para obtener una velocidad constante
        distancia = self.pos.distance((y, self.x))
        tiempo = distancia / self.velocidad

        if self.y < y:
            direccion = self.south
            self.quieto = self.southq
        else:
            direccion = self.north
            self.quieto = self.northq

        a = spyral.Animation("image",
            spyral.easing.Iterate(direccion, tiempo), tiempo)
        b = spyral.Animation("y", spyral.easing.Linear(self.y, y), tiempo)
        d = spyral.Animation("image",
            spyral.easing.Iterate([self.quieto], 0.1), 0.1)
        c = a & b
        c = c + d

        if disparar:
            z = spyral.Animation("image",
                spyral.easing.Iterate(self.fire, 1), 1)
            c = c + z
        c.property = "traslado"
        self.animate(c)
        self.estado = "caminando"
        return tiempo
Exemple #3
0
    def __init__(self, frase, infodato, ganaste):
        spyral.Scene.__init__(self, SIZE)

        self.background = spyral.Image(size=SIZE).fill(BG_COLOR)

        self.text = frase
        font_path = "fonts/SFDigitalReadout-Medium.ttf"
        font = spyral.Font(font_path, 72, FG_COLOR)

        self.finale = spyral.Sprite(self)
        self.finale.image = font.render(self.text)
        self.finale.anchor = 'midtop'
        self.finale.x = SIZE[0] / 2
        self.finale.y = 75

        self.infodato_label = MultilineText(self, infodato, self.finale.x, 500,
                                            1000, 500)

        if ganaste:
            animation = spyral.Animation('y',
                                         spyral.easing.Sine(50),
                                         shift=75,
                                         duration=3,
                                         loop=True)
        else:
            animation = spyral.Animation('x',
                                         spyral.easing.Sine(50),
                                         shift=self.finale.x,
                                         duration=3,
                                         loop=True)
        self.finale.animate(animation)

        spyral.event.register("input.keyboard.down.*", self.procesar_tecla)
        self.closing = False
        spyral.event.register("system.quit", spyral.director.quit)
Exemple #4
0
    def set_caminar_x(self, x, disparar=False):
        if self.estado in ["caminando"]:
            self.stop_all_animations()

        # Calculamos el tiempo para obtener una velocidad constante
        distancia = self.pos.distance((x, self.y))
        tiempo = distancia / self.velocidad

        if self.x < x:
            direccion = self.east
        else:
            direccion = self.west
        a = spyral.Animation("image",
            spyral.easing.Iterate(direccion, tiempo), tiempo)
        b = spyral.Animation("x", spyral.easing.Linear(self.x, x), tiempo)
        d = spyral.Animation("image",
            spyral.easing.Iterate([self.quieto], 0.1), 0.1)
        c = a & b
        c = c + d
        if disparar:
            z = spyral.Animation("image",
                spyral.easing.Iterate(self.fire, 1), 1)
            c = c + z
        c.property = "traslado"
        try:
            self.animate(c)
        except ZeroDivisionError:
            print "ZERODIVISIONERROR!!!!"
            print "self.x",self.x
            print "x",x
            print "tiempo", tiempo
            print "duracion", duracion

        self.estado = "caminando"
        return tiempo
Exemple #5
0
	def move_player(self, direction):
		if not self.player_animation_lock.acquire(False):
			return
		#self.player_animation_lock.acquire()
		#self.player_sprite.stop_all_animations()
		pos = self.player_sprite.pos
		tile_height = int(self.renderer.tmx_data.tileheight * self.scale_height)
		tile_width = int(self.renderer.tmx_data.tilewidth * self.scale_width)

		if direction == 'down':
			move_animation = spyral.Animation('y', spyral.easing.Linear(pos.y, pos.y + tile_height), STEP_INTERVAL)
			new_pos = spyral.Vec2D(pos.x, pos.y + tile_height)
		elif direction == 'up':
			move_animation = spyral.Animation('y', spyral.easing.Linear(pos.y, pos.y - tile_height), STEP_INTERVAL)
			new_pos = spyral.Vec2D(pos.x, pos.y - tile_height)
		elif direction == 'left':
			move_animation = spyral.Animation('x', spyral.easing.Linear(pos.x,  pos.x - tile_width), STEP_INTERVAL)
			new_pos = spyral.Vec2D(pos.x - tile_width, pos.y)
		elif direction == 'right':
			move_animation = spyral.Animation('x', spyral.easing.Linear(pos.x,  pos.x + tile_width), STEP_INTERVAL)
			new_pos = spyral.Vec2D(pos.x + tile_width, pos.y)
		try:
			assert(new_pos.x % self.renderer.tmx_data.tilewidth == 0)
			assert(new_pos.y % self.renderer.tmx_data.tileheight == 0)
		except AssertionError:
			import pdb; pdb.set_trace()
		properties = self.get_renderer_tile_properties(new_pos)
		walking_animation = load_walking_animation(self.sprite_file, direction, self.sprite_offset)
		if self.position_in_scene(new_pos):
			if properties.get('collision'):
				collision_event = spyral.Event(pos = pos, new_pos = new_pos)
				spyral.event.handle('rpg.map.collision', event = collision_event)
			else:
				walking_animation = (walking_animation & move_animation)

		event_name = None
		if 'x' in walking_animation.properties:
			event_name = self.player_sprite.__class__.__name__ + '.x.animation.end'
		elif 'y' in walking_animation.properties:
			event_name = self.player_sprite.__class__.__name__ + '.y.animation.end'
		if event_name:
			def test_function(*args, **kwargs):
				self.player_animation_lock.release()
				spyral.event.unregister(event_name, test_function)
			spyral.event.register(event_name, test_function)
		else:
			self.player_animation_lock.release()
		try:
			self.player_sprite.animate(walking_animation)
		except ValueError:
			if event_name:
				self.player_animation_lock.release()
				spyral.event.unregister(event_name, test_function)
Exemple #6
0
    def explotar(self, wait=0):
        n = spyral.Animation("image", spyral.easing.Iterate(
            self.explosion_frames, 1), 2)
        if wait:
            m = spyral.Animation("image", spyral.easing.Iterate(
                self.target_frames, wait / 5.0), wait)
            n = m + n
            n.property = "tictac"
        self.stop_all_animations()
        self.animate(n)

        d = DelayAnimation(wait)
        d.property="demora"
        self.animate(d)
Exemple #7
0
    def __init__(self, scene):
        spyral.Sprite.__init__(self, scene)

        self.ESTADO = "bigbang"

        self.image = spyral.Image(size=(1, 1))
        self.pos = (-1, -1)

        self.offset = (0, 0)

        self.offset_anim = spyral.Animation("offset", spyral.easing.Arc((0,0), 50), duration=5) + \
                            spyral.Animation("offset", spyral.easing.LinearTuple((50,0),(0,0)), duration=1)
        self.offset_anim.property = "offset"

        spyral.event.register("TimeMaster.offset.animation.end",
                              self.endhandler)
 def main(self, dt):
     delay = spyral.Animation('delay',
                              spyral.animator.Linear(600, 0),
                              duration=4.0)
     while True:
         self.run_animation(delay)
         self.scene.junks.append(Junk(self.scene))
Exemple #9
0
    def __init__(self, scene):
        scene = spyral.director.get_scene()
        spyral.Sprite.__init__(self, scene)
        self.image = spyral.Image("images/minivintage-frame.png").scale((scene.width, scene.height))
#        self.image.width = scene.width
#        self.image.height = scene.height
        self.width = scene.width
        self.height = scene.height
        self.pos = (0, 0)
        self.layer = "fondo"

        font_path = "fonts/new-century-schoolbook-bi-1361846783.ttf"
        self.font = spyral.Font(font_path, 28, (0,0,0))
        self.line_height = self.font.linesize
        self.margen = 50

        #self.miau = pygame.mixer.Sound("sounds/kipshu__prrmeow.wav")
        #self.miau.play()

        texto = sabiduria[self.count]

        self.image.draw_image(self.render_text(texto),
                                position=(0, scene.height / 2))
                                #anchor="midleft")

        anim_aparecer = spyral.Animation("scale", spyral.easing.Linear(0.1, 1), duration=0.5)
        self.animate(anim_aparecer)

        RetroTexto.count += 1
        if self.count == len(sabiduria):
            RetroTexto.count = 2
Exemple #10
0
 def main(self, delta):
     right = spyral.Animation('x',
                              spyral.easing.Linear(0, 600),
                              duration=1.0)
     down = spyral.Animation('y',
                             spyral.easing.Linear(0, 600),
                             duration=1.0)
     left = spyral.Animation('x',
                             spyral.easing.Linear(600, 0),
                             duration=1.0)
     up = spyral.Animation('y', spyral.easing.Linear(600, 0), duration=1.0)
     while True:
         self.run_animation(right)
         self.run_animation(down)
         self.run_animation(left)
         self.run_animation(up)
Exemple #11
0
    def reset(self, txt=None, img=None, loop=False):
        self.stop_all_animations()

        if not txt:
            self.text = "Please type the word"
        else:
            self.text = txt

        if not img:
            try:
                self.palabra_png = self.scene.tablero.archivo_img
            except AttributeError:
                self.palabra_png = spyral.Image(size=(self.width - self.margen,
                    self.height - self.margen)).fill((255, 255, 255))
        else:
            self.palabra_png = img

        image1 = self.image.copy()
        image1.draw_image(self.render_image(self.palabra_png),
            position=(25, 0), anchor="midleft")

        image2 = self.image.copy()

        nueva = spyral.Image(size=(self.width - self.margen,
            self.height - self.margen)).fill((255, 255, 255))
        image2.draw_image(nueva,
            position=(self.margen / 2, 0), anchor="midleft")
        image2.draw_image(self.render_text(self.text),
            position=(0, 0), anchor="midleft")
        a = spyral.Animation("image", spyral.easing.Iterate([image1, image2], 6), 6, loop=loop)
        self.animate(a)
Exemple #12
0
    def init_animations(self):
        ## TODO
        ## self.invasion_anim_1 = spyral.Animation("scale", spyral.easing.QuadraticOut(0.1, 1), duration=15)
        self.invasion_anim = spyral.Animation("angle", spyral.easing.Linear(0, math.pi * 2), duration=5) & \
                             spyral.Animation("scale", spyral.easing.QuadraticOut(0.1, 1.2), duration=15)
        ## self.invasion_anim = spyral.Animation("scale_x", spyral.easing.QuadraticOut(0, 0.9), duration=10)
        ## self.invasion_anim = spyral.Animation("scale_y", spyral.easing.QuadraticOut(0, 0.9), duration=10)
        self.invasion_anim.property = "invasion"

        self.delay_anim = DelayAnimation(15)
        self.delay_anim.property = "wait"

        self.delay2_anim = DelayAnimation(3)
        self.delay2_anim.property = "wait2"

        self.delay3_anim = DelayAnimation(6)
        self.delay3_anim.property = "wait3"
Exemple #13
0
 def goodbye(self):
     self.stop_all_animations()
     self.stop_all_animations()
     self.animate(self.goodbye_anim)
     a = spyral.Animation("speed",
                          spyral.easing.Linear(self.speed, self.top),
                          duration=5)
     self.animate(a)
Exemple #14
0
 def blink(self):
     blank = spyral.Image(size=(1, 1)).fill((0, 0, 0, 0))
     anim = spyral.Animation("image",
                             spyral.easing.Iterate([blank, self.image],
                                                   times=8),
                             duration=3)
     self.visible = True
     self.animate(anim)
Exemple #15
0
    def init_animations(self):
        a = spyral.Animation("pos",
                             spyral.easing.LinearTuple(self.pos, self.center),
                             3)
        b = spyral.Animation("scale_y", spyral.easing.Linear(1, 0.5), 1)
        c = spyral.Animation("scale_x", spyral.easing.QuadraticOut(1, 0.1), 2)
        top = (self.scene.width / 2, -100)
        d = spyral.Animation("pos",
                             spyral.easing.LinearTuple(self.center, top), 3)
        composition = a + b + (c & d)
        composition.property = "goodbye"
        self.scene.campo.goodbye()
        self.animate(composition)

        self.delay = DelayAnimation(4)
        self.delay.property = "demora"
        self.animate(self.delay)
Exemple #16
0
 def cae(self):
     if not self.estado == "cayendo":
         self.estado = "cayendo"
         animacion = spyral.Animation("y",
                                      spyral.easing.QuadraticIn(
                                          self.y, self.cajita.height),
                                      duration=2)
         self.animate(animacion)
Exemple #17
0
 def seguir_raton(self):
     self.stop_all_animations()
     pos = self.scene.activity._pygamecanvas.get_pointer()
     self.movimiento = pos - self.pos
     anim = spyral.Animation("pos",
                             spyral.easing.LinearTuple(self.pos, pos),
                             duration=0.5)
     self.animate(anim)
 def derecha(self, event):
     if self.moviendo and not self.girando:
         start = self.angle
         end = self.angle - math.pi / 8 * (-1 if self.vel < 0 else 1)
         anim = spyral.Animation("angle",
                                 spyral.easing.Linear(start, end),
                                 duration=0.2)
         self.animate(anim)
         self.girando = True
Exemple #19
0
    def init_animations(self):
        # ABRIR
        secuencia = [self.tiled(self.ARMADO, self.COLOR)] + \
                    [self.tiled(self.CERRADO, self.COLOR)] * 6 + \
                    [self.tiled(self.CERRANDO, self.COLOR)] + \
                    [self.tiled(self.ABIERTO, self.COLOR)] * 6
        # Y CERRAR
        retro_secuencia = list(reversed(secuencia))
        toda_secuencia = secuencia + retro_secuencia

        self.open_animation = spyral.Animation(
            "image", spyral.easing.Iterate(secuencia, times=0.9), 1)
        self.close_animation = spyral.Animation(
            "image", spyral.easing.Iterate(retro_secuencia, times=0.9), 1)
        self.blink_animation = spyral.Animation(
            "image", spyral.easing.Iterate(toda_secuencia), 2)

        spyral.event.register("Bloque.image.animation.end", self.update)
Exemple #20
0
 def salto(self):
     self.stop_all_animations()
     self.estado = "saltando"
     animacion = spyral.Animation("y",
                                  spyral.easing.CubicOut(
                                      self.y, self.y - 100),
                                  duration=1)
     self.animate(animacion)
     self.flap.play()
Exemple #21
0
 def avanzo(self):
     if not self.avanzando:
         animacion = spyral.Animation("x",
                                      spyral.easing.Linear(
                                          self.x,
                                          self.x - self.scene.width),
                                      duration=10)
         self.animate(animacion)
         self.avanzando = True
Exemple #22
0
 def ascender(self):
     animacion = spyral.Animation("pos",
                                  spyral.easing.LinearTuple(
                                      self.pos, (-1 * self.width, 0)),
                                  duration=1)
     try:
         self.animate(animacion)
     except ValueError:
         pass
Exemple #23
0
 def mover(self):
     self.traslacion = spyral.Animation("x",
                                        spyral.easing.Linear(
                                            self.x, 0 - self.width),
                                        duration=self.duration)
     try:
         self.animate(self.traslacion)
     except ValueError:
         pass
Exemple #24
0
 def reset(self):
     self.x = self.scene.width / 2 + random.randint(0, 600) - 300
     self.stop_all_animations()
     self.stop_all_animations()
     self.stop_all_animations()
     m = spyral.Animation("image", spyral.easing.Iterate(
         self.asteroid_frames, 1), 5, loop=True)
     self.animate(m)
     self.llover()
Exemple #25
0
    def llover(self):
        if not Intro.MUTE:
            self.alarm_snd.play()

        tick = (spyral.director.get_tick() - self.start_time) / 300.0
        if tick>16:
            tick = 16
        p = spyral.Animation("y",
            spyral.easing.CubicIn(0, self.scene.height - 75),
            duration=10 + len(self.scene.tablero.palabra) * 3 - tick)
        self.animate(p)
 def frena(self, event):
     if self.vel > 0:
         if not self.frenando:
             self.fren_anim = spyral.Animation('vel',
                                               spyral.easing.CubicIn(
                                                   self.vel, 0),
                                               duration=self.vel**(1 / 10))
             self.animate(self.fren_anim)
             self.frenando = True
     else:
         self.vel -= 5
Exemple #27
0
    def __init__(self, scene):

        spyral.Sprite.__init__(self, scene)

        self.font = spyral.Font(font_path, 28, (255, 255, 255))
        self.anchor = "center"
        self.x = scene.width / 2 + random.randint(0, 300) - 150

        self.layer = "primer"
        self.start_time = spyral.director.get_tick()

        # Asteroide
        self.asteroid_frames = []
        self.target_frames = []
        for i in range(0, 60):
            number = str(i).zfill(2)
            name = "Asteroid-A-10-" + number + ".png"
            self.asteroid_frames.append(spyral.Image(
                filename=gamedir("images/asteroid/" + name)))
            if int(i / 3) % 2 == 0:
                self.target_frames.append(spyral.Image(size=(75, 75)))
            else:
                self.target_frames.append(spyral.Image(
                    filename=gamedir("images/asteroid/" + name)))

        m = spyral.Animation("image", spyral.easing.Iterate(
            self.asteroid_frames, 1), 5, loop=True)

        self.animate(m)

        # Boom
        self.explosion_full = spyral.Image(
            filename=gamedir("images/explosion.png"))

        self.explosion_frames = []
        explosion_size = 205

        self.explosion_frames.append(
            self.explosion_full.copy().crop((13 * explosion_size, 0),
            (explosion_size, explosion_size)))

        for i in range(0, 13):
            self.explosion_frames.append(
                self.explosion_full.copy().crop((i * explosion_size, 0),
                (explosion_size, explosion_size)))

        spyral.event.register("Lluvia.y.animation.end", self.finalizar, scene=self.scene)
        spyral.event.register("Lluvia.demora.animation.end", self.sonar_explosion)
        self.scale = 2

        self.explotar_snd = pygame.mixer.Sound(gamedir("sonidos/Explosion.ogg"))
        self.alarm_snd = pygame.mixer.Sound(gamedir("sonidos/missile_alarm.ogg"))
Exemple #28
0
    def set_deambular(self):
        if self.estado in ["caminando"]:
            self.stop_all_animations()

        tiempo = 16

        frames = self.east + self.west
        frames = collections.deque(frames)
        frames.rotate(-4)

        # Calculamos el tiempo para obtener una velocidad constante
        a = spyral.Animation("image",
            spyral.easing.Iterate(frames), duration=tiempo, loop=True)
        b = spyral.Animation("x", spyral.easing.Sine(100), shift=self.scene.width/2, duration=tiempo, loop=True)

        c = a & b
        c.property = "deambular"
        self.estado = "caminando"
        try:
            self.animate(c)
        except ValueError:
            pass
Exemple #29
0
    def update(self):
        self.visible = True
        newpos = self.ubicacion * spyral.Vec2D(140, 140) + spyral.Vec2D(70, 70)

        if self.desplaz_anim:
            self.stop_animation(self.desplaz_anim)

        self.desplaz_anim = spyral.Animation("pos",
                                             QuadraticOutTuple(
                                                 self.pos, newpos),
                                             duration=0.4)
        self.animate(self.desplaz_anim)

        event = spyral.event.Event(ubicacion=self.ubicacion)
        spyral.event.queue("Tablero.movimiento", event)
Exemple #30
0
 def muere(self):
     self.scene.fondo1.stop_all_animations()
     self.scene.fondo2.stop_all_animations()
     spyral.event.unregister("director.update", self.chequea)
     spyral.event.unregister("input.keyboard.down.space", self.salto)
     spyral.event.unregister("input.keyboard.down.up", self.salto)
     if not self.estado == "muerto":
         try:
             animacion = spyral.Animation("scale",
                                          spyral.easing.QuadraticInOut(
                                              0.5, 0.01),
                                          duration=3)
             self.animate(animacion)
         except ValueError:
             pass
     self.estado = "muerto"