-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsprite.h
36 lines (28 loc) · 1.2 KB
/
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
#ifndef BUTTON_H
#define BUTTON_H
class Mouse; // forward declaring Mouse class
#include "main.h" // globals
#include "render.h"
#include <iostream>
#include <functional>
class Sprite{
public:
// x,y coords (origo is topleft); w,h size, filepath
Sprite(int x, int y, int w, int h, const char* spritesheetPath, SDL_Rect spriteRect);
~Sprite();
void Draw(SDL_Surface *gScreen);
void DrawScaled(SDL_Surface *gScreen);
void Toggle(); // Toggles between states
void DetectIntersections(Mouse &mouse); // Using the forward declared Mouse class
void SetToggleCallback(std::function<void(bool)> callback); // Set a callback for toggle actions
void SetAlternateSprite(SDL_Surface *alternate); // Set the alternate surface
bool hasintersection; // WIP cant privatize main.cpp reads from this via playSprite.hasintersection
bool toggled; // Current toggled state
private:
SDL_Surface *rawSprite; // Specific image extracted from the spritesheet
SDL_Surface *alternateSprite; // Alternate image for toggled states
SDL_Surface *spritesheet;
SDL_Rect dRectSprite; // The specific images position and size
std::function<void(bool)> toggleCallback; // Callback for toggle action
};
#endif // BUTTON_H