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.
Revision 19:bb0179b9043f, committed 2013-08-23
- Comitter:
- vsluiter
- Date:
- Fri Aug 23 20:42:56 2013 +0000
- Parent:
- 18:789e9fafa5f6
- Child:
- 20:a63273c11af0
- Commit message:
- Working game! Paddle hit indicaition OK. Still have to find a way to make the game more interesting when advancing levels. Increase speed?
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Aug 23 20:18:40 2013 +0000
+++ b/main.cpp Fri Aug 23 20:42:56 2013 +0000
@@ -219,8 +219,8 @@
Ticker updater;
//Ticker demopaddlepos;
Timer gametimer;
- PongGameButton buttonleft(PTD5,0.5);
- PongGameButton buttonright(PTD0, 0.5);
+ PongGameButton buttonleft(PTD5,1);
+ PongGameButton buttonright(PTD0, 1);
uint8_t ledcounter;
uint8_t left_score = 0, right_score = 0;
pc.baud(115200);
@@ -246,9 +246,9 @@
strip_drawable = false;
DrawGamePaddle();
if(buttonleft.getTimeoutActive())
- DrawLine(5,10,255,0,0);
+ DrawLine(0,1,0,0,255);
if(buttonright.getTimeoutActive())
- DrawLine(NUMBER_OF_PIXELS-5, NUMBER_OF_PIXELS-1,255,0,0);
+ DrawLine(NUMBER_OF_PIXELS-1, NUMBER_OF_PIXELS,0,0,255);
strip_drawable = true;
if(buttonleft.pushflag || buttonright.pushflag)
{
@@ -261,7 +261,7 @@
if(buttonright.paddlepos >= NUMBER_OF_PIXELS-1 ) //also count when hit at last pixel = NUMBER_OF_PIXELS-1
{
paddle.direction = 0;
- paddle.setSpeed(25+(buttonright.paddlepos-(NUMBER_OF_PIXELS-1))*4);
+ paddle.setSpeed(25+(buttonright.paddlepos-(NUMBER_OF_PIXELS-1))*6);
paddle.position = NUMBER_OF_PIXELS-2;
}
pc.printf("\n\rright pushed. Paddle position: %d, registered: %d, speed: %", paddle.position, buttonright.paddlepos,paddle.getSpeed());
@@ -277,7 +277,7 @@
if(buttonleft.paddlepos <= 0 )
{
paddle.direction = 1;
- paddle.setSpeed(25+(-buttonleft.paddlepos)*4);
+ paddle.setSpeed(25+(-buttonleft.paddlepos)*6);
paddle.position = 0;
}
pc.printf("\n\rleft pushed. Paddle position: %d, registered: %d, speed %d", paddle.position, buttonleft.paddlepos, paddle.getSpeed());
@@ -296,6 +296,8 @@
paddle.position = -paddle.getSize();
naglevel1=naglevel2 = 0;
paddle.setSpeed(30);
+ buttonright.pushflag = false;
+ buttonleft.pushflag = false;
}
if(paddle.position < -paddle.getSize() && (paddle.direction == 0))
{
@@ -306,12 +308,14 @@
naglevel1=naglevel2 = 0;
paddle.position = NUMBER_OF_PIXELS;
paddle.setSpeed(30);
+ buttonright.pushflag = false;
+ buttonleft.pushflag = false;
}
}
if(gametimer.read()>10 && !naglevel1)
{
naglevel1 = 1;
- paddle.setSize(4);
+ paddle.setSize(8);
//paddle.setSpeed(40);
}
if(gametimer.read()>15 && !naglevel2)
@@ -332,7 +336,7 @@
{
*leftscore = 0;
*rightscore = 0;
- Randomblinks(2,5);
+ Randomblinks(5,false);
}
(*(mbed::Timer *)gametimer).reset();
paddle.setSize(6);
@@ -428,7 +432,7 @@
{
uint8_t ledcounter;
if(end >= NUMBER_OF_PIXELS)
- end = NUMBER_OF_PIXELS-1;
+ end = NUMBER_OF_PIXELS;
if(start < end)
{
for(ledcounter = start; ledcounter < end ; ledcounter++)