The Minimal Tic Tac Toe Source Code

The following source code is the "minimal" amount of code needed to run the tic tac toe application. All of the interface functions are defined, but not implemented.

Note how GSinterfaceinit() and GSinterface() are called in main(). Also, notice the FuncNames[] array.


/*
	tictactoe.c - version 1
	
	This version of tictactoe is the "minimal" source code 
	needed to support the tictactoe interface.
*/

#include "geosim.h"

#define NAME "Tic Tac Toe"
#define IFILE "tictactoe.inf"
#define BSTORE 0
#define GAME_WIND "GameWind"
#define STATUS_WIND "StatusWind"

/*  ---  Prototypes - interface functions  ---  */
bool redraw_func();
bool null_func();
bool new_game();
bool undo_move();
bool quit();
bool make_move(int mouse_x, int mouse_y, DragStatusType status);
/**/

void main(int argc, void *argv[])
{
	GSinterfaceinit(NAME, IFILE, BSTORE, "wc", G640x480x256, argc, argv);
	
	GSinterface();
}

bool redraw_func()
{
	GSredrawnamedwindow("root");
	GSredrawnamedwindow(GAME_WIND);
	GSredrawnamedwindow(SCORE_WIND);
	
	return TRUE;
}

bool null_func()
{
	return TRUE;
}

bool new_game()
{
	return TRUE;
}

bool undo_move()
{
	return TRUE;
}

bool quit()
{
	GSquit(NULL);
	return TRUE;
}

bool make_move(int mouse_x, int mouse_y, DragStatusType status)
{
	return TRUE;
}

IntrFunction FuncNames[] = {
	{"redraw_func", redraw_func},
	{"game_menu", null_func},
	{"new_game", new_game},
	{"undo_move", undo_move},
	{"quit", quit},
	{"make_move", make_move},
	};
	
int NumFuncs = GSnumifuncs(FuncNames);

forward forward