Subversion Repositories sssnakesss

Compare Revisions

Ignore whitespace Rev 10 → Rev 4

/history.txt
File deleted
\ No newline at end of file
/tmake.lua
2,7 → 2,7
Language("C++")
 
function build()
Set("Sources", Srcs("main.cpp", "sssnakesss.cpp", "texture.cpp", "point.cpp", "snake.cpp"))
Set("Sources", Srcs("main.cpp", "sssnakesss.cpp", "texture.cpp"))
Set("Libraries", Libs("SDL", "SDL_image", "SDL_mixer", "SDL_ttf", "GL"))
Set("Includes", Incs("SDL", "SDL_image", "SDL_mixer", "SDL_ttf"))
 
/include/point.hpp
File deleted
/include/snake.hpp
File deleted
/include/sssnakesss.hpp
1,6 → 1,8
#ifndef SSSNAKESSS_HPP
#define SSSNAKESSS_HPP
 
struct SDL_Surface;
 
class SSSNAKESSS
{
public:
18,16 → 20,11
void draw();
void end();
vector<string> listDir(string dir);
private:
bool running;
SDL_Surface *screen;
map<string, Texture *> textures;
Snake *snake;
};
 
#endif // SSSNAKESSS_HPP
/include/texture.hpp
19,6 → 19,4
int halfHeight;
};
 
void drawTexture(Texture *texture, int x, int y);
 
#endif // TEXTURE_HPP
/src/snake.cpp
File deleted
/src/point.cpp
File deleted
/src/sssnakesss.cpp
2,15 → 2,10
#include "SDL/SDL_image.h"
#include "SDL/SDL_opengl.h"
 
#include <dirent.h>
#include <iostream>
#include <vector>
#include <map>
 
using namespace std;
 
#include "point.hpp"
#include "snake.hpp"
#include "texture.hpp"
#include "sssnakesss.hpp"
 
38,8 → 33,6
initData();
snake = new Snake;
return true;
}
 
84,17 → 77,6
 
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()
106,8 → 88,6
checkEvents();
update();
draw();
SDL_GL_SwapBuffers();
}
}
 
132,36 → 112,8
 
void SSSNAKESSS::draw()
{
//drawTexture(textures["food.png"], 20, 20);
}
 
void SSSNAKESSS::end()
{
delete snake;
SDL_FreeSurface(screen);
SDL_Quit();
}
 
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;
}
/src/texture.cpp
11,7 → 11,7
{
loaded = false;
GLenum textureFormat = GL_RGBA;
GLenum textureFormat = GL_RGB;
SDL_Surface *surface = IMG_Load(filename.c_str());
if (surface)
102,11 → 102,3
glEnd();
}
}
 
void drawTexture(Texture *texture, int x, int y)
{
if (texture)
{
texture->draw(x, y);
}
}
/src/main.cpp
1,17 → 1,3
#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include "SDL/SDL_opengl.h"
 
#include <dirent.h>
#include <iostream>
#include <vector>
#include <map>
 
using namespace std;
 
#include "point.hpp"
#include "snake.hpp"
#include "texture.hpp"
#include "sssnakesss.hpp"
 
int main(int argc, char *argv[])