I need this for mufasa (vm), which doesn't have SDL or OpenGL or even GNOME
Besides, it doesn't need it, and attempting to install them did not end well...
Still need to test that it actually builds on mufasa
signal(SIGPIPE, Game::HandleBrokenPipe);
signal(SIGPIPE, Game::HandleBrokenPipe);
if (graphicsEnabled && (!Graphics::Initialised()))
Graphics::Initialise("Stratego", theBoard.Width()*32, theBoard.Height()*32);
if (graphicsEnabled && (!Graphics::Initialised()))
Graphics::Initialise("Stratego", theBoard.Width()*32, theBoard.Height()*32);
+ #endif //BUILD_GRAPHICS
if (strcmp(redPath, "human") == 0)
red = new Human_Controller(Piece::RED, graphicsEnabled);
if (strcmp(redPath, "human") == 0)
red = new Human_Controller(Piece::RED, graphicsEnabled);
Game::theGame = this;
signal(SIGPIPE, Game::HandleBrokenPipe);
Game::theGame = this;
signal(SIGPIPE, Game::HandleBrokenPipe);
if (graphicsEnabled && (!Graphics::Initialised()))
Graphics::Initialise("Stratego", theBoard.Width()*32, theBoard.Height()*32);
if (graphicsEnabled && (!Graphics::Initialised()))
Graphics::Initialise("Stratego", theBoard.Width()*32, theBoard.Height()*32);
+ #endif //BUILD_GRAPHICS
input = fopen(fromFile, "r");
input = fopen(fromFile, "r");
TimerThread timer(wait*1000000); //Wait in seconds
timer.Start();
TimerThread timer(wait*1000000); //Wait in seconds
timer.Start();
if (!graphicsEnabled)
{
while (!timer.Finished());
timer.Stop();
return;
}
if (!graphicsEnabled)
{
while (!timer.Finished());
timer.Stop();
return;
}
+ #endif //BUILD_GRAPHICS
while (!timer.Finished())
{
while (!timer.Finished())
{
SDL_Event event;
while (SDL_PollEvent(&event))
{
SDL_Event event;
while (SDL_PollEvent(&event))
{
+ #endif //BUILD_GRAPHICS
if (Game::theGame->printBoard)
Game::theGame->theBoard.PrintPretty(stdout, Piece::BOTH);
if (Game::theGame->printBoard)
Game::theGame->theBoard.PrintPretty(stdout, Piece::BOTH);
+
+ #ifdef BUILD_GRAPHICS
if (Game::theGame->graphicsEnabled && theGame->log == stdout)
{
theGame->logMessage("CLOSE WINDOW TO EXIT\n");
if (Game::theGame->graphicsEnabled && theGame->log == stdout)
{
theGame->logMessage("CLOSE WINDOW TO EXIT\n");
+ #endif //BUILD_GRAPHICS
{
if (theGame->log == stdout)
{
{
if (theGame->log == stdout)
{
theBoard.PrintPretty(stdout, Piece::BOTH);
fprintf(stdout, "\n");
}
theBoard.PrintPretty(stdout, Piece::BOTH);
fprintf(stdout, "\n");
}
+
+ #ifdef BUILD_GRAPHICS
if (graphicsEnabled && log == stdout)
{
logMessage("CLOSE WINDOW TO EXIT\n");
if (graphicsEnabled && log == stdout)
{
logMessage("CLOSE WINDOW TO EXIT\n");
+ #endif //BUILD_GRAPHICS
fprintf(stdout, "\n\n");
}
fprintf(stdout, "\n\n");
}
if (graphicsEnabled)
theBoard.Draw(toReveal);
if (graphicsEnabled)
theBoard.Draw(toReveal);
+ #endif //BUILD_GRAPHICS
turn = Piece::RED;
logMessage( "%d RED: ", turnCount);
turn = Piece::RED;
logMessage( "%d RED: ", turnCount);
theBoard.PrintPretty(stdout, toReveal);
fprintf(stdout, "\n\n");
}
theBoard.PrintPretty(stdout, toReveal);
fprintf(stdout, "\n\n");
}
+
+ #ifdef BUILD_GRAPHICS
if (graphicsEnabled)
theBoard.Draw(toReveal);
if (graphicsEnabled)
theBoard.Draw(toReveal);
+ #endif //BUILD_GRAPHICS
#include "stratego.h"
#include "ai_controller.h"
#include "human_controller.h"
#include "stratego.h"
#include "ai_controller.h"
#include "human_controller.h"
#include <cassert>
#include <iostream>
#include <cassert>
#include <iostream>
#undef DEBUG
//#define DEBUG
#undef DEBUG
//#define DEBUG
Font::Font(const char * filename, int newWidth, int newHeight) : Texture(filename), width(newWidth), height(newHeight)
{
Font::Font(const char * filename, int newWidth, int newHeight) : Texture(filename), width(newWidth), height(newHeight)
{
+void Graphics::Wait(int n)
+{
+ SDL_Delay(n);
+}
+//#define BUILD_GRAPHICS
+#ifdef BUILD_GRAPHICS
+
#ifndef GRAPHICS_H
#define GRAPHICS_H
#ifndef GRAPHICS_H
#define GRAPHICS_H
#include <SDL/SDL.h>
#include <SDL/SDL_opengl.h>
#include <SDL/SDL.h>
#include <SDL/SDL_opengl.h>
+typedef SDL_Surface Screen;
+typedef SDL_Rect Rectangle;
+typedef short unsigned int SUint;
+typedef unsigned char Uint8;
#include <vector>
#include <list>
#include <vector>
#include <list>
-typedef SDL_Surface Screen;
-typedef SDL_Rect Rectangle;
-typedef short unsigned int SUint;
class Texture;
class Font;
class Texture;
class Font;
static SDL_Surface * TextureFromColours(std::vector<SUint> * R, std::vector<SUint> * G, std::vector<SUint> * B, std::vector<SUint> * A = NULL);
static SDL_Surface * TextureFromColours(std::vector<std::vector<SUint> > * R, std::vector<std::vector<SUint> > * G, std::vector<std::vector<SUint> > * B, std::vector<std::vector<SUint> > * A = NULL);
static SDL_Surface * TextureFromColours(std::vector<SUint> * R, std::vector<SUint> * G, std::vector<SUint> * B, std::vector<SUint> * A = NULL);
static SDL_Surface * TextureFromColours(std::vector<std::vector<SUint> > * R, std::vector<std::vector<SUint> > * G, std::vector<std::vector<SUint> > * B, std::vector<std::vector<SUint> > * A = NULL);
-
- static void Wait(int n) {SDL_Delay(n);}
+
+ static void Wait(int n);
template <class T>
class TextureManager
template <class T>
class TextureManager
int width() const {return surface->w;}
int height() const {return surface->h;}
int width() const {return surface->w;}
int height() const {return surface->h;}
protected:
SDL_Surface * surface;
GLuint texture;
protected:
SDL_Surface * surface;
GLuint texture;
+#endif //BUILD_GRAPHICS
+
fprintf(stdout, "Click to move!\n");
SDL_Event event; int mouseClick = 0;
fprintf(stdout, "Click to move!\n");
SDL_Event event; int mouseClick = 0;
}
}
fprintf(stdout, "Move complete!\n");
}
}
fprintf(stdout, "Move complete!\n");
+ #endif //BUILD_GRAPHICS
{
buffer.clear();
for (char in = fgetc(stdin); in != '\n'; in = fgetc(stdin))
{
buffer.clear();
for (char in = fgetc(stdin); in != '\n'; in = fgetc(stdin))
using namespace std;
Piece::Colour SetupGame(int argc, char ** argv);
using namespace std;
Piece::Colour SetupGame(int argc, char ** argv);
+ #else
+ fprintf(stderr, "ERROR: -g switch supplied, but the program was not built with graphics.\n Please do not use the -g switch.");
+ exit(EXIT_FAILURE);
+ #endif //BUILD_GRAPHICS
+
break;
case 'p':
printBoard = !printBoard;
break;
case 'p':
printBoard = !printBoard;
Piece::TextureManager Piece::textures;
Piece::TextureManager Piece::textures;
Piece::TextureManager::~TextureManager()
{
Array<Texture*>::Iterator i(*this);
Piece::TextureManager::~TextureManager()
{
Array<Texture*>::Iterator i(*this);
}
return *(Array<Texture*>::operator[](at));
}
}
return *(Array<Texture*>::operator[](at));
}
/**
* Gets the type of a piece, based off a character token
/**
* Gets the type of a piece, based off a character token
/**
* Draw the board state to graphics
* @param reveal - Pieces matching this colour will be revealed. If Piece::BOTH, all pieces will be revealed
/**
* Draw the board state to graphics
* @param reveal - Pieces matching this colour will be revealed. If Piece::BOTH, all pieces will be revealed
*/
void Board::Draw(const Piece::Colour & reveal, bool showRevealed)
{
*/
void Board::Draw(const Piece::Colour & reveal, bool showRevealed)
{
if (!Graphics::Initialised())
{
fprintf(stderr, "ERROR - Board::Draw called whilst graphics disabled!!!\n");
if (!Graphics::Initialised())
{
fprintf(stderr, "ERROR - Board::Draw called whilst graphics disabled!!!\n");
Graphics::UpdateScreen();
}
Graphics::UpdateScreen();
}
/**
* Adds a piece to the board
/**
* Adds a piece to the board
-
- #include "graphics.h"
- #include "array.h"
+#include "graphics.h"
+#include "array.h"
class TextureManager : public Graphics::TextureManager<LUint>, private Array<Texture*>
{
public:
class TextureManager : public Graphics::TextureManager<LUint>, private Array<Texture*>
{
public:
+ #endif //BUILD_GRAPHICS
void Print(FILE * stream, const Piece::Colour & reveal=Piece::BOTH); //Print board
void PrintPretty(FILE * stream, const Piece::Colour & reveal=Piece::BOTH); //Print board using colour
void Print(FILE * stream, const Piece::Colour & reveal=Piece::BOTH); //Print board
void PrintPretty(FILE * stream, const Piece::Colour & reveal=Piece::BOTH); //Print board using colour
void Draw(const Piece::Colour & reveal=Piece::BOTH, bool showRevealed = true); //Draw board
void Draw(const Piece::Colour & reveal=Piece::BOTH, bool showRevealed = true); //Draw board
+ #endif //BUILD_GRAPHICS
bool AddPiece(int x, int y, const Piece::Type & newType, const Piece::Colour & newColour); //Add piece to board
bool AddPiece(int x, int y, const Piece::Type & newType, const Piece::Colour & newColour); //Add piece to board
+ NOTE: This switch only functions if stratego is built with graphics enabled. See BUILDING for more information.
+
By default, graphics are disabled. If the -g switch is present, stratego will draw the game as it is played using SDL/OpenGL
-p
By default, graphics are disabled. If the -g switch is present, stratego will draw the game as it is played using SDL/OpenGL
-p
If an error occurs within stratego itself, an error message will be printed to stderr and return exit code 1.
If possible, stratego will print the message "QUIT" to both AI programs, and they should exit as soon as possible.
If an error occurs within stratego itself, an error message will be printed to stderr and return exit code 1.
If possible, stratego will print the message "QUIT" to both AI programs, and they should exit as soon as possible.
+
+BUILDING
+ To build from source, simply run make in the source directory.
+
+ stratego can be built with or without graphics enabled. By default, graphics are disabled.
+
+ To enable graphics, ensure that the first line of the source file "graphics.h" reads:
+
+ #define BUILD_GRAPHICS
+
+ To disable graphics, comment out the first line of "graphics.h" i.e ensure that it reads:
+
+ //#define BUILD_GRAPHICS
+
+ If you intend to build with graphics enabled, you will need the SDL and OpenGL developement libraries installed first.
+ If you intend to use graphics, please ensure the "images" directory is located in the executable's run directory.
+
+
irc://irc.ucc.asn.au #progcomp
THIS PAGE LAST UPDATED
irc://irc.ucc.asn.au #progcomp
THIS PAGE LAST UPDATED