Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
Ask your question in a clear and concise manner.
firstPerson
Senior Poster
3,923 posts since Dec 2008
Reputation Points: 841
Solved Threads: 608
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
ok....
1)i want to set the lines at run time.( w.r.t. x-axis,y-axis,clockwise and anti-clockwise)
Ok whats the problem. In your drawFunc have the (X_i,Y_i,Z_i)
and the (X_f, Y_f, Z_f) as variables and change it accordingly. Maybe
if '+' is pressed, increase the length of each X coord by 1 unit...2)i want to detect collision of a circle with the lines(which may be in slope), and after collision the circle should bounce in a paricular direction.....
Option # 1) Check if the lines is within the circle's position. The
circle position has an X,Y,Z coordinate. If the line is within the area
of the circle then there is a collision. And move the circle -x.
Option # 2) Check if the circle + radius is within the Top height
and the low height of the line. If so then check if its X position + radius
is within the lines X coordinate of the line. If so then there is a collision and
move circle to -x, maybe by making its x velocity = -x velocity.
firstPerson
Senior Poster
3,923 posts since Dec 2008
Reputation Points: 841
Solved Threads: 608
Okay, you clearly didn't write that code, so before you go any further, do you actually understand any of this or have a knowledge of OpenGL at all? if not, read a book or tutorial first then give it a shot.
i want to detect collision of a circle with the lines(which may be in slope), and after collision the circle should bounce in a paricular direction.....
If you want to bounce off an angled surface, your problem requires some physics, so unless you really know your stuff, don't consider this an easily achievable task.
William Hemsworth
Posting Virtuoso
1,591 posts since Mar 2008
Reputation Points: 1,429
Solved Threads: 129
This code is running good ... but I'm unable to make the ball fall down.
Plz tell what changes i should make to create gravity effects???
Constantly increment ySpeed by however strong you want the gravity to be.
Somewhere in your game loop, try:
ySpeed += 0.5f;
or a value of your choice (better stored as a constant variable).
William Hemsworth
Posting Virtuoso
1,591 posts since Mar 2008
Reputation Points: 1,429
Solved Threads: 129
Pretty much anywhere in your game loop, if you want an exact position, I would put it directly before the lines:
// Animation Control - compute the location for the next refresh
xPos += xSpeed;
yPos += ySpeed;
William Hemsworth
Posting Virtuoso
1,591 posts since Mar 2008
Reputation Points: 1,429
Solved Threads: 129
You're shouting again, and i don't understand your question.
William Hemsworth
Posting Virtuoso
1,591 posts since Mar 2008
Reputation Points: 1,429
Solved Threads: 129