# Need help, verlet and colisions with bounding box

## Recommended Posts

Hello. I've got my whole system working fine, however there is a problem with the colisions. What I'm trying to do is just some basic string system collisions with the screen ("bounding box"). It seems to work but not quite. This is what my collision code looks like:
	float x,y;
Vector v;
int j;
for ( j=0; j<iParticles;j++) {
tParticle *p1;
p1 = particles[j];

x = p1->m_x.x;
y = p1->m_x.y;

if ( x <= 0 || x >= SCREEN_W - 1) {
v = p1->m_x - p1->m_oldx;
v.x *= -1;
p1->m_oldx = p1->m_x - v;
}

if (y <= 0 || y >= SCREEN_H - 1) {
v = p1->m_x - p1->m_oldx;
v.y *= -1;
p1->m_oldx = p1->m_x - v;
}

However when a only one particle within a system collides the particle starts jumping and "gets stuck" in the wall. You can see the attached exe http://s3.youshareit.com/download.php?03cae6ed449f4ad83e3a7815e48dadd5 (Scanned with AVG Free) I will be very greatful if anyone can help me Thanks in advance! PS: If anyone can suggest me an article about verlet integration and collision that would be awesome too!

##### Share on other sites

if ( (x <= 0 && v.x =< 0) || (x >= SCREEN_W - 1 && v.x >= 0)) {	v = p1->m_x - p1->m_oldx;	v.x *= -1;	p1->m_oldx = p1->m_x - v;}

same for y.

as for collisions and verlet stuff, try
car
balls

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627678
• Total Posts
2978605

• 12
• 12
• 10
• 12
• 22