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.
Dependencies: 4DGL direction draw game list mbed
Revision 1:aa27e5ef379b, committed 2012-10-11
- Comitter:
- lucoby
- Date:
- Thu Oct 11 20:24:26 2012 +0000
- Parent:
- 0:1ca938e58b91
- Commit message:
- updated drawing and game engine
Changed in this revision
--- a/draw.lib Thu Oct 11 19:00:03 2012 +0000 +++ b/draw.lib Thu Oct 11 20:24:26 2012 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/lucoby/code/draw/#06f3e47afa60 +http://mbed.org/users/lucoby/code/draw/#2e528b145987
--- a/game.lib Thu Oct 11 19:00:03 2012 +0000 +++ b/game.lib Thu Oct 11 20:24:26 2012 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/lucoby/code/game/#3668e8f103be +http://mbed.org/users/lucoby/code/game/#fae551b1bd58
--- a/main.cpp Thu Oct 11 19:00:03 2012 +0000
+++ b/main.cpp Thu Oct 11 20:24:26 2012 +0000
@@ -17,26 +17,44 @@
int points;
int tempRow, tempCol;
int draw_yes = 0;
+ int draw_y2 = 0;
+ int spx = 0;
+ int spy = 0;
int i;
- State game = start;
+ State game = splash;
drawSetup();
while(1) {
wait(0.016666667);
myled = !myled;
switch(game) {
- case start:
+ case splash:
+ draw_y2++;
+ if(draw_y2 == 19) {
+ drawBlank(spy,spx);
+ spx = rand() % COL;
+ spy = rand() % ROW;
+ drawApple(spy,spx);
+ draw_y2 = 0;
+ }
+ if((direction = getDirection(none)) != none) game = start;
+ break;
+ case start:
if((direction = getDirection(none)) != none) {
deleteList(&snake);
clearscr();
- for(i = -1; i < ROW + 2; i++) {
- drawPixel(i,-1,0xFFFFFF);
+ for(i = -1; i < COL + 2; i++){
+ drawPixel(-1,i,0xFFFFFF);
+ }
+ for(i = 0; i < ROW + 2; i++) {
drawPixel(i,COL+1,0xFFFFFF);
}
- for(i = -1; i < COL + 2; i++){
- drawPixel(-1,i,0xFFFFFF);
+ for(i = COL + 1; i > -2; i--){
drawPixel(ROW+1,i,0xFFFFFF);
}
+ for(i = ROW + 1; i > -2; i--) {
+ drawPixel(i,-1,0xFFFFFF);
+ }
addToHead(&snake, 5, 5);
addToHead(&snake, 5, 6);
addToHead(&snake, 5, 7);
@@ -117,6 +135,7 @@
if(!checkGameOver(&snake)){
game = end;
+ break;
}
//view
@@ -128,7 +147,10 @@
drawScore(points);
break;
case end:
- if(!pb) game = start;
+ if(!pb) {
+ game = splash;
+ clearscr();
+ }
break;
}
}