Commit 94d08ffd authored by Robert Scott James's avatar Robert Scott James

Removed alot of the old annoying debugging added a simple example of the new...

Removed alot of the old annoying debugging added a simple example of the new debugging macros and stuff

Changes to be committed:new file:src / debug.h
  modified:src / entity / vision / vision.cpp
  modified:src / game / game.cpp
  modified:src / main.cpp modified:testLevels / maze.lvl
parent 63d64450
#define KNRM "\x1B[0m"
#define KRED "\x1B[31m"
#define KGRN "\x1B[32m"
#define KYEL "\x1B[33m"
#define KBLU "\x1B[34m"
#define KMAG "\x1B[35m"
#define KCYN "\x1B[36m"
#define KWHT "\x1B[37m"
#ifndef NDEBUG
#define VERBOSE(a) std::cerr<<KWHT<<a<<KNRM<<std::endl
#define DEBUG(a) std::cerr<<KBLU<<a<<KNRM<<std::endl
#define WARN(a) std::cerr<<KYEL<<a<<KNRM<<std::endl
#define ERROR(a) std::cerr<<KRED<<a<<KNRM<<std::endl
#define CRIT(a) std::cerr<<KMAG<<"!! "<<KRED<<a<<KMAG<<" !!"<<KNRM<<std::endl
#else
#define VERBOSE(a)
#define DEBUG(a)
#define WARN(a)
#define ERROR(a)
#define CRIT(a)
#endif
......@@ -178,13 +178,14 @@ void Vision::drawTiles(Display *& dpy, Window &w, GC &gc,int scale,Pixmap *tiles
for(int sy=0; sy < VIEW_DIAM; sy++){
int mapX = ( x + sx - viewDistance);
int mapY = ( y + sy - viewDistance);
TILE_TYPES t;
if(mapX < 0 || mapY < 0 || mapX >= dungeon.getWidth() || mapY >= dungeon.getHeight() ){
t = UNSEEN;
continue;
} else {
t = fov[ mapY * dungeon.getWidth() + mapX ];
}
std::cerr << "(" << mapX << "," << mapY << ")" << " - " << fov[ mapY * dungeon.getWidth() + mapX ] << std::endl;
TILE_TYPES t = fov[ mapY * dungeon.getWidth() + mapX ];
XCopyArea(dpy,tiles[t],w,gc,0,0,32,32,sx*32,sy*32);
}
......
......@@ -57,8 +57,8 @@ void Game::loop(){
std::cout << "Drawing seed for level " << dungeonLevel << ": " << milliseconds_since_epoch << std::endl;
std::shared_ptr<DungeonGenerator> d(new DungeonGenerator(200,200,milliseconds_since_epoch));
//std::shared_ptr<Loader> d(new Loader(202,202,"../testLevels/maze.lvl"));
//std::shared_ptr<DungeonGenerator> d(new DungeonGenerator(200,200,milliseconds_since_epoch));
std::shared_ptr<Loader> d(new Loader(202,202,"../testLevels/maze.lvl"));
levels.emplace_back(d);
......@@ -126,6 +126,7 @@ void Game::loop(){
}
XCopyArea(dpy, double_buffer, w, gc, 0, 0, wa.width, wa.height, 0, 0);
XFillRectangle(dpy, double_buffer, gc, 0, 0, wa.width, wa.height);
XFlush(dpy);
if(theHero->levelComplete() == true){
break;
......@@ -175,7 +176,7 @@ int Game::readTiles(std::string tilesFilename,Display*& dpy,Drawable d,GC gc){
int colour = (image[imageOffset]<<24) | (image[imageOffset+1]<<16) | (image[imageOffset+2]<<8);
std::cerr << n << "," << i << "," << j << "," << (colour) << std::endl;
//std::cerr << n << "," << i << "," << j << "," << (colour) << std::endl;
XSetForeground(dpy, gc, colour>>8);
XFillRectangle (dpy, tiles[n], gc, j, i, 1, 1);
}
......
......@@ -7,6 +7,7 @@
#include <getopt.h>
#include "game/game.h"
#include "debug.h"
//Debugging spaces
int main(int argc, char **argv){
......@@ -21,6 +22,8 @@ int main(int argc, char **argv){
getopt_long(argc, argv, "", longopts, &index);
std::cout << ROOT << std::endl;
CRIT("Ouch");
// Create a game class
Game main(ROOT);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment