2 Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
10 #include "baseanimator.h"
12 #include "animation.h"
19 BaseAnimator::BaseAnimator(TaguaAPI
* api
, const INamer
* namer
)
23 AnimationPtr
BaseAnimator::warp(const IState
* state
) {
24 const IState
* current
= m_api
->state();
25 AnimationPtr res
= m_api
->group("default");
27 for (int i
= 0; i
< current
->board()->size().x
; i
++) {
28 for (int j
= 0; j
< current
->board()->size().y
; j
++) {
31 NamedSprite sprite
= m_api
->getSprite(p
);
32 Piece piece
= state
->board()->get(p
);
35 if (!sprite
&& piece
!= Piece()) {
36 anim
= m_api
->appear(m_api
->setPiece(p
, piece
, false), "instant");
39 else if (sprite
&& piece
== Piece()) {
41 anim
= m_api
->disappear(sprite
, "instant");
44 // sprite and piece differ
45 else if (sprite
&& piece
!= Piece() &&
46 m_namer
->name(piece
) != sprite
.name()) {
48 anim
= m_api
->morph(sprite
, m_api
->setPiece(p
, piece
, false), "instant");
51 res
->addPreAnimation(anim
);
58 AnimationPtr
BaseAnimator::forward(const Move
&, const IState
*) {
59 return AnimationPtr();
62 AnimationPtr
BaseAnimator::back(const Move
&, const IState
*) {
63 return AnimationPtr();