-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSprite.cpp
More file actions
38 lines (30 loc) · 925 Bytes
/
Sprite.cpp
File metadata and controls
38 lines (30 loc) · 925 Bytes
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
#include "Sprite.h"
// Phase out this constructor
Sprite::Sprite(int _x, int _y, int _width, int _height, std::string bmpAddress_, ImageCache *images)
{
x = _x;
y = _y;
width = _width;
height = _height;
bmpAddress = bmpAddress_;
frameRect = {0, 0, _width, _height};
}
Sprite::Sprite(int x_, int y_, int width_, int height_, std::pair<int, int> frameSize, std::pair<int, int> frameOffset, std::string bmpAddress_, ImageCache *images)
{
x = x_;
y = y_;
width = width_;
height = height_;
bmpAddress = bmpAddress_;
// surface = images->get_image(bmpAddress);
frameRect = {frameOffset.first, frameOffset.second, frameSize.first, frameSize.second};
}
Sprite::~Sprite()
{
texture = nullptr;
}
SDL_Texture *Sprite::getTexture(SDL_Renderer *sdlRenderer, ImageCache *images)
{
// texture = SDL_CreateTextureFromSurface(sdlRenderer, surface);
return images->getTexture(bmpAddress, sdlRenderer);
}