Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void moveObject1()
- {
- if(directionXObstacle1 != 0 && directionYObstacle1 !=0)
- { //If it is diagonal
- }
- else
- {//if not diagonal
- if(directionXObstacle1 == 2 && directionYObstacle1 == 0)
- {
- //south
- //check to see if it will hit wall
- if(startingPointXObstacle1 + speedObstacle1 > gridSize )
- {
- int holder = startingPointXObstacle1 + speedObstacle1 - gridSize;
- startingPointXObstacle1 = gridSize - holder;
- directionXObstacle1 = 1;
- }
- else
- {
- startingPointXObstacle1 += speedObstacle1;
- }
- }
- else if(directionXObstacle1 == 1 && directionYObstacle1 == 0)
- {
- //north
- //check to see if it will hit wall
- if(startingPointXObstacle1 - speedObstacle1 < 1 )
- {
- int holder = (startingPointXObstacle1 - speedObstacle1) -1;
- startingPointXObstacle1 = 1 + (holder * -1);
- startingPointXObstacle1 = 2;
- directionXObstacle1 = 2;
- }
- else
- {
- startingPointXObstacle1 -= speedObstacle1;
- }
- }
- else if(directionXObstacle1 == 0 && directionYObstacle1 == 2)
- {
- //east
- //check to see if it will hit wall
- if(startingPointYObstacle1 + speedObstacle1 > gridSize )
- {
- int holder = startingPointYObstacle1 + speedObstacle1 - gridSize;
- startingPointYObstacle1 = gridSize - holder;
- directionYObstacle1 = 1;
- }
- else
- {
- startingPointYObstacle1 += speedObstacle1;
- }
- }
- else if( directionXObstacle1 == 0 && directionYObstacle1 == 1)
- {
- //west
- if(startingPointYObstacle1 - speedObstacle1 < 1 )
- {
- int holder = (startingPointYObstacle1 - speedObstacle1) -1;
- startingPointYObstacle1 = 1 + (holder * -1);
- directionYObstacle1 = 2;
- }
- else
- {
- startingPointYObstacle1 -= speedObstacle1;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement