Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: Map/Map.cpp
- Revision:
- 40:a1cdb6ab08af
- Parent:
- 38:a85bc227b907
--- a/Map/Map.cpp Thu May 09 01:58:36 2019 +0000 +++ b/Map/Map.cpp Thu May 09 10:52:00 2019 +0000 @@ -14,8 +14,8 @@ void Map::read_input(FXOS8700CQ &accelerometer, Ball &ball){ Data values = accelerometer.get_values(); int ball_speed = ball.get_ball_speed(); //get the sensitivity from ball object - _map_change.x = -(1+0.5*ball_speed)*values.ay; //axes of accelerometer different to gamepad so use -y for x and vice versa - _map_change.y = -(1+0.5*ball_speed)*values.ax; + _map_change.x = -0.25*(1+0.5*ball_speed)*values.ay; //axes of accelerometer different to gamepad so use -y for x and vice versa + _map_change.y = -0.25*(1+0.5*ball_speed)*values.ax; } void Map::update(){ @@ -67,18 +67,17 @@ int x = ball_pixels[i].x; if(gamemap[y][x] == 1){ //check each pixel in the ball to see if it is on a '1' in game map (representing wall) collision = true; - printf("colliding pixel = %d,%d\n", x, y); break; //break with true if wall collision } else { collision = false; } //keep iterating if not } return collision; } -bool Map::get_coordinate(Vector2D coord){ - bool position; +int Map::get_coordinate(Vector2D coord){ + int position; int x = coord.x; int y = coord.y; - if(gamemap[y][x] == 1){ position == true; } //find the desired coord in the game map - else{ position == false; } //return true if its a wall, false if it's pathway + if(gamemap[y][x] == 1){ position = 1; } //find the desired coord in the game map + else{ position = 0; } //return true if its a wall, false if it's pathway return position; } \ No newline at end of file