Here it is again - but sadly - this is with the timer not being used to adjust the animation speed - but I'm at a loss why it worked b4 and not now - the FPS I'm getting is 1300+ and I wonder
` Picasso's First SKY BOX
color backdrop rgb(150,150,255)
` PLAYER STUFF---------------------------------
` So I make the player 2 (meters) High, so his feet are at
` player y position -1 Ok? (cuz 0,0,0 is at the center of the cube)
` also learn what USER DEFINED TYPES are (UDT's) beause this player data
` should be wrapped in one.
global giPlayerID=1
global gfPlayerXPos#=0
global gfPlayerYPos#=200.0
global gfPlayerZPos#=0
global gfPlayerYVelocity#=0.0
make object cube giPlayerID,2
position object giPlayerID,0,gfPlayerYPos#,0
` GROUND STUFF---------------------------------
global giGround=2
make object box giGround,50,0.1,50
color object giGround, rgb(0,100,0)
` TIMER STUFF ---------------------------------
global giTime=Timer()
global giTimeOld=giTime-1
` want a float so math with floating point works - don't want
` integer (scalars) numbers for the type of stuff we're doing here
global gfTimeElapsed# ` float version
global giTimeElapsed ` integer version
global giHeartBeatTimeStamp=0
global giHeartBeatDelayInMilliSeconds=100
` GRAVITY (related) STUFF ---------------------------------
` I don't know the correct values here - but I'll guess
` I should use constants where the values aren't going to change
` (See giHeartBeatDelayInMilliSeconds - should be a constant, but...)
global gfGravityForce# = -3.0
global gfMaximumVelocity# = 66.00
autocam off
move camera -30
do
` Timer based movement and animations is the ONLY way to fly!
` anything else... well.. isn't timer based B^)
iTempTime=Timer()
iTempTimeElapsed = iTempTime-giTime
if iTempTimeElapsed > 0
giTimeOld=giTime
giTime=iTempTime
giTimeElapsed=giTime-giTimeOld
gfTimeElapsed#=giTimeElapsed
else
giTimeElapsed=0
gfTimeElapsed#=0
endif
` Here's the DEAL Brother... We are trying to simulate PHYSICS Right?
` So - most physics math uses time as a constant... so we're gonna make
` a simple heart beat dilly... basically, we only are going to change
` velocity values every tenth of a second
if ((giTime - giHeartBeatTimeStamp) >= giHeartBeatDelayInMilliSeconds)
` reset this 100 milli second timer for next go round
giHeartBeatTimeStamp=giTime
gfPlayerYVelocity#=gfPlayerYVelocity#+gfGravityForce#
if gfPlayerYVelocity# > 0
if gfPlayerYVelocity# > gfMaximumVelocity#
gfPlayerYVelocity# = gfMaximumVelocity#
endif
else
if gfPlayerYVelocity# < 0
if gfPlayerYVelocity# < (gfMaximumVelocity# * -1)
gfPlayerYVelocity# = gfMaximumVelocity# * -1
endif
endif
endif
endif
` But animation we should TRY to advance every frame for smoother end result on screen
if giTimeElapsed > 0
gfPlayerXPos#=Object Position x(giPlayerID)
gfPlayerYPos#=Object Position y(giPlayerID)
gfPlayerZPos#=Object Position z(giPlayerID)
` move the player based on velocity and the time elapsed
gfPlayerYPos#=gfPlayerYPos# + (gfPlayerYVelocity#* 0.001)
` we hit or are on ground??
if gfPlayerYPos# < 1.0
gfPlayerYVelocity#= (gfPlayerYVelocity#/ 2) * -1
gfPlayerYPos#=1 ` on the ground
endif
position object giPlayerID,gfPlayerXPos#,gfPlayerYPos#,gfPlayerZPos#
endif
set cursor 0,0
print "FPS:",screen fps()
print "gfPlayerXPos#:",gfPlayerXPos#
print "gfPlayerYPos#:",gfPlayerYPos#
print "gfPlayerZPos#:",gfPlayerZPos#
print "gfPlayerYVelocity#",gfPlayerYVelocity#
print "giTime:",giTime
print "giTimeOld:",giTimeOld
print "gfTimeElapsed#:",gfTimeElapsed#
print "giTimeElapsed:",giTimeElapsed
print "giHeartBeatTimeStamp:",giHeartBeatTimeStamp
print "giHeartBeatDelayInMilliSeconds:",giHeartBeatDelayInMilliSeconds
print "gfGravityForce#:",gfGravityForce#
print "gfMaximumVelocity#:",gfMaximumVelocity#
if keystate(2)=1 then gfPlayerYVelocity#=gfPlayerYVelocity#+0.03
sync
loop
Pressing "1" pushes the block back up... anyways... I tried - I'm tired - brain done for the day