Imported graphics updates from Codebase

This commit is contained in:
Kayne Ruse
2013-06-04 05:05:40 +10:00
parent 6a16e341ec
commit 783e8928d6
9 changed files with 98 additions and 116 deletions
+11 -15
View File
@@ -21,28 +21,24 @@
*/
#include "sprite_sheet.hpp"
SpriteSheet::SpriteSheet(SDL_Surface* s, Uint16 w, Uint16 h)
: Image(s, {0, 0, w, h})
{
currentFrame = 0; maxFrames = GetSurface()->w / GetClipW();
currentStrip = 0; maxStrips = GetSurface()->h / GetClipH();
interval = ticks = 0;
SpriteSheet::SpriteSheet(SDL_Surface* s, Uint16 w, Uint16 h) {
SetSurface(s, w, h);
}
void SpriteSheet::Update(int delta) {
if (interval && (ticks += delta) > interval) {
void SpriteSheet::Update(double delta) {
if (interval && (ticks += delta) >= interval) {
if (++currentFrame >= maxFrames) {
currentFrame = 0;
}
ticks = 0;
}
SetClipX(currentFrame * GetClipW());
SetClipY(currentStrip * GetClipH());
image.SetClipX(currentFrame * image.GetClipW());
image.SetClipY(currentStrip * image.GetClipH());
}
void SpriteSheet::SetSurface(SDL_Surface* s, Uint16 w, Uint16 h) {
Image::SetSurface(s, {0, 0, w, h});
currentFrame = 0; maxFrames = GetSurface()->w / GetClipW();
currentStrip = 0; maxStrips = GetSurface()->h / GetClipH();
SDL_Surface* SpriteSheet::SetSurface(SDL_Surface* const s, Uint16 w, Uint16 h) {
image.SetSurface(s, {0, 0, w, h});
currentFrame = 0; maxFrames = image.GetSurface()->w / image.GetClipW();
currentStrip = 0; maxStrips = image.GetSurface()->h / image.GetClipH();
interval = ticks = 0;
}
}