Go Back   Zune Boards > Zune Discussions > Zune Games > Development Discussions > Development Help

Development Help For help from coding to error finding to that one thing you just can't get right

Reply
 
LinkBack Thread Tools
Old 10-30-2009, 02:07 PM   #1 (permalink)
Experienced Zuner
 
Join Date: Jul 2008
Location: Kingdom Hearts...Duh
Posts: 225
itsthatsguy is on a distinguished road
Default Gravity help

hey guys, need some more help with a formula. So i have this formula that calculates gravity, which Should be a constant force, and in the program it looks like it is, but for some reason it only happens if i have a collision with the upper wall (if x <= 0) heres the update code for the bounding box and the gravity formula.\

Code:
                if (r.getXpos() >= 244)
                {
                    r.setXspeed(r.getXspeed() * -1);
                    r.setXpos(243);
                }
                if (r.getXpos() <= 0)
                {
                    r.setXspeed(r.getXspeed() * -1);
                    r.setXpos(1);
                }
                if (r.getYpos() >= 452)
                {
                    r.setYpos(451);
                    r.setYspeed(r.getYspeed() * -1);
                }
                if (r.getYpos() <= 0)
                {
                    r.setYpos(1);
                    r.setYspeed(r.getYspeed() * -1);
                }
Btw r is a "red ball" its a foreach loop. this part of the code finds collison with the edges fo the screen

Code:
if (r.getGrav() <= 6)
                {
                    r.setGrav(r.getGrav() + 1);
                }

                r.setYpos(r.getYpos() + r.getYspeed());
                r.setXpos(r.getXpos() + r.getXspeed() + r.getGrav());
the if statement is how we calculate gravity until the ball reaches terminal velocity (its max fall speed0
The second part is where we update the balls position based on its speed and gravity.
__________________
go on, buy the melon you started wanting a second ago...




itsthatsguy is offline   Reply With Quote

Advertisement [Remove Advertisement]
Reply

Bookmarks

Thread Tools