Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions demos/TicTacToe/Classes/TicTacToeLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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);
Expand All @@ -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));
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
17 changes: 8 additions & 9 deletions demos/TicTacToe/Classes/TicTacToeLayer.h
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
#ifndef TICTACTOE_DEMO_CLASSES_TICTACTOELAYER_SCENE_H_
#define TICTACTOE_DEMO_CLASSES_TICTACTOELAYER_SCENE_H_

#include <unordered_set>

#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;
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 <unordered_set>

#include "firebase/future.h"
#include "firebase/util.h"

static const int kTilesX = 3;
static const int kTilesY = 3;
Expand Down