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.
Diff: BreakoutEngine/BreakoutEngine.cpp
- Revision:
- 62:64559062e0ec
- Parent:
- 61:0a8b3ffedc40
- Child:
- 63:2de6fb2de428
--- a/BreakoutEngine/BreakoutEngine.cpp Sat May 04 20:01:54 2019 +0000
+++ b/BreakoutEngine/BreakoutEngine.cpp Sat May 04 20:17:05 2019 +0000
@@ -29,6 +29,7 @@
_index = 0;
_cool_time = 0.0f;
_prev_score = prev_score;
+ _multiplier = 1;
// y position on screen - WIDTH is defined in N5110.h
_p1y = HEIGHT - GAP - 1;
@@ -90,7 +91,7 @@
void BreakoutEngine::moveback_bricks() // rename to reset add in ball reset and use to increase the number of balls each time
{
reset_num_left();
- _ball.init(_ball_size,_speed + 1); // replace the 1 with a multiplier private variable that tracks the number of times continued from victory
+ _ball.init(_ball_size,_speed + _multiplier/2); // replace the 1 with a multiplier private variable that tracks the number of times continued from victory
int pointer = 0;
for (it_R = listofBricks.begin(); it_R != listofBricks.end(); ++it_R){
if (pointer <= 5) {
@@ -418,7 +419,7 @@
_p1.lose_life();
//lose_screen(); // go to loss screen then initialise again
- _ball.init(_ball_size,_speed);
+ _ball.init(_ball_size,_speed+_multiplier/2);
pad.tone(1500.0,0.5);
return true;
}
@@ -432,8 +433,7 @@
void BreakoutEngine::print_scores(N5110 &lcd) //maybe add to oneless
{
// get scores from paddles
- int multiplier = get_prev_score()/1800 + 1; // add in a multiplier private variable so that it can increment
- int p1_score = get_prev_score() + (18 - get_num_left())*100 * multiplier; //maybe add a previous score so the score carries over through victory screens. add hi score fix so restart restarts from 321
+ int p1_score = get_prev_score() + (18 - get_num_left())*100 * _multiplier; //maybe add a previous score so the score carries over through victory screens. add hi score fix so restart restarts from 321
// also, add a multiplier of 2 for every contiue on victory
// print to LCD i
char buffer1[14];
@@ -441,6 +441,8 @@
lcd.printString("SCORE: ",2 ,0);
lcd.printString(buffer1,WIDTH/2 -2,0); // font is 8 wide, so leave 4 pixel gape from middle assuming two digits
}
+
+
int BreakoutEngine::get_prev_score(){
return _prev_score;
}
@@ -452,4 +454,13 @@
}
void BreakoutEngine::reset_num_left() {
_number_left = 18;
-}
\ No newline at end of file
+}
+int BreakoutEngine::get_mult() {
+ return _multiplier;
+}
+void BreakoutEngine::inc_mult() {
+ _multiplier ++;
+}
+void BreakoutEngine::set_mult_zero() {
+ _multiplier = 0;
+}