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:
- 47:1d1a827be81b
- Parent:
- 46:810b3a7fc387
- Child:
- 48:966f2cf803ec
--- a/BreakoutEngine/BreakoutEngine.cpp Fri Apr 26 16:26:58 2019 +0000
+++ b/BreakoutEngine/BreakoutEngine.cpp Fri Apr 26 21:43:55 2019 +0000
@@ -12,7 +12,7 @@
}
-void BreakoutEngine::init(int paddle_width,int paddle_height,int ball_size,int speed)
+void BreakoutEngine::init(int paddle_width,int paddle_height,int ball_size,int speed, int prev_score)
{
// initialise the game parameters
_paddle_width = paddle_width;
@@ -22,7 +22,8 @@
_number_left = 18;
_index = 0;
_cool_time = 0.0f;
-
+ _prev_score = prev_score;
+
// y position on screen - WIDTH is defined in N5110.h
_p1y = HEIGHT - GAP - 1;
@@ -397,7 +398,8 @@
void BreakoutEngine::print_scores(N5110 &lcd) //maybe add to oneless
{
// get scores from paddles
- int p1_score = (18 - get_num_left())*100; //maybe add a previous score so the score carries over through victory screens. add hi score fix so restart restarts from 321
+ int multiplier = get_prev_score()/1800 + 1;
+ 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];
@@ -405,7 +407,9 @@
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;
+}
int BreakoutEngine::get_num_left(){
return _number_left;
}