Skip to content

Conversation

Grant-Postma
Copy link

No description provided.


#include <algorithm>
#include <ctime>

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're not really touching this file, can you just revert this change completely?


const int kNumberOfTiles = 9;
const int kMaxMovesPerPlayer = 1 + kNumberOfTiles / 2;
const int kTilesX = std::sqrt(kNumberOfTiles);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would do this the other way:

kTilesX = 3
kTilesY = 3
kNumberOfTiles = kTilesX * kTilesY;


USING_NS_CC;

const int kNumberOfTiles = 9;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make all of these static.

const double kTileWidth = (kScreenWidth / kTilesX);
const double kTileHeight = (kScreenHeight / kTilesY);
const int kNumberOfPlayers = 2;
std::array<std::string, kNumberOfPlayers> kMoveImageFileNames = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't have std::strings as global variables according to the C++ style guide.

https://google.github.io/styleguide/cppguide.html#Static_and_Global_Variables

strings do dynamic allocation and then delete on destruction, which is against the style guide rules.

Instead either use const char* here, or make it a string* and initialize the value at startup.

class AppDelegate : private cocos2d::Application {
public:
AppDelegate();
virtual ~AppDelegate();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of virtual, use override.

https://en.cppreference.com/w/cpp/language/override

// kScreenWidth = Director::getInstance()->getWinSize().width; auto
// kScreenHeight = Director::getInstance()->getWinSize().height;

auto board_sprite = Sprite::create("tic_tac_toe_board.png");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put "tic_tac_toe_board.png" in a constant

board_sprite->setAnchorPoint(Vec2(0.0, 0.0));

auto touchListener = EventListenerTouchOneByOne::create();
touchListener->onTouchBegan = [=](Touch* touch,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://google.github.io/styleguide/cppguide.html#Lambda_expressions

Prefer explicit captures when the lambda will escape the current scope.

Only capture the variables you need in the lambda.

@alexames alexames changed the base branch from master to demo-dev June 12, 2020 21:43
@alexames alexames merged commit 2f9eea5 into firebase:demo-dev Jun 12, 2020
@Grant-Postma Grant-Postma deleted the demos branch June 15, 2020 15:04
@firebase firebase locked and limited conversation to collaborators Jul 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

3 participants