UnderwareDESIGN

PlayBASIC => Game Design => Topic started by: bmorris on April 05, 2013, 07:01:24 AM

Title: "Single buffering" via swapscreen repetition
Post by: bmorris on April 05, 2013, 07:01:24 AM
When I translated Creeping Angels from DarkBasic to PlayBasic, the biggest challenge was converting from a one-screen to a double-buffering regime; I ended up putting all the disparate display functions into one big function, controlled through its arguments. Happily, the new version works just as well as the old.

It occurred to me recently that I could've bypassed this in the following simple way: by calling swapscreen before as well as after every (disparate) gfx/text command block, thereby totally ignoring one of the two screens.

What do you think about this strategy? It feels to me like "missing the point" of double buffering, but in the context of games with simple, turn-based gfx, I can't see anything fundamentally wrong with it.
Title: Re: "Single buffering" via swapscreen repetition
Post by: kevin on April 05, 2013, 02:55:29 PM
 DB is also double buffered, except they render  2D to a 'mock up' screen and overlay it.  

Here's a rough approximation.  And you don't have to flip the buffers multiple times.

[pbcode]

   global Screen=NewImage(GetSurfaceWidth(),GetSurfaceHeight())
   rendertoimage Screen
   
   Show()   

   print "some Stuff"

   Show()

   print "some Stuff"
   print "some Stuff"
   print "some Stuff"

   Show()

   waitkey
   



Psub Show()
  oldsurface=getsurface()

   rendertoscreen
   drawImage Screen,0,0,false     

  rendertoimage oldsurface
EndPsub

[/pbcode]


Title: Re: "Single buffering" via swapscreen repetition
Post by: bmorris on April 06, 2013, 03:11:11 AM
I see. Thanks for filling me in on this - although, alas, in my future programming I'll probably adhere to standard double buffering.