-
Notifications
You must be signed in to change notification settings - Fork 0
/
Animated.hpp
43 lines (36 loc) · 980 Bytes
/
Animated.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* File: Animated.h
* Author: greg
*
* Created on 4 mars 2012, 18:53
*/
#ifndef ANIMATED_H
#define ANIMATED_H
#include "GameObject.h"
#include <SFML/System.hpp>
#include <vector>
#include <memory>
#include <map>
struct frame {
sf::IntRect rect;
sf::Time duration;
frame(sf::IntRect r, unsigned int d) : rect(r), duration(sf::milliseconds(d)) {}
};
typedef std::vector<std::unique_ptr<frame>> framevector;
typedef std::map<std::string,std::unique_ptr<framevector>> animationmap;
class Animated : public GameObject {
public:
Animated(sf::Sprite _sprite) : GameObject(_sprite) {}
virtual ~Animated();
void addFrame(std::string, sf::IntRect, int);
void playanimation(std::string);
void playanimation(std::string, int);
virtual void update();
private:
int remainingtime;
framevector::iterator currentframe;
framevector *currentanim;
animationmap anims;
sf::Clock clock;
};
#endif /* ANIMATED_H */