Balint Bogdan 2645 project, 200966741
Diff: Snake.cpp
- Revision:
- 4:c74ec3f409f9
- Parent:
- 3:b24ef00836c5
- Child:
- 5:449858a54971
--- a/Snake.cpp Fri May 05 13:56:24 2017 +0000 +++ b/Snake.cpp Fri May 05 14:37:44 2017 +0000 @@ -30,9 +30,9 @@ starty=y; startl=lenght; live=_live; - if (live==0){ + /*if (live==0){ live=3; - } + }*/ _length = lenght; _food.init(); @@ -64,6 +64,9 @@ checkWallCollision(lcd); if (live!=0){ lcd.clear(); + waitCount=((float)_length/3)+5; + waitTime=(1/waitCount); + wait(waitTime); char buffer1[14]; char buffer2[14]; sprintf(buffer1,"%2d",live); @@ -91,6 +94,7 @@ //printf("drawn"); } }//live loop + } void Snake::update(Gamepad &pad){ @@ -208,44 +212,23 @@ void Snake::deadSnake(N5110 &lcd){ - /*if (live!=0){ - lcd.clear(); - lcd.printString("Game Over",0,1); - lcd.printString("Press Start",0,2); - lcd.printString("To Continue",0,3); - lcd.refresh(); - live--; - while ( pad.check_event(Gamepad::START_PRESSED) == false){ - pad.leds_on(); - wait(0.05); - pad.leds_off(); - wait(0.05); - } - init(startx,starty,startl,live); - }*/ - //live--; - init(startx,starty,startl,live); - if (live==0){ + + live--; + while (live==0){ lcd.clear(); lcd.printString("Game Over",0,1); lcd.printString("Press Start",0,2); lcd.printString("To restart",0,3); lcd.refresh(); - /* live--; - while ( pad.check_event(Gamepad::START_PRESSED) == false){ - pad.leds_on(); - wait(0.2); - pad.leds_off(); - wait(0.2); - }*/ - // init(startx,starty,startl,live); + } - lcd.clear(); - lcd.printString("Game Over",0,1); - lcd.refresh(); - live--; + //lcd.clear(); + //lcd.printString("Game Over",0,1); + //lcd.refresh(); - }//end of deadSnake + init(25,starty,startl,live); + +}//end of deadSnake void Snake::checkWallCollision(N5110 &lcd){