943,769 Members | Top Members by Rank

Ad:
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Aug 31st, 2009
0

Re: RAMP GAME

I know the physics thing .......but i don't know how interact both the things......
I mean i can make a class of VECTOR working for 2D, it can find the dot product, addition, subtraction and all.
But i don't how interact this class with the circle to find collision detection....
Reputation Points: 8
Solved Threads: 0
Newbie Poster
ammadkhan is offline Offline
12 posts
since Aug 2009
Sep 1st, 2009
0

Re: RAMP GAME

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???
Reputation Points: 8
Solved Threads: 0
Newbie Poster
ammadkhan is offline Offline
12 posts
since Aug 2009
Sep 2nd, 2009
0

Re: RAMP GAME

Click to Expand / Collapse  Quote originally posted by ammadkhan ...
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).
Last edited by William Hemsworth; Sep 2nd, 2009 at 9:32 am.
Reputation Points: 1429
Solved Threads: 129
Posting Virtuoso
William Hemsworth is offline Offline
1,542 posts
since Mar 2008
Sep 2nd, 2009
0

Re: RAMP GAME

I have changed these lines of code
GLfloat xSpeed = 0.0f;      // Ball's speed in x and y directions
GLfloat ySpeed = 0.05f;
Now the ball is moving in y-axis only...
And William where i should make these changes u r talking ??
ySpeed += 0.5f;
Reputation Points: 8
Solved Threads: 0
Newbie Poster
ammadkhan is offline Offline
12 posts
since Aug 2009
Sep 2nd, 2009
0

Re: RAMP GAME

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;
Reputation Points: 1429
Solved Threads: 129
Posting Virtuoso
William Hemsworth is offline Offline
1,542 posts
since Mar 2008
Sep 2nd, 2009
0

Re: RAMP GAME

Thanks William it is working......
// Animation Control - compute the location for the next refresh
   ySpeed -= 0.04f;
   xPos += xSpeed;
   yPos += ySpeed;
NOW I HAVE A QUESTION, IF THE BALL DETECTS ANY COLLISION IN BETWEEN THE SCREEN WILL IT MOVEIN X-AXIS OR NOT????
I MEAN I SET THESE LINES OF CODE
GLfloat xSpeed = 0.0f;      // Ball's speed in x and y directions
GLfloat ySpeed = 0.001f;
[edit]
which means ( GLfloat xSpeed = 0.0f; ) this will effect the ball to move in x-axis if the ball detects any sloped line ....right?
[/edit]
Last edited by ammadkhan; Sep 2nd, 2009 at 12:56 pm.
Reputation Points: 8
Solved Threads: 0
Newbie Poster
ammadkhan is offline Offline
12 posts
since Aug 2009
Sep 2nd, 2009
0

Re: RAMP GAME

You're shouting again, and i don't understand your question.
Reputation Points: 1429
Solved Threads: 129
Posting Virtuoso
William Hemsworth is offline Offline
1,542 posts
since Mar 2008
Sep 2nd, 2009
1

Re: RAMP GAME

I'm not shouting my friend...
First tell me how can i attach my file here in the thread?
then will understand my problem...
Reputation Points: 8
Solved Threads: 0
Newbie Poster
ammadkhan is offline Offline
12 posts
since Aug 2009
Sep 2nd, 2009
-2

Re: RAMP GAME

http://www.4shared.com/file/12969485...8122/ramp.html
CHECK THIS OUT , I HAVE MADE A .bmp FOR U.
[EDIT]
NOW U CAN SEE THE SLOPED LINES TO WHICH THE BALL IS INTERSECTING,
NOW AFTER INTERSECTION THE BALL WILL TRAVEL BOTH THE AXIS i.e X AND Y.
I WRITE THIS LINE IN MY CODING
GLfloat xSpeed = 0.0f;      // Ball's speed in x and y directions
GLfloat ySpeed = 0.001f;
WHICH MEANS BALL HAS ONLY ySpeed BUT NOT xSpeed, WHICH FURTHER MEANS THE BALL WILL MOVE IN ONLY ONE DIRECTION i.e Y-AXIS.
U GOT ME NOW?
Last edited by ammadkhan; Sep 2nd, 2009 at 3:49 pm.
Reputation Points: 8
Solved Threads: 0
Newbie Poster
ammadkhan is offline Offline
12 posts
since Aug 2009
Nov 15th, 2009
0
Re: RAMP GAME
Well , Thanks William..... That was very very helpful....
Sorry because my English is not that much strong to specify my question correctly.......
But u helped anyways.....
Reputation Points: 8
Solved Threads: 0
Newbie Poster
ammadkhan is offline Offline
12 posts
since Aug 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Game Development Forum Timeline: Searching for coders
Next Thread in Game Development Forum Timeline: Recommended C# - XNA Game Software





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC