Doxygen comments added
Dependencies: mbed Gamepad N5110
Diff: main.cpp
- Revision:
- 4:e98b22e5d5e8
- Parent:
- 3:5409b50b01b0
- Child:
- 5:3a0948f56de0
diff -r 5409b50b01b0 -r e98b22e5d5e8 main.cpp --- a/main.cpp Tue Apr 23 17:09:28 2019 +0000 +++ b/main.cpp Wed May 01 22:01:10 2019 +0000 @@ -76,8 +76,8 @@ }; void welcome(); -void start(int xaxis,int yaxis); -//void pipes(int pipex,int height); +void checkcollisions(int hor, int ver); + int xaxis=25; int yaxis=20; @@ -92,7 +92,7 @@ lcd.clear(); int xvalue=84; - int height = rand() % (20 + 1 - 2) + 2; + int height = rand() % (19 + 1 - 0) + 0; int score = 0; char scoredisplay[3]; while(1) { @@ -113,7 +113,7 @@ if(xvalue<1) { - height=rand() % (20 + 1 - 2) + 2; + height=rand() % (19 + 1 - 0) + 0; xvalue=84; } @@ -123,10 +123,13 @@ lcd.drawSprite(xaxis,yaxis,6,6,(int*)moving); yaxis=yaxis+2; if (pad.check_event(Gamepad::A_PRESSED) == true) { - yaxis=yaxis-16; + yaxis=yaxis-14; } + wait(0.075); xvalue=xvalue-1; + + //checkcollisions(xaxis,yaxis); //wait(0.1); lcd.refresh(); lcd.clear(); @@ -153,22 +156,12 @@ } } -void start(int xaxis,int yaxis) { - lcd.drawRect(0,45,84,3,FILL_BLACK); - int height = rand() % (20 + 1 - 2) + 2; - lcd.drawRect(40,0,5,height,FILL_BLACK); - lcd.drawSprite(xaxis,yaxis,9,9,(int*)moving); - yaxis=yaxis+2; - if (pad.check_event(Gamepad::A_PRESSED) == true) { - yaxis=yaxis-16; - } - wait(0.05); - //wait(0.1); - lcd.refresh(); - lcd.clear(); - +void checkcollisions(int hor , int ver) { + if(lcd.getPixel((hor+3),ver)|| lcd.getPixel(hor+4,ver)) { welcome();} + if(lcd.getPixel((hor+1),(ver+1)) || lcd.getPixel((hor+4),(ver+1))) { welcome();} + if(lcd.getPixel((hor),(ver+2)) || lcd.getPixel((hor+5),(ver+2))) {welcome();} + if(lcd.getPixel((hor),(ver+3)) || lcd.getPixel((hor+4),(ver+3))) {welcome();} + if(lcd.getPixel((hor+1),(ver+4)) || lcd.getPixel((hor+4),(ver+4))) {welcome();} } - - \ No newline at end of file