Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of el17ajf by
Diff: Game/Game.cpp
- Revision:
- 34:0bb0d010e755
- Parent:
- 31:69fedaa9b171
- Child:
- 36:c854f1f51f43
--- a/Game/Game.cpp Sat Apr 13 10:05:10 2019 +0000
+++ b/Game/Game.cpp Tue Apr 23 16:38:32 2019 +0000
@@ -8,11 +8,16 @@
#include "Prefs.h"
#include "Math.h"
-Game::Game(Difficulty difficulty) {
- current_tetromino = Tetromino::getTetrominoOfType(
- Tetromino::getRandomTetrominoType());
- next_tetromino_type = Tetromino::getRandomTetrominoType();
-
+Game::Game(Difficulty difficulty) :
+ score(0),
+ next_tetromino_type(Tetromino::getRandomTetrominoType()),
+ current_tetromino(
+ Tetromino::getTetrominoOfType(Tetromino::getRandomTetrominoType())),
+ frames(0),
+ last_move_frame(0),
+ start_x(Grid::GRID_WIDTH / 2 - 1),
+ player_number(Prefs::getInstance()->getKey(Prefs::LAST_PLAYER)) {
+ current_tetromino = current_tetromino.teleportedTo(start_x);
switch (difficulty) {
case EASY:
move_frames = Engine::FPS / 6; // ~ 160ms
@@ -27,12 +32,7 @@
score_for_row = 10;
break;
}
- frames = 0;
- last_move_frame = 0;
- start_x = Grid::GRID_WIDTH / 2 - 1;
- current_tetromino = current_tetromino.teleportedTo(start_x);
- score = 0;
- player_number = Prefs::getInstance()->getKey(Prefs::LAST_PLAYER);
+
if (player_number == Prefs::EMPTY) {
player_number = 1;
} else {
