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 11:fc80c39ba9f0, committed 2013-08-22
- Comitter:
- vsluiter
- Date:
- Thu Aug 22 07:11:27 2013 +0000
- Parent:
- 10:6f9624c7425d
- Child:
- 12:97c71b84c984
- Commit message:
- Some minor cleanup, and corrected paddle detection for left hand player
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Aug 21 22:29:30 2013 +0000
+++ b/main.cpp Thu Aug 22 07:11:27 2013 +0000
@@ -22,7 +22,7 @@
public:
Paddle();//constructor
// ~Paddle();//deconstructor
- int8_t position;
+ int16_t position;
uint8_t direction;
void setSpeed(float speed);
void setColor(uint8_t red, uint8_t green, uint8_t blue);
@@ -130,6 +130,7 @@
Paddle paddle;
bool leftpushed = false, rightpushed = false;
+
void left_pushed(void)
{
if(paddle.direction != 1)
@@ -158,7 +159,7 @@
updater.attach(UpdateLEDstrip, .01);
demopaddlepos.attach(UpdateDemoPaddle, .03);
ledstrip.format(8,0); //15 bits, mode '0'
- ledstrip.frequency(1000000);
+ ledstrip.frequency(1000000); //1MHz clock
for(ledcounter = 0; ledcounter < NUMBER_OF_PIXELS; ledcounter++) {//turn off leds
write_led(&totalstrip[ledcounter], 0,0,0);
}
@@ -168,11 +169,7 @@
gametimer.start();
while(1) {
static uint8_t naglevel1 = 0, naglevel2 = 0;
- //PaddleDemo(2,255,10,100);
DrawGamePaddle();
- //wait(.05);
- //Score(3,2);
- //WinLoose(2.5, LEFT);
if(paddle.direction == 1)
{
if(rightpushed)
@@ -187,23 +184,22 @@
if(leftpushed)
{
leftpushed = false;
- if(paddle.position > -paddle.getSize() && (paddle.position < 0 ) )
+ if(paddle.position > -paddle.getSize() && (paddle.position <= 0 ) )
paddle.direction = 1;
}
}
- if(gametimer.read()>4 && !naglevel1)
+ if(gametimer.read()>6 && !naglevel1)
{
naglevel1 = 1;
paddle.setSize(4);
paddle.setSpeed(40);
}
- if(gametimer.read()>8 && !naglevel2)
+ if(gametimer.read()>10 && !naglevel2)
{
naglevel2 = 1;
paddle.setSize(2);
paddle.setSpeed(70);
}
- //paddle.setSpeed(gametimer<4?30:gametimer.read()*10);
if(paddle.position >= NUMBER_OF_PIXELS && (paddle.direction == 1))
{
//left player scores!
@@ -216,8 +212,8 @@
{
//right player scores!
right_score++;
- HandleScore(&left_score,&right_score,true, &gametimer);
- naglevel1=naglevel2 = 0;
+ HandleScore(&left_score,&right_score,true, &gametimer);
+ naglevel1=naglevel2 = 0;
paddle.position = NUMBER_OF_PIXELS;
}
}
@@ -337,6 +333,7 @@
}
}
}
+
void PaddleDemo(float seconds, uint8_t red, uint8_t green, uint8_t blue)
{
uint8_t ledcounter;
@@ -392,15 +389,3 @@
if(paddlestart < 0)
direction = 1;
}
-
-
-//DigitalOut myled(LED1);
-
-//int main() {
-// while(1) {
-// myled = 1;
-// wait(0.2);
-// myled = 0;
-// wait(0.2);
-// }
-//}