Ahmed Adamjee
/
SnakeVSBlock
Snake vs Block Game to be run upon K64F.
Diff: GameEngine/SnakevsBlock/SnakevsBlock.cpp
- Revision:
- 92:693a6ae0ff8e
- Parent:
- 87:871d9fecb593
- Child:
- 93:7f9c31ed5cab
--- a/GameEngine/SnakevsBlock/SnakevsBlock.cpp Wed May 08 21:29:06 2019 +0000 +++ b/GameEngine/SnakevsBlock/SnakevsBlock.cpp Wed May 08 22:27:45 2019 +0000 @@ -86,7 +86,7 @@ break; } SnakevsBlock::lightTheLEDS(); //This function ligths the LEDS dependent on the direction of travel. - //printf("%d",gm); + //printf("%d",g_mode); //printf("%f",_tiltAngle); //printf("%f",device.get_roll_angle()); } @@ -312,22 +312,6 @@ } } -void SnakevsBlock::_setVelocity(int srn) -{ - if((_length>=10)&&(b_number[srn]>0)) { //this makes the block stop moving down if it's length is more than 10 and still collides. - velocity = 0; //the block and food have to stop as if length of snake is 15 and it reaches 10 one by one, it stays at the same place, as max virtual length - } else { //is 10. - velocity = 1; - } - //Send velocities set to related classes. - _b.velocity.y = velocity; - _f.velocity.y = velocity; - _ff.velocity.y = velocity; - _fff.velocity.y = velocity; - _barA.velocity.y = velocity; - _barB.velocity.y = velocity; -} - int SnakevsBlock::CheckBlock(int block) { //This gets the value of int block from the loop in SnakevsBlock::CheckSnakeBlockCollision() and compares it to some preset ranges, and sees which sr num @@ -351,6 +335,22 @@ return srn; } +void SnakevsBlock::_setVelocity(int srn) +{ + if((_length>=10)&&(b_number[srn]>0)) { //this makes the block stop moving down if it's length is more than 10 and still collides. + velocity = 0; //the block and food have to stop as if length of snake is 15 and it reaches 10 one by one, it stays at the same place, as max virtual length + } else { //is 10. + velocity = 1; + } + //Send velocities set to related classes. + _b.velocity.y = velocity; + _f.velocity.y = velocity; + _ff.velocity.y = velocity; + _fff.velocity.y = velocity; + _barA.velocity.y = velocity; + _barB.velocity.y = velocity; +} + void SnakevsBlock::ImplementSnakeBlockCollision() { send_block_number = 1; @@ -424,7 +424,7 @@ } -void SnakevsBlock::CheckSnakeBarrierCollision(int bar_sr_no) //bar_sr_no is the endex of which barrier collision we are detecting. +void SnakevsBlock::CheckSnakeBarrierCollision(int bar_sr_no) //bar_sr_no is the index of which barrier collision we are detecting. { //If statements check if the snake sprite has collided with any //of the barrier's sides and then stop the snake moving in x axis