diff --git a/demos/TicTacToe/Classes/TicTacToeLayer.cpp b/demos/TicTacToe/Classes/TicTacToeLayer.cpp index 8dd7122e..a1a5320b 100644 --- a/demos/TicTacToe/Classes/TicTacToeLayer.cpp +++ b/demos/TicTacToe/Classes/TicTacToeLayer.cpp @@ -202,7 +202,7 @@ std::string GenerateGameUuid(std::size_t length) { // A function that returns true if any of the row // is crossed with the same player's move -bool RowCrossed(int board[][kTilesY]) { +static bool RowCrossed(int board[][kTilesY]) { for (int i = 0; i < kTilesY; i++) { if (board[i][0] == board[i][1] && board[i][1] == board[i][2] && board[i][0] != kEmptyTile) @@ -213,7 +213,7 @@ bool RowCrossed(int board[][kTilesY]) { // A function that returns true if any of the column // is crossed with the same player's move -bool ColumnCrossed(int board[][kTilesY]) { +static bool ColumnCrossed(int board[][kTilesY]) { for (int i = 0; i < kTilesX; i++) { if (board[0][i] == board[1][i] && board[1][i] == board[2][i] && board[0][i] != kEmptyTile) @@ -224,7 +224,7 @@ bool ColumnCrossed(int board[][kTilesY]) { // A function that returns true if any of the diagonal // is crossed with the same player's move -bool DiagonalCrossed(int board[][kTilesY]) { +static bool DiagonalCrossed(int board[][kTilesY]) { if (board[0][0] == board[1][1] && board[1][1] == board[2][2] && board[0][0] != kEmptyTile) return (true); @@ -238,7 +238,7 @@ bool DiagonalCrossed(int board[][kTilesY]) { // A function that returns true if the game is over // else it returns a false -bool gameOver(int board[][kTilesY]) { +static bool GameOver(int board[][kTilesY]) { return (RowCrossed(board) || ColumnCrossed(board) || DiagonalCrossed(board)); } @@ -443,7 +443,7 @@ TicTacToeLayer::TicTacToeLayer(string game_uuid) { WaitForCompletion(future_current_player_index, "setCurrentPlayerIndex"); awaiting_opponenet_move = true; waiting_label->setString("waiting"); - if (gameOver(board)) { + if (GameOver(board)) { // Set game_over_label to reflect the use won. game_over_label->setString("you won!"); } else if (remaining_tiles.size() == 0) { @@ -500,7 +500,7 @@ void TicTacToeLayer::update(float /*delta*/) { remaining_tiles.erase(last_move); awaiting_opponenet_move = false; current_player_index = player_index; - if (gameOver(board)) { + if (GameOver(board)) { // Set game_over_label to reflect the use lost. game_over_label->setString("you lost."); } else if (remaining_tiles.size() == 0) { diff --git a/demos/TicTacToe/Classes/TicTacToeLayer.h b/demos/TicTacToe/Classes/TicTacToeLayer.h index 2a146a8b..a25d4451 100644 --- a/demos/TicTacToe/Classes/TicTacToeLayer.h +++ b/demos/TicTacToe/Classes/TicTacToeLayer.h @@ -1,8 +1,16 @@ #ifndef TICTACTOE_DEMO_CLASSES_TICTACTOELAYER_SCENE_H_ #define TICTACTOE_DEMO_CLASSES_TICTACTOELAYER_SCENE_H_ +#include + #include "TicTacToeScene.h" #include "cocos2d.h" +#include "firebase/app.h" +#include "firebase/auth.h" +#include "firebase/database.h" +#include "firebase/future.h" +#include "firebase/util.h" + using cocos2d::Director; using cocos2d::Event; using cocos2d::Layer; @@ -10,18 +18,9 @@ using cocos2d::LayerColor; using cocos2d::Point; using cocos2d::Sprite; using cocos2d::Touch; - -#include "firebase/app.h" -#include "firebase/auth.h" -#include "firebase/database.h" - using firebase::database::DataSnapshot; using firebase::database::MutableData; using firebase::database::TransactionResult; -#include - -#include "firebase/future.h" -#include "firebase/util.h" static const int kTilesX = 3; static const int kTilesY = 3;