
ccc
Revision 14:f898d37428b1, committed 2020-05-11
- Comitter:
- pjr
- Date:
- Mon May 11 10:32:00 2020 +0000
- Parent:
- 13:9a6aff771774
- Commit message:
- Classes
Changed in this revision
--- a/Food/Food.cpp Mon May 06 04:25:09 2019 +0000 +++ b/Food/Food.cpp Mon May 11 10:32:00 2020 +0000 @@ -8,11 +8,11 @@ } Food::~Food(){ - + } void Food::init(){ - food.x=30; + food.x=7; food.y=30; }//set the initial foof position
--- a/Snake/Snake.cpp Mon May 06 04:25:09 2019 +0000 +++ b/Snake/Snake.cpp Mon May 11 10:32:00 2020 +0000 @@ -35,7 +35,7 @@ { snek._x[i]=x+i; snek._y[i]=y; - snek._dir[i]=1; + snek._dir[i]=4; } snek._x[_length]=x+_length; @@ -157,24 +157,39 @@ } printf("updated "); - addPoint(); + } } -void Snake::addPoint(){ - - pos foodPos = _food.returnPos(); - - bool ifcondition=(snek._x[_length-1]==foodPos.x && snek._y[_length-1]== foodPos.y); - if (ifcondition) - { - snek._x[_length+1]=snek._x[_length]; - snek._y[_length+1]=snek._y[_length]; - snek._dir[_length+1]=snek._dir[_length-1]; - _length=_length+1; - _food.response(); - } -} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + void Snake::deadSnake(N5110 &lcd){//check the condition that the life reduces
--- a/main.cpp Mon May 06 04:25:09 2019 +0000 +++ b/main.cpp Mon May 11 10:32:00 2020 +0000 @@ -22,7 +22,7 @@ lcd.init(); pad.init(); - snake.init(25,25,5,3); + snake.init(25,25,20,10); init_screen(); while (true) { @@ -36,13 +36,14 @@ void init_screen(){ - lcd.printString("Du Xianjie 201089059",0,1); - lcd.printString("Press Start!!!",0,4); + lcd.printString("Peng Jingran",10,0); + lcd.printString("201199511",20,2); + lcd.printString("Press Start!!!",1,4); lcd.refresh();//print the information while ( pad.check_event(Gamepad::START_PRESSED) == false) { pad.leds_on(); - wait(0.1); + wait(0.4); pad.leds_off(); wait(0.1); printf("Error");
--- a/mbed.bld Mon May 06 04:25:09 2019 +0000 +++ b/mbed.bld Mon May 11 10:32:00 2020 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file +https://os.mbed.com/users/mbed_official/code/mbed/builds/994bdf8177cb \ No newline at end of file