2,7 → 2,10 |
#include "SDL/SDL_image.h" |
#include "SDL/SDL_opengl.h" |
|
#include <dirent.h> |
#include <iostream> |
#include <vector> |
#include <map> |
|
using namespace std; |
|
77,6 → 80,17 |
|
void SSSNAKESSS::initData() |
{ |
string dataDir = "data/"; |
|
string graphicsDir = dataDir + "graphics/"; |
vector<string> graphicsList = listDir(graphicsDir); |
for (unsigned int i = 0; i < graphicsList.size(); i++) |
{ |
string file = graphicsList[i]; |
string fullfilename = graphicsDir + file; |
|
textures[file] = new Texture(fullfilename); |
} |
} |
|
void SSSNAKESSS::run() |
117,3 → 131,26 |
void SSSNAKESSS::end() |
{ |
} |
|
vector<string> SSSNAKESSS::listDir(string dirName) |
{ |
vector<string> files; |
|
DIR *dp = opendir(dirName.c_str()); |
if (dp != NULL) |
{ |
dirent *ep; |
while ((ep = readdir(dp))) |
{ |
string n = ep->d_name; |
if (n != "." && n != "..") |
{ |
files.push_back(n); |
} |
} |
|
closedir(dp); |
} |
|
return files; |
} |