So, I'm trying to code some gravity, well, any collisions really. I still haven't figured out why this results in jittering effects of the objects though. I'll just hand the full source out below, it doesn't do much and is mostly stolen from the documentation anyway:
Rem Project: wasdWalk
Rem Created: 5/1/2009 9:22:57 AM
Rem ***** Main Source File *****
rem Standard Setup Code
sync on : sync rate 0 : color backdrop rgb(0,0,64) : backdrop on
set text font "arial" : set text size 16
set text to bold : set text transparent
rem Loading prompt
sync : center text screen width()/2,screen height()/2,"LOADING" : sync
rem Create Level
make object box 10, 100, 5, 100
position object 10, 0, -20, 0
set object collision on 10
rem load gordo object
load object "gordo.x", 1
position object 1, 0, 0, 0
scale object 1, 400,400,400
rem setup player control
playerXmovement = 0
playerYmovement = 0
playerZmovement = 0
gravity = 1
inputDir$ = "none"
rem enable collisions for player object
set object collision on 1
rem Main loop
desc$="project wasd walk"
do
rem Control camera automatically
control camera using arrowkeys 0,0.1,1
rem control player object
inputDir$ = "none"
if keystate(17)=1 then inputDir$ = "up" rem "W up"
if keystate(31)=1 then inputDir$ = "down" rem "S down"
if keystate(30)=1 then inputDir$ = "left" rem "A left"
if keystate(32)=1 then inputDir$ = "right" rem "D right"
rem setup quick values for player movement and positioning
px = object position X(1)
py = object position y(1)
pz = object position z (1)
pyrotate = object angle y (1)
pxrotate = object angle x (1)
pzrotate = object angle z (1)
rem gravity pulls player down
position object 1,px,py-gravity,pz
if object collision (1,0)
position object 1,px,py+gravity,pz
endif
rem display input direction value for debugging
text 20,40,inputDir$
rem Show Framerate
text 20,screen height()-40,desc$
fps$="DBPro Fps: "+str$(screen fps())
text screen width()-20-text width(fps$),screen height()-40,fps$
rem Update screen
sync
rem End loop
loop
Anyway, the main part I am concerned about is the gravity code. When the program is run, the object keeps "bouncing".
I think what is happening is that DBPro is rendering the movement of the object down, and then instantly rendering it again as it's moved back up, resulting in the twitching. But I don't know how to fix it, as my rendering code is the same as the example's code, which contains a sync command at the end that should result in rendering the game AFTER the movement, not before.
I'd like to add that I clearly have no idea what I am doing. :p It's been several months since I last used DBPro, and it was the autocomplete feature in the recent update that brought me back(I have trouble remembering command syntax, it's a side effect of my medical situation, so this has made it possible for me to actually type stuff without having to look up every command for hours.)
Oh, to test the code, just replace the gordo.x with whatever file you like, it's just a 3d model used to test for now, so it doesn't matter what it is, within reason of course. A giant level model probably won't work well since it'll end up inside the floor. x_x