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
Diff: Engine/Engine.cpp
- Revision:
- 22:d2969236b4f3
- Parent:
- 21:20478f086bc2
--- a/Engine/Engine.cpp Sat Apr 20 14:46:50 2019 +0000 +++ b/Engine/Engine.cpp Mon Apr 22 16:28:04 2019 +0000 @@ -1,5 +1,8 @@ #include "Engine.h" +// Reference for the technique used to generate random numbers. +// [1] "rand" cplusplus. [Online] Available: http://www.cplusplus.com/reference/cstdlib/rand/ [Accessed: 22 April 2019]. + // Buffer to print updated score. char buffer[14]; @@ -9,9 +12,10 @@ Engine::~Engine() {} void Engine::init() { + // reset_skater(); reset_engine(); - srand(time(NULL)); // Set up for generating random numbers + srand(time(NULL)); // Set up for generating random numbers, [1]. } void Engine::check_reset(N5110 &lcd, Gamepad &gamepad) { @@ -149,13 +153,13 @@ void Engine::generate_lower_lines() { // Use a scaled random number to generate the length of the lower lines. - _length_1 = (rand() %20) + 10; + _length_1 = (rand() %20) + 10; // [1]. _lower_platforms.set_line_1(_length_1); _lower_line_1 = _lower_platforms.get_line_1(); - _length_2 = (rand() %20) + 10; + _length_2 = (rand() %20) + 10; // [1]. _lower_platforms.set_line_2(_length_2); _lower_line_2 = _lower_platforms.get_line_2(); - _length_3 = (rand() %20) + 10; + _length_3 = (rand() %20) + 10; // [1]. _lower_platforms.set_line_3(_length_3); _lower_line_3 = _lower_platforms.get_line_3(); } @@ -213,7 +217,7 @@ _coin_collision_flag = true; _player_score++; _coin.set_coin((rand() % 100),(abs(rand() % 100 - 20))); // Place coin - // on a constrained random position + // on a constrained random position, [1]. gamepad.tone(1500, 0.05); // Make noise on buzzer. wait(0.05); gamepad.tone(3000, 0.05);