-
Notifications
You must be signed in to change notification settings - Fork 1
/
sprite.h
37 lines (30 loc) · 843 Bytes
/
sprite.h
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
#ifndef SPRITE__H
#define SPRITE__H
#include <string>
#include <iostream>
#include "drawable.h"
class Sprite : public Drawable {
public:
Sprite(const std::string& n, const Frame*, const float sc);
Sprite(const Sprite& s);
virtual ~Sprite() {};
Sprite& operator=(const Sprite&);
virtual const Frame* getFrame() const { return frame; }
virtual void setFrame(const Frame* f) { frame = f; }
virtual void draw() const;
virtual void update(Uint32 ticks);
unsigned getPixel(Uint32, Uint32) const;
int getFrameWidth() const { return frameWidth; }
Vector2f getCenter() const {
return Vector2f( X()+frame->getWidth()/2, Y()+frame->getHeight()/2 );
}
protected:
int frameWidth;
int frameHeight;
private:
const Frame * frame;
int worldWidth;
int worldHeight;
int getDistance(const Sprite*) const;
};
#endif