We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › URGENT Help with collision detection and movement
Pages: 1 2 
URGENT Help with collision detection and movement (Read 894 times)
Re: URGENT Help with collision detection and movem
Reply #15 - Dec 10th, 2008, 6:15am
 
sorry about that : ) by the way i just want to say thank you so very much. I dont think I could have done it without you, and everyone else who helped me. I hope karma come back ten fold, you odnt know m=how much this saved my rear. Thank You!!!!!
Re: URGENT Help with collision detection and movem
Reply #16 - Dec 10th, 2008, 6:28am
 
glad to hear that! i like helping. i <strike>used to</strike> still wait til the last minute too. post up your project when it's finished!
Re: URGENT Help with collision detection and movem
Reply #17 - Dec 10th, 2008, 6:41am
 
im still wondering wheather or not to have a small line on each ball that points in the direction the UP button "force" would push it. so left and right arrows are to turn the ball's heading and up is to push it in that direction...im working on that one right now...
Re: URGENT Help with collision detection and movem
Reply #18 - Dec 10th, 2008, 7:34am
 
im trying to find an example of "Asteroids" like controls to implement to Rebirth's movement code and some collision detection code im working on...no luck...best example of a perfect asteroids clone is not open source at the moment...grr...btw i started a new topic due to this one being too long...its now "Asteroids-like Control System"
Re: URGENT Help with collision detection and movem
Reply #19 - Dec 10th, 2008, 10:47am
 
ok.. i'm going to bed right now but let me offer you some last tidbits of advice:

here is code that shows how to "extend" a vector. that is increase it's magnitude.  change 30 to whatever value you want to increase (or decrease) it by.  you can use this to accelerate and decelerate by extending the velocity vector, causing the ball to get faster while remaining straight.

turning i'm too tired to think through, but it will involve applying the vector to a different angle. try just offsetting a by the desired amount of turn. remember processing works in radians by default.

ok goodnight! goodluck!

Code:

PVector y, v, v2;

void setup(){
size(200,200);
y = new PVector(0,1);//y-axis
v = new PVector(10,20);//the original vector
v2 = new PVector();//resulting vector
line(100,100,100+v.x,100+v.y);
v2 = v.get();
float a = PVector.angleBetween(y,v);
println(a);
// v2.add(cos(a)*30,sin(a)*30, 0);
v2.x += sin(a)*30;
v2.y += cos(a)*30;
println("cos(a) * 30: " + cos(a) * 30);
println("sin(a) * 30: " + sin(a) * 30);
stroke(0,0,255);
line(50,100,50+v2.x,100+v2.y);//show the new vector
stroke(0,255,0);
line(100,100,100+v.x,100+v.y);//show the original
}


p.s. use PVector.limit() for max speed.
Pages: 1 2