Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualP0jahn

Posted 23 May 2013 - 07:52 AM

I am checking if the rectangle is intersecting with solid tile.

 

Here is my previous code(it was two for loops instead of one:

		int x = entity.x;
		int y = entity.y;
		int width =  entity.width;
		int height = entity.height;
		
		//Check the top and bottom line
		for(int i = 0; i < width; i++)
			if(foo(i, y) || foo(i, y + height))
				...
			
                //Check left and right line
		for(int i = 0; i < height; i++)
			if(foo(x, i) || foo(x, i + width))
				...

#1P0jahn

Posted 23 May 2013 - 07:51 AM

I am checking if the rectangle is intersecting with solid tile.

 

Here is my previous code(it was two for loops instead of one:

		int x = entity.x;
		int y = entity.y;
		int width =  entity.width;
		int height = entity.height;
		
		//Check the top line
		for(int i = 0; i < width; i++)
			if(foo(i, y) || foo(i, y + height))
				...
				
		for(int i = 0; i < height; i++)
			if(foo(x, i) || foo(x, i + width))
				...

PARTNERS