-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathframe.cpp
More file actions
82 lines (69 loc) · 2.16 KB
/
Copy pathframe.cpp
File metadata and controls
82 lines (69 loc) · 2.16 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "SDL/SDL_rotozoom.h"
#include "drawable.h"
#include "frame.h"
#include "ioManager.h"
#include "viewport.h"
Frame::Frame( const std::string& name, SDL_Surface* surf ) :
screen(IOManager::getInstance().getScreen()),
surface( surf ),
width(Gamedata::getInstance().getXmlInt(name+"/Width")),
height(Gamedata::getInstance().getXmlInt(name+"/Height")),
sourceX(0),
sourceY(0)
{ }
Frame::Frame( SDL_Surface* spr, Uint16 w, Uint16 h,
Sint16 src_x, Sint16 src_y) :
screen(IOManager::getInstance().getScreen()),
surface(spr),
width(w), height(h),
sourceX(src_x), sourceY(src_y) {
}
Frame::Frame( const Frame& frame ) :
screen(frame.screen),
surface(frame.surface),
width(frame.width),
height(frame.height),
sourceX(frame.sourceX),
sourceY(frame.sourceY)
{ }
Frame& Frame::operator=(const Frame& rhs) {
surface = rhs.surface;
screen = rhs.screen;
width = rhs.width;
height = rhs.height;
sourceX = rhs.sourceX;
sourceY = rhs.sourceY;
return *this;
}
void Frame::draw(Sint16 x, Sint16 y) const {
SDL_Rect src = { sourceX, sourceY, width, height };
x -= Viewport::getInstance().X();
y -= Viewport::getInstance().Y();
SDL_Rect dest = {x, y, width, height };
SDL_BlitSurface(surface, &src, screen, &dest);
}
void Frame::draw(Sint16 sx, Sint16 sy, Sint16 dx, Sint16 dy) const {
SDL_Rect src = { sx, sy, width, height };
SDL_Rect dest = {dx, dy, width, height };
SDL_BlitSurface(surface, &src, screen, &dest);
}
/*
void Frame::draw(Sint16 x, Sint16 y, double angle) const {
SDL_Surface* tmp = rotozoomSurface(surface, angle, 1, 1);
SDL_Rect src = { 0, 0, tmp->w, tmp->h };
x -= Viewport::getInstance().X();
y -= Viewport::getInstance().Y();
SDL_Rect dest = {x, y, 0, 0 };
SDL_BlitSurface(tmp, &src, screen, &dest);
SDL_FreeSurface( tmp );
}
*/
void Frame::draw(Sint16 x, Sint16 y, double zoom) const {
SDL_Surface* tmp = zoomSurface(surface, zoom, zoom, SMOOTHING_ON);
SDL_Rect src = { 0, 0, tmp->w, tmp->h };
x -= Viewport::getInstance().X();
y -= Viewport::getInstance().Y();
SDL_Rect dest = {x, y, 0, 0 };
SDL_BlitSurface(tmp, &src, screen, &dest);
SDL_FreeSurface( tmp );
}