Ejemplo n.º 1
0
 def spin_up(self, num) -> None:
     self.spin_animations.empty()
     speeds = {3: 10, 4: 5, 5: 2, 6: 1, 7: 1, 8: 1}
     spin_up = Animation(spin_speed=speeds[num],
                         duration=350,
                         round_values=True)
     spin_up.callback = self.spin_down
     spin_up.start(self)
     self.spin_animations.add(spin_up)
Ejemplo n.º 2
0
 def send_flower(self, new_cell, animations) -> None:
     dist = new_cell.rect.top - self.rect.top
     a = Animation(top=new_cell.rect.top,
                   left=new_cell.rect.left,
                   duration=int(dist * Animation.ANIM_SPEED),
                   round_values=True)
     a.start(self.flower.rect)
     animations.add(a)
     new_cell.flower = self.flower
     self.flower = None
Ejemplo n.º 3
0
 def fill_flowers(self) -> None:
     for cell in self.rows[0]:
         if not cell.flower:
             topleft = cell.rect.left, cell.rect.top - cell.rect.height
             color = choice(self.flower_combos)
             cell.flower = Flower(position=topleft, color=color)
             dist = cell.rect.top - cell.flower.rect.top
             a = Animation(top=cell.rect.top,
                           duration=int(dist),
                           round_values=True)
             a.start(cell.flower.rect)
             self.animations.add(a)
     self.recheck = True
Ejemplo n.º 4
0
    def reseat_flower(self, cell) -> None:
        flower = cell.flower
        if not flower:
            return

        dist = get_distance(flower.rect.topleft, cell.rect.topleft)
        if dist > 0:
            a = Animation(top=cell.rect.top,
                          left=cell.rect.left,
                          duration=int(dist * 3),
                          round_values=True,
                          transition="out_bounce")
            a.start(flower.rect)
            self.animations.add(a)
Ejemplo n.º 5
0
 def swap_tiles(self, grabbed_tile, dest_tile) -> None:
     gf = grabbed_tile.flower
     df = dest_tile.flower
     speed = 3.5
     dist = get_distance(gf.rect.topleft, dest_tile.rect.topleft)
     if dist != 0:
         duration = int(speed * dist)
         a1 = Animation(left=dest_tile.rect.left,
                        top=dest_tile.rect.top,
                        duration=duration,
                        round_values=True)
         a1.start(gf.rect)
         a2 = Animation(left=grabbed_tile.rect.left,
                        top=grabbed_tile.rect.top,
                        duration=duration,
                        round_values=True)
         a2.start(df.rect)
         self.grid.animations.add(a1, a2)
     dest_tile.flower = gf
     grabbed_tile.flower = df
     self.grid.recheck = True
Ejemplo n.º 6
0
 def spin_down(self) -> None:
     spin = Animation(spin_speed=100, duration=3500, round_values=True)
     spin.start(self)
     self.spin_animations.add(spin)