Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualMathew Bergen

Posted 27 December 2012 - 09:22 PM

void Move(){
	
	//Check if there is collision
	if(!(box.x >= SCREEN_W) && box.y >= SCREEN_H) {

		xDir = '+';
		yDir = '-';
	}

	if(!(box.y >= SCREEN_H) && box.x >= SCREEN_W) {

		xDir = '-';
		yDir = '+';
	}

	if(!(box.x <= 0) && box.y <= 0){

		xDir = '-';
		yDir = '+';
	}

	if(!(box.y <= 0) && box.x <= 0){

		xDir = '-';
		yDir = '+';
	}

	//Move
	if(xDir == '+'){

		box.x++;
	}

	else if(xDir == '-'){

		box.x--;
	}

	if(yDir =='+'){

		box.y++;
	}

	else if(yDir == '-'){

		box.y--;
	}

}

 

This is supposed to make a square bounce around the window. The first time it hits the bottom it works, then it goes right through.


#2Mathew Bergen

Posted 27 December 2012 - 09:20 PM

void Move(){
	
	//Check if there is collision
	if(!(box.x >= SCREEN_W) && box.y >= SCREEN_H) {

		xDir = '+';
		yDir = '-';
	}

	if(!(box.y >= SCREEN_H) && box.x >= SCREEN_W) {

		xDir = '-';
		yDir = '+';
	}

	if(!(box.x <= 0) && box.y <= 0){

		xDir = '-';
		yDir = '+';
	}

	if(!(box.y <= 0) && box.x <= 0){

		xDir = '-';
		yDir = '+';
	}

	//Move
	if(xDir == '+'){

		box.x++;
	}

	else if(xDir == '-'){

		box.x--;
	}

	if(yDir =='+'){

		box.y++;
	}

	else if(yDir == '-'){

		box.y--;
	}

}

 

This is supposed to make a square bounce around the window, but It works for two bounces then it stops.


#1Mathew Bergen

Posted 27 December 2012 - 09:17 PM

void Move(){
	
	//Check if there is collision
	if(!(box.x >= SCREEN_W) && box.y >= SCREEN_H) {

		xDir = '+';
		yDir = '-';
	}

	if(!(box.y >= SCREEN_H) && box.x >= SCREEN_W) {

		xDir = '-';
		yDir = '+';
	}

	if(!(box.x <= 0) && box.y <= 0){

		xDir = '-';
		yDir = '+';
	}

	if(!(box.y <= 0) && box.x <= 0){

		xDir = '-';
		yDir = '+';
	}

	//Move
	if(xDir = '+'){

		box.x++;
	}

	else if(xDir = '-'){

		box.x--;
	}

	if(yDir = '+'){

		box.y++;
	}

	else if(yDir = '-'){

		box.y--;
	}

}

 

 


PARTNERS