-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed sprite glitches, added small animation demo to test sprites
- Loading branch information
1 parent
34a7c80
commit a561439
Showing
5 changed files
with
146 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
#define __ENGINE_H__ | ||
#include <string> | ||
#include <SDL2/SDL.h> | ||
#undef main | ||
|
||
class Engine | ||
{ | ||
public: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,76 @@ | ||
#include <stdio.h> | ||
#include <tinyfiledialogs/tinyfiledialogs.h> | ||
#include "pal.h" | ||
#include <string.h> | ||
|
||
#define RED 0 | ||
#define GREEN 1 | ||
#define BLUE 2 | ||
|
||
size_t PAL::GetFileSize(FILE *pFile) | ||
{ | ||
size_t fileLen; | ||
|
||
fseek(pFile, 0, SEEK_END); | ||
fileLen = ftell(pFile); | ||
rewind(pFile); | ||
|
||
return fileLen; | ||
} | ||
|
||
unsigned int PAL::ReadPal(std::string filename, uint32_t offset) | ||
{ | ||
uint8_t buffer[3]; | ||
Palette curPal; | ||
size_t fileLen; | ||
const char* error; | ||
mPalettes.clear(); | ||
|
||
FILE *pFile = fopen(filename.c_str(), "rb"); | ||
if (pFile == NULL) | ||
{ | ||
error = "Could not open pallette file!"; | ||
tinyfd_messageBox(error, error, "ok", "error", 1); | ||
return PAL_NOK; | ||
} | ||
|
||
fileLen = GetFileSize(pFile); | ||
|
||
if (offset > fileLen) | ||
{ | ||
error = "Offset greater than file size!"; | ||
tinyfd_messageBox(error, error, "ok", "error", 1); | ||
return PAL_NOK; | ||
} | ||
|
||
fseek(pFile, offset, SEEK_SET); | ||
|
||
for (int i = offset; i + 3 < fileLen; i+=3) | ||
{ | ||
fread(buffer, 1, 3, pFile); | ||
curPal.r = buffer[RED]; | ||
curPal.g = buffer[GREEN]; | ||
curPal.b = buffer[BLUE]; | ||
|
||
mPalettes.push_back(curPal); | ||
} | ||
|
||
return PAL_OK; | ||
} | ||
|
||
size_t PAL::GetNumPalettes() | ||
{ | ||
return mPalettes.size(); | ||
} | ||
|
||
Palette PAL::operator [](size_t index) | ||
{ | ||
return mPalettes[index]; | ||
} | ||
|
||
PAL::PAL() | ||
{ | ||
|
||
} | ||
|
||
PAL::~PAL() | ||
{ | ||
|
||
} | ||
#include <stdio.h> | ||
|
||
#include "pal.h" | ||
|
||
#define RED 0 | ||
#define GREEN 1 | ||
#define BLUE 2 | ||
|
||
size_t PAL::GetFileSize(FILE * pFile) | ||
{ | ||
size_t fileLen; | ||
|
||
fseek(pFile, 0, SEEK_END); | ||
fileLen = ftell(pFile); | ||
rewind(pFile); | ||
|
||
return fileLen; | ||
} | ||
|
||
unsigned int PAL::ReadPal(std::string filename, uint32_t offset) | ||
{ | ||
uint8_t buffer[3]; | ||
Palette curPal; | ||
size_t fileLen; | ||
|
||
mPalettes.clear(); | ||
|
||
FILE* pFile = fopen(filename.c_str(), "rb"); | ||
if (pFile == NULL) | ||
{ | ||
printf("File could not be opened\n"); | ||
return PAL_NOK; | ||
} | ||
|
||
fileLen = GetFileSize(pFile); | ||
|
||
if (offset > fileLen) | ||
{ | ||
printf("Offset greater than file size\n"); | ||
return PAL_NOK; | ||
} | ||
|
||
fseek(pFile, offset, SEEK_SET); | ||
|
||
for (int i = offset; i <= fileLen; i += 3) | ||
{ | ||
fread(buffer, 1, 3, pFile); | ||
curPal.r = buffer[RED]; | ||
curPal.g = buffer[GREEN]; | ||
curPal.b = buffer[BLUE]; | ||
|
||
mPalettes.push_back(curPal); | ||
} | ||
|
||
return PAL_OK; | ||
} | ||
|
||
size_t PAL::GetNumPalettes() | ||
{ | ||
return mPalettes.size(); | ||
} | ||
|
||
Palette PAL::operator [](size_t index) | ||
{ | ||
return mPalettes[index]; | ||
} | ||
|
||
PAL::PAL() | ||
{ | ||
|
||
} | ||
|
||
PAL::~PAL() | ||
{ | ||
|
||
} |