A small coding question

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

User avatar
xiphirx
Chaos Rift Junior
Chaos Rift Junior
Posts: 324
Joined: Mon Mar 22, 2010 3:15 pm
Current Project: ******** (Unkown for the time being)
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Contact:

Re: A small coding question

Post by xiphirx »

Kyosaur wrote:
X Abstract X wrote:It's almost 8:00am now, my head is spinning in all these sketches I'm making, I'm probably overcomplicating this. I'm going to bed, I'll have another look tomorow. I'm pretty sure I have this all worked out if I can figure out how to calculate one angle that I'm missing.
Ok, keep me posted :D.

If you think it would be easier, i can change the area to a rectangular one (although if i do that, i lose my "bounce" affect, and will have to learn how to do basic physics :|).
Here's a thought from a math friend of mine: get the line from the player to the soccer ball, figure out where it intersects with the edge of the circle
(although if i do that, i lose my "bounce" affect, and will have to learn how to do basic physics :|)
You do know that the ball does not come back with the exact angle on a circle right?
StarCraft II Zerg Strategy, open to all levels of players!

Looking for paid work :< Contact me if you are interested in creating a website, need a web design, or anything else you think I'm capable of :)
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: A small coding question

Post by Ginto8 »

xiphirx wrote:Here's a thought from a math friend of mine: get the line from the player to the soccer ball, figure out where it intersects with the edge of the circle
ok I really haven't been following this thing at all, but I can help with the point of collision on the outside edge of the ball, if you have the centers and the radius.

Code: Select all

Vector dist = Player.center-Ball.center; // a line from the ball to the player
Point edgeCoord = (dist.normalized()*Ball.radius)+Ball.center;
all the .center's should be vectors or some comparable type. Vector::normalized() returns the normalized version of the vector, and the rest should be easy to figure out.
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
Post Reply