Stick_Runner
Dependencies: FXOS8700CQ Gamepad N5110 SDFileSystem mbed
Fork of Stick_Runner by
Diff: Character/Character.cpp
- Revision:
- 6:bf601a65cb27
- Parent:
- 5:1bf7c83f86cc
--- a/Character/Character.cpp Thu May 04 09:50:18 2017 +0000 +++ b/Character/Character.cpp Thu May 04 13:04:14 2017 +0000 @@ -4,6 +4,8 @@ void Character::init() { + //fprintf("in character init"); + //Initializing the X and Y co ordinates of the character charPosX = 42; @@ -19,6 +21,7 @@ //Drawing the character + //fprintf("character being drawn"); lcd.setPixel(charPosX,charPosY); lcd.setPixel(charPosX-1,charPosY); lcd.setPixel(charPosX+1,charPosY); @@ -49,6 +52,7 @@ //Function to move the character using the joystick void Character::updateCharacter(Direction d,float mag) { + //fprintf("updating th character speed to make it move"); _speed = int(mag*10.0f); // scale is arbitrary, could be changed in future // update y value depending on direction of movement @@ -123,9 +127,11 @@ } + //Returns the postion (x,y) of the character on the screen Vector2D Character::getCharacterPos() { + //fprintf("in character get pos"); Vector2D p = {charPosX,charPosY}; return p; } @@ -134,6 +140,7 @@ //Function to check if the character has been hit by a obstacle and update the status if yes void Character::characterStatus(Vector2D p) { + //fprintf("IN character status"); //Using the dimensions of the character we check if there any pixels near it if(((charPosX-5<p.x)&&(charPosX+5>p.x))&&((charPosY-5<p.y)&&(charPosY+5>p.y))) { @@ -145,6 +152,11 @@ //Function to return the status of the character bool Character::getCharacterStatus() { + + //fprintf("in get character status"); + + //fprintf("The value of character status is (in 0/1) %d",charStatus); + //Used to determine whether the character has been and hit and charstatus returns false the game is over return charStatus;