merry xmas and a better new year to all.
thanks scott for the gifts. you seem to always be busy working on something or another. i always look forward to seeing what you code.
you seem to code a good variety of programs too.
all the best for 2024 and beyond.
stevmjon
Good job... Scotty and Happy New Year to you also
PlayBASIC Source Code Snippet - Ball Following Mouse - (2024-01-09) in this example PlayBASIC source code, we create a ball that moves towards the mouse with what seems like some soft acceleration. The code also includes method to decouple the programs execution speed from the performance from the machine running the code. This is achieved by monitoring the how much time has past between updates and only moving the characters when enough time has past. If too much time has past we step the movement as per the required number of frames past.
[pbcode]
PlayerX# = GetScreenWidth()/2
PlayerY# = GetScreenHeight()
// Frame rate we're targeting
TicksPerFrame# = 1000.0/100
// Current frame we're on
CurrentFRAME = 0
// Time when this program Starts
FrameStart = timer()
do
// Check how much time as Past since program started
TimePast#=(timer()-FrameStart)
// Is it time to move characters or not ??
if (CurrentFRAME*TicksPerFrame#)<TimePAST#
// See how much time as past since we might need to move
// things more than once this refresh.
FramesPAST = ( TimePAST# - (CurrentFRAME*TicksPerFrame#) ) / TicksPerFrame#
// Move everything
for FrameCOUNT =1 to FramesPAST
gosub Update_Logic
CurrentFRAME++
next
endif
// Scroll Wheeel to force a frame rate (simulate slower computers)
LImitedFPS=cliprange(LimitedFPS+mousemovez(),0,1000)
if GetFps()<>LImitedFPS
Setfps LImitedFPS
endif
// Draw the scene
cls
print "Machine FPS:"+str$(LImitedFPS)
circle PlayerX#,PlayerY#,30,true
sync
loop
Update_Logic:
mX#=mousex()
mY#=mousey()
PlayerX# = curvevalue( mX#,PlayerX#, 20)
PlayerY# = curvevalue( mY#,PlayerY#, 20)
return
[/pbcode]
just for fun i made all the graphics from inside PB.
also modified the re-dim arrays to only use re-dim when increase in size. no need to re-dim each frame when the array size has not changed.
have fun, stevmjon