Posted: 15th Jan 2004 10:07
just a little demo I made last night.

it's basically 2D trajectory physics, synched up with the timer() to run at a constant speed regardless of framerate.

I think it's a relatively accurate system, which includes gravity (of course), and basic loss of energy on bouncing. the code is set up so that you can adjust the variables easily, and view the results. you can even add rudimentary wind if you want...

probably useful for anyone still struggling with gravity, and expecially usefull for those still using "sync rate 30" in their programs!

p.s. try changing the sync rate in this example, the system should run at the same speed regardless!

I've posted this in the codebase as well.

enjoy!

[edit] This was done in DBPro, no idea if it will work in DBC
Posted: 19th Jan 2004 22:57
You Should make the gravity real. It could make it even better and stand out more.
+ Code Snippet
inc Ball.Pos.y,(Ball.bounce*ElapsedInSec#)+(-9.81*(ElapsedInSec#^2))

That should work. If it doesn't then get acceleration to 9.81*time falling^2. I made it so whatever the initial velocity of the ball is ball bounce (the speed it bounces of the ground at) then whenever it hits the ground just reset the time.(I didn't read the code that well so im not sure it u already do.
Posted: 20th Jan 2004 6:32
yeah, the gravity currently doesn't have the ^2 part involved, but it would be really easy to add. I just adjusted the gravity constant until I got a simulation that lookd good to me.

as this is primarily for game development, I am generally more interested in making if "feel" or "look" right than being absolutely accurate.

that being said, I'll try what you said when I get home to my DBPro system tonight, and see if it looks better that way!

thanks for the input! I was afraid everyone was ignoring it

[edit] plus that code assumes that youre game world works with the scale 1 unit (pixel) = 1 meter. you would have to adjust the gravity constant based on your game world scale. [/edit]
Posted: 22nd Jan 2004 12:25
Command out of place at line 98

Anyone else?
Posted: 22nd Jan 2004 18:39
are you using DBC?

i just tried the code again and it worked fine for me...
Posted: 23rd Jan 2004 4:20
No dbpro, latest patch. Nutty.

Hey can you take a look at my code? Im trying to sync a pendulum swing based on looptime#. Maybe you can figure out what im doing wrong.

http://darkbasic.thegamecreators.com/?m=forum_view&t=24316&b=1
Posted: 27th Jan 2004 10:37
Command out of place at line 181 ?
Posted: 28th Jan 2004 4:31
this snippet is in DBPro, coded in the BLUE IDE... haven't tried it with the original editor... works fine for me, don't know what I can say
Posted: 3rd Feb 2004 17:17
try this version... I think the comments were causing trouble. otherwise I have no friggin' idea!
Posted: 17th Feb 2004 15:47
Works fine for me. Runs at about 390-425 FPS.

DBPro Update 5.2
Posted: 19th Feb 2004 6:09
perhaps it's something to do with the DBPro version?

it doesn't use any 3D commands though.

anyway glad it works for you!
Posted: 22nd Feb 2004 0:01
The time thing doesnt work because it seems timer() is entirely based on FPS, it doesnt run the same at Sync rate 30 and Sync rate 3.
Im thinking you should record Timer() over a course of time and use an average...:/

So im not so sure that the way you use Timer() to base events off of works correctly...
Posted: 2nd Mar 2004 6:07
actually that has to do with the accuracy of the physics engine. basically running at only 3 fps will cause all sorts of problems, because the system needs a few more chances to update the trajectory of the ball.

All physics systems have similar problems, the realism breaks down below a certain point. This system becomes less and less accurate as the frame rate drops, but it's acceptable down to about 15 fps in my opinion.

if I was using more complex physics formulas, it would be accurate at even slower framerates, but this is for game programming, so 3fps isn't really worth worrying about.
Posted: 2nd Mar 2004 19:22
hmz, when you shoot the ball at 90 degrees it does not bounce off once it hits the ground, even with a very large velocity. but nice job
Posted: 3rd Mar 2004 8:21
hehehe, never even tried shooting the ball at exactly 90 degrees