extern "C" { #include #include #include #include } void *operator new(size_t size) { return malloc(size); } void *operator new[](size_t size) { return malloc(size); } void operator delete(void *p) { free(p); } void operator delete[](void *p) { free(p); } #include "Board.h" using namespace stacker; void Draw(Board&, ScreenBuffer); bool QuitKeyPressed(); bool StepKeyPressed(); int main() { ScreenBuffer screen = GetDirectScreenBuffer(); clearScreen(WHITE, screen); Board b; while(!b.IsGameOver() && !QuitKeyPressed()) { //Adjust the board b.Step(); //Show the board Draw(b, screen); if( StepKeyPressed() ) { b.Stop(); //Wait while(any_key_pressed()); b.Step(); //If won game if( b.WonGame() ) { Draw(b, screen); drawStr(SCREEN_WIDTH/2 - 12*10, SCREEN_HEIGHT/2-CHAR_HEIGHT/2, "You Win!!!", 3, false, RED, screen); while(!any_key_pressed()) sleep(100); break; } } sleep(100);//I could use a different speed depending on the height; but //it wasn't all that important; the game was fun at a constant speed! } // And quit return 0; } void Draw(Board& b, ScreenBuffer screen) { static bool boardCache[BOARD_HEIGHT][BOARD_WIDTH] = {0}; int nWidthPerPiece = SCREEN_WIDTH / b.GetWidth(); int nHeightPerPiece = SCREEN_HEIGHT / b.GetHeight(); for(int nX=0; nX