Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Bounce Too High

Author
Message
Cr4t3r
22
Years of Service
User Offline
Joined: 28th Oct 2003
Location: Portland, OR
Posted: 7th Aug 2005 07:15
I'm trying to get a good bounce but each arc is higher than the last. I should bounce lower and lower until it rolls. Where is my error?

Width = 800
Height = 600
Depth = 32
SET DISPLAY MODE Width, Height, Depth

X AS WORD `Location 'X'
X = 0
Y AS WORD `Location 'Y'
Y = Height/2
XVel AS FLOAT `Velocity 'X'
XVel = 1
YVel AS FLOAT `Velocity 'Y'
YVel = -4
Gravity AS FLOAT
Gravity = 0.225
TempA AS FLOAT


CIRCLE X, Y, 10
DOT X, Y
SLEEP 1500


WHILE X < 640
SLEEP 50
YVel = Yvel + Gravity
X = X + XVel
Y = Y + YVel
IF Y >= Height
TempA = Height - Y
Y = Height + TempA
YVel = YVel * -1
ENDIF
DOT X, Y
ENDWHILE

If there's anything else wrong with my code, or it could be more streamlined, I could you use the help. Mostly I just want the dot to bounce.

Thanks!

I do not feel pain; only the lack of a controller.
BlinkOk
22
Years of Service
User Offline
Joined: 22nd Oct 2003
Location:
Posted: 8th Aug 2005 02:59
it's because you have defined the x and y values as word (integers) the small gravity increments are getting rounded and consequently the curve is growing.
if you change the x, y values to FLOAT then you will get an even curve on the bounce.
if you want the curve to scale down then add friction. something like this;


P4 2.8Ghz, 2Gb, 128Mb Radeon Pro, Dark Basic PRO
Cr4t3r
22
Years of Service
User Offline
Joined: 28th Oct 2003
Location: Portland, OR
Posted: 8th Aug 2005 07:55
Thank you! I applied friction to both XVel and YVel, and now as it moves it slows down and bounces less.

I do not feel pain; only the lack of a controller.

Login to post a reply

Server time is: 2026-07-08 10:17:39
Your offset time is: 2026-07-08 10:17:39