Ahmed Adamjee
/
SnakeVSBlock
Snake vs Block Game to be run upon K64F.
Diff: SnakevsBlock/SnakevsBlock.cpp
- Revision:
- 46:dc7dccae9f9e
- Parent:
- 44:cd10d07ea1e5
- Child:
- 47:b448ffd073e7
--- a/SnakevsBlock/SnakevsBlock.cpp Thu Apr 25 21:53:05 2019 +0000 +++ b/SnakevsBlock/SnakevsBlock.cpp Fri Apr 26 11:36:01 2019 +0000 @@ -22,12 +22,12 @@ for(int i=0; i<=14; i++) { b[i] = 1; } - _l.init(); - _s.init(); - _f.init(); - _ff.init(); - _fff.init(); - _b.init(); + _l.init(); //length calc object initialisation. + _s.init(); //snake object initialisation. + _f.init(); //food 1 object initialisation. + _ff.init(); //food 2 object initialisation. + _fff.init(); //food 3 object initialisation. + _b.init(); //block object initialisation. } void SnakevsBlock::reset() @@ -38,6 +38,7 @@ food_pos[i].x = 0; food_pos[i].y = 0; } + if(blockgap >= 50) {blockgap -= 40;} //to make progressive levels harder by making the blocks drop more frequently. _l.init(); _s.init(); _f.init(); @@ -100,9 +101,9 @@ _l.print_length_on_screen(lcd); if(_length >= 20) { + SnakevsBlock::reset(); + level = _wl.LevelComplete(lcd, pad, level); _statset.write(level, sd); - SnakevsBlock::reset(); - _wl.LevelComplete(lcd, pad, food_pos, level, blockgap); } if(_length == 0) { _wl.GameOver(lcd,pad); @@ -182,7 +183,7 @@ ) { //printf("snake feast working \n"); //audio feedback - pad.tone(1000.0,0.1); + pad.tone(786.0,0.1); food_pos[food_sr].x = (rand() % 82); //this makes the food pop up at a random, unspecified location in the x axis. food_pos[food_sr].y = -3; _l.PlusLength();