collision issue

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
User avatar
XxWalKaxX
Posts: 244
Joined: June 11th, 2012, 7:15 pm

collision issue

Post by XxWalKaxX » June 18th, 2012, 2:51 pm

this is basically the same code that clamps the poo to the window but instead of clamping im attempting to make the poo treat the "face" as a wall and bounce off, the code works fine by its self, but when it running with code to clamp poo the screen, the poo simple goes crazy and shoots off the screen and breaks the program

Code: Select all

for(int index = 0; index < nPoo; index++)
		{
			
			if(poo[ index ] .x - 20 == faceX)
			{ 
				poo[ index ] .x = faceX + 20;
				poo[ index ] .vx = -poo[ index ] .vx;
			}
			else if( poo[ index ] .x - 40 == faceX )
			{
				poo[ index ] .x = faceX + 40;
				poo[ index ] .vx = -poo[ index ] .vx;
			}
			if(poo[ index ] .y + 20 == faceY)
			{
				poo[ index ] .y = faceY - 20;
				poo[ index ] .vy = -poo[ index ] .vy;
			}
			else if( poo[ index ] .y + 40 == faceY)
			{
				poo[ index ] .y = faceY - 49;
				poo[ index ] .vy = -poo[ index ] .vy;
			}
			
			
		}
	}
What you call a bug...I call a new feature!

kratrs
Posts: 8
Joined: May 22nd, 2012, 2:46 am
Location: California

Re: collision issue

Post by kratrs » June 18th, 2012, 11:50 pm

Could you post your solution? I think I have an idea on what's going on since i ran into this problem myself, but I'd rather see the problem for myself so i could point you in the right direction rather than give you some wrong pointers.
Image

User avatar
XxWalKaxX
Posts: 244
Joined: June 11th, 2012, 7:15 pm

Re: collision issue

Post by XxWalKaxX » June 19th, 2012, 3:46 am

ok well due to my impatience i have deleted the collision detection code, im gonna start fresh with it although i believe i may have determined the problem i could very well be wrong bc i am a complete newbie but i think the problem is im using poo[index] in 2 different fuctions and there both for collision detection---one for walls----and one for my "shield" and both are in for() statements and both are saying for(int index = 0; index < nPoo; index++)
What you call a bug...I call a new feature!

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: collision issue

Post by chili » June 19th, 2012, 3:47 am

Well, if you are still stuck later, post your zipped cleaned solution and we will help you bro. ;)
Chili

User avatar
XxWalKaxX
Posts: 244
Joined: June 11th, 2012, 7:15 pm

Re: collision issue

Post by XxWalKaxX » June 19th, 2012, 3:52 am

Will do Chili, thanx alot to everyone who has been helping me out with this, if it wasnt for yall i'd still be kicking it in "Hello World" land haha . POO Rulz!
What you call a bug...I call a new feature!

Post Reply