Exemplo n.º 1
0
void GamePlayScene::onMenuClicked(int menu) {
    log("onMenuClicked");
    if (menu == Constant::MENU_RETRY_TAG) {
        initGameBoard();
        initNavigator();
    } else if (menu == Constant::MENU_NEXT_TAG) {
        gCurrentLevel = getNextLevel(gCurrentLevel);
        initGameBoard();
        initNavigator();
    }
}
Exemplo n.º 2
0
/*****************************************************************************
void startCheckers(void)
    Description :
		Starts a game of Checkers.
    Parameters  : -
    Returns     : -
*****************************************************************************/
void startCheckers(void)
{
	size_t i = 0;

	// allocate memory
	g_Board = (Field_t**)calloc(g_Fields, sizeof(Field_t));
	for(i = 0; i < g_Fields; ++i)
	{
		g_Board[i] = (Field_t*)calloc(g_Fields, sizeof(Field_t));
	}

	if(!g_Board)
	{
		// show error box
		showError("Memory Allocation Failed", "Memory could not be allocated for Checkers.");

		// quit
		return;
	}

	// initialize the board
	initGameBoard(g_Board, g_Fields, g_Fields);
	
	// print for the first time
	system("CLS");
	printBoardLabels(g_Fields, g_Fields);
	printGameBoard(g_Board, &g_Offset, NULL, NULL, g_Fields, g_Fields);

	// game loop
	while(updateCheckers(g_Fields * g_Fields));

	// free the boards memory
	cleanUpGameBoard(g_Board, g_Fields);
}
Exemplo n.º 3
0
bool GamePlayScene::init() {
    if (!Layer::init()) {
        return false;
    }
    initBackground();
    initGameBoard();
    initNavigator();
    initTouchListener();
    return true;
}
Exemplo n.º 4
0
int main(){	
	//Add snakes and ladders to gameBoard array
	initGameBoard();
	//Initilise Seed
	time_t t;
	srand((unsigned)time(&t));

	//Play Game 1000000 time
	for (int k = 0; k < repetitions; k++){
		playGame();
	};
	//Generate statistics for the game
	stats();
	//Print results to file
	checkPRNG();
	print();

	return 0;
};