GNUShogi engine.
[tagua/yd.git] / src / variants / xchess / animator.h
blobd1e704f2e2f7c1ed8c548e6aa3ff7fe0bd2131cd
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 ANIMATOR_H
12 #define ANIMATOR_H
14 #include "animation.h"
15 #include "fwd.h"
17 class NamedSprite;
18 class Point;
19 class AnimationFactory;
21 /**
22 * A generic animator.
23 * Can be used as a base class for other specialized animators.
25 template <typename Variant>
26 class BaseAnimator {
27 protected:
28 typedef typename UnwrappedGraphicalAPIPtr<Variant>::type API;
29 typedef typename Variant::Position Position;
30 typedef typename Variant::Move Move;
31 typedef typename Variant::Piece Piece;
32 API m_cinterface;
33 public:
34 BaseAnimator(API cinterface)
35 : m_cinterface(cinterface) { }
36 virtual ~BaseAnimator() { }
38 virtual AnimationGroupPtr warp(const Position& final);
39 virtual AnimationGroupPtr forward(const Position& final, const Move& move);
40 virtual AnimationGroupPtr back(const Position& final, const Move& move);
44 template <typename _Variant>
45 class SimpleAnimator : BaseAnimator<_Variant> {
46 public:
47 typedef _Variant Variant;
48 private:
49 typedef BaseAnimator<Variant> Base;
50 protected:
51 typedef typename Base::API API;
52 typedef typename Base::Position Position;
53 typedef typename Base::Move Move;
54 typedef typename Base::Piece Piece;
56 using Base::m_cinterface;
58 virtual SchemePtr movement(const NamedSprite& sprite, const Point& from, const Point& to);
59 public:
60 SimpleAnimator(API cinterface)
61 : Base(cinterface) { }
63 virtual AnimationGroupPtr warp(const Position& final);
64 virtual AnimationGroupPtr forward(const Position& final, const Move& move);
65 virtual AnimationGroupPtr back(const Position& final, const Move& move);
69 #endif // ANIMATOR_H