News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Challenge #7 - Timer Based Movement

Started by kevin, May 12, 2007, 12:18:58 AM

Previous topic - Next topic

kevin





Challenge #7 - Timer Based Movement


  This challenge brings up the age old chestnut of 'Timer Based Movement".  For the this challenge, you'll need to implement a movement system that can control objects moving at a constant speed and direction.   The positions,  speed and direction should be assigned randomly when the object is spawned.   The object shall die when it leaves the display completely.

  The Game Clock should simulate a sync rate of 50FPS,   regardless of the of speed of the machine it's running on.   Each frame of the game clock (every 1000/50 milliseconds), the game  should randomly spawn one  object.   The spawn rate should be consistent regardless of frame rate also!

  The example should not saturate the host computer when running upon faster machines.

  The example should include (be based on) the following test code main loop for testing purposes.  This will allow you to simulate the effect of system system upon your example.


PlayBASIC Code: [Select]
   ; Set PB to limit the max rate to 50 or less. 
SetFPS 50



Do
Cls 0


; Update



; Output Information
print "REAL Sync Rate:"+str$(Fps())
print " MAX Sync Rate:"+str$(GetFps())

; Bump the PB sync rate up, clamp it at 100
if upkey()
Setfps GetFps()+1
endif


if downkey()
currentFPs=GetFps()
if CurrentFps
Setfps CurrentFps-1
endif
endif


; Show the Back buffer
Sync
loop






Submission

* Submissions can be written in any version of PlayBasic

* Submission can only be accepted in Source Code form only.

* Authors can use external Media (images/music) provided you created the media, have permission to use somebody else's media or the media is public domain.

* Zip up your Submissions and please try to keep it smaller than 500K !

* Authors automatically give consent for their submission(s) to distributed and used for promotional purposes via UnderwareDesign.com, PlayBasic code tank.

* Authors can submit as many times as they like.

* To make a submission, zip up your projects source code + media and either post it in this thread, or create your own a thread the Source Codes or Show Case forums and post a link bellow.


Dead Line

Anytime before the next ice age





kevin

#1
Timer Based Movement In PlayBasic

  Here's my submission. It ended up taking a few days since I decided to add a bit of tutorial with it. Which turned out  longer than anticipated,  As usual..  


 Timer Based Movement Tutorial & Examples

Timer Based Movement Tutorial