Main Menu

Ultra smooth graphics

Started by gingerprince, September 23, 2006, 01:27:20 AM

Previous topic - Next topic

gingerprince

As a current Blitzbasic 2d user I am very interested in PLAYBASIC,especially all of its powerful graphics commands.
My only bugbear with any new language I try is that I love to get Ultra Smooth graphics - top priority - something that came easily with Bllitz.
Can you confirm that PLAYBASIC is equally as capable at this.
I`ve listed a small frame limiting routine below which is one of the methods I use to keep things running well and I`ve adapted it for playbasic.....feel free to look at it and use it as an example if you wish.

Is this routine doing effectively what SETFPS is doing but with more user control

cheers



; PROJECT : shooter_1.3_230906
; AUTHOR  : longshaws
; CREATED : 22/09/2006
; EDITED  : 23/09/2006
; ---------------------------------------------------------------------

openscreen 800,600,32,2

;loadimage "graphics\test_ship1.bmp",1

circle 16,16,13,1

getimage 1,0,0,32,32

x#=400.0
y#=300.0

drawimage 1,x,y,1

targetfps#        = 30.0 ;FRAME SPEED YOU WISH TO KEEP TO (DOESN`T NEED TO BE HIGH TO BE SMOOTH
speedfactor#      = 0.0
framespersecond#  = 0.0
tickspersecond    = 1000
currentticks      = 0
framedelay        = timer()


Do
   

   ;ROUTINE BORROWED FROM blitzbasic TO KEEP SPEED SAME ON ANY MACHINE 
   currentticks = timer()
   speedfactor#  = ( currentticks - framedelay ) / ( tickspersecond / targetfps#)
   
    If speedfactor# <= 0 Then speedfactor# = 1
   
   framespersecond# = targetfps# / speedfactor#
   framedelay = currentticks
     
   
   If LeftKey()=1 Then x#=x#-(1*speedfactor#)
   
     If RightKey()=1 Then X#=x#+(1*speedfactor#)
   
     If UpKey()=1 Then y#=y#-(1*speedfactor#)
 
     If DownKey()=1 Then y#=y#+(1*speedfactor#)
     
     cls 0
   
     DrawImage 1,x#,y#,0
     
   
     Sync
  loop

setfps