News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

SyncImage

Started by kevin, March 06, 2007, 12:01:03 PM

Previous topic - Next topic

kevin

   PlayBASIC FX (Beta) V1.68 and above supports more than one image type.  As you know, there's the video, FX + 3D image types. Which can also be combined.    Since images can  have more than one playfield, we have some new commands to active playfields (the one render occurs on / from) plus a way to sync up (copy) a playfield data between the SyncImage.  

  Confused ? you should be :)   Not to worry. You'll pretty much only use this with pixel based sprite collisions.   For example, lets say you wanted 3D rendering & pixel collision for your sprites.   In this case you'd create images with FX + 3D playfields.   Then copy the Sprite image data to the 3D playfield (the version of the image we see) and then either sync the 3d image to the fx playfield (copy it)  or a load custom  mask of the image to the FX playfield.   Yes, this means you'll be able could filter pixel based collisions    A filter version would just be a 'hard' zone version of the image.   So you (the art guys) can mask stuff out of the images like black outlines, shadows etc etc that some sprites have.   So the collision only registers when the hard pixels are hit.  

 Anyway, here's a bit of example of the new commands.  The demo creates a image with a video +Fx playfield, then lets you render / flip between the playfields.  





MyImage=1

CreateImageEx MyImage,100,100,1+2 ; My IMage now contains a video + FX buffer playfield

Do

Cls 255

Select PLayfieldFlag=0
case 0
IMagePLayfield MyImage,1 ; Set to Video Playfield
   Message$="Showing Video Playfield"
case 1
IMagePLayfield MyImage,2 ; Set to FX Playfield
   Message$="Showing FX Playfield"
EndSelect


if FillPlayfield=false
rendertoimage MyImage
For lp=0 to 100
; circlec rnd(100),rnd(100),rnd(10),true,rndrgb()
Dotc rnd(100),rnd(100),rndrgb()
next

FillPlayfield=true
rendertoscreen
endif



DrawImage MyImage,100,100,false


if lower$(Inkey$())="r"
FillPlayfield=false
Flushkeys
endif

if Spacekey()
PlayfieldFlag=1-PLayfieldFlag
Flushkeys
endif




if Enterkey()
; Copy the Visible playfield, to the background playfield

if GetIMagePLayfield(MyImage)=1
SyncImage MyImage, 1, 2
else
SyncImage MyImage, 2, 1
endif
FlushKeys
endif

print Message$
print "Current Playfield:"+str$(GetIMagePLayfield(MyImage))
print "Space = Swap Image render to playfields"
print "Enter = Sync Image playfields"

Sync
loop


Sync
waitkey