-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspritesheet.cpp
More file actions
28 lines (22 loc) · 805 Bytes
/
spritesheet.cpp
File metadata and controls
28 lines (22 loc) · 805 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
#include"spritesheet.hpp"
Spritesheet::Spritesheet(char const *path, int row, int column) {
m_spritesheet_image = load_bmp(path);
m_clip.w = m_spritesheet_image->w / column;
m_clip.h = m_spritesheet_image->h / row;
}
Spritesheet::~Spritesheet() {
SDL_FreeSurface(m_spritesheet_image);
}
void Spritesheet::select_sprite(int x, int y) {
m_clip.x = x*m_clip.w;
m_clip.y = y*m_clip.h;
}
void Spritesheet::draw_selected_sprite(SDL_Surface *window_surface, SDL_Rect *position) {
SDL_BlitSurface(m_spritesheet_image, &m_clip, window_surface, position);
}
void Spritesheet::draw_winner(SDL_Surface *window_surface, char const *pathh) {
image_output = load_bmp(pathh);
SDL_BlitSurface(image_output, NULL, window_surface, NULL);
//SDL_Delay(5000);
//SDL_Quit();
}