Ported DropAnimatorMixin.
[tagua/yd.git] / src / hlvariant / animator.h
blobbac5d1457d7abbaef169112e4f10f4b25249fa7a
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@sns.it>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 */
11 #ifndef HLVARIANT__ANIMATOR_H
12 #define HLVARIANT__ANIMATOR_H
14 #include "animation.h"
15 #include "fwd.h"
16 #include "variantdata.h"
18 class NamedSprite;
19 class Point;
20 class AnimationFactory;
22 namespace HLVariant {
24 /**
25 * A generic animator.
26 * Can be used as a base class for other specialized animators.
28 template <typename _Variant>
29 class BaseAnimator {
30 public:
31 typedef _Variant Variant;
32 protected:
33 typedef typename UnwrappedGraphicalAPIPtr<Variant>::type API;
34 typedef typename VariantData<Variant>::GameState GameState;
35 typedef typename VariantData<Variant>::Move Move;
36 typedef typename VariantData<Variant>::Piece Piece;
37 API m_cinterface;
38 public:
39 BaseAnimator(API cinterface)
40 : m_cinterface(cinterface) { }
41 virtual ~BaseAnimator() { }
43 virtual AnimationGroupPtr warp(const GameState& final);
44 virtual AnimationGroupPtr forward(const GameState& final, const Move& move);
45 virtual AnimationGroupPtr back(const GameState& final, const Move& move);
49 template <typename _Variant>
50 class SimpleAnimator : BaseAnimator<_Variant> {
51 public:
52 typedef _Variant Variant;
53 private:
54 typedef BaseAnimator<Variant> Base;
55 protected:
56 typedef typename Base::API API;
57 typedef typename Base::GameState GameState;
58 typedef typename Base::Move Move;
59 typedef typename Base::Piece Piece;
61 using Base::m_cinterface;
63 virtual SchemePtr movement(const NamedSprite& sprite, const Point& from, const Point& to);
64 public:
65 SimpleAnimator(API cinterface)
66 : Base(cinterface) { }
68 virtual AnimationGroupPtr warp(const GameState& final);
69 virtual AnimationGroupPtr forward(const GameState& final, const Move& move);
70 virtual AnimationGroupPtr back(const GameState& final, const Move& move);
75 #endif // HLVARIANT__ANIMATOR_H