(https://underwaredesign.com/forums/2021-04-29-PBFX-2D-Core-logo-250p.png)
PBFX 2D Core - DEMOS
ABOUT:
PBFX2DCore was a build of OpenGL based back end for PBFX that was originally in the works back in 2012... The demos included here are for historical use only..
Youtube:
DOWNLOAD LIBRARY:
Attached bellow.
PBFX 2D Core - Demo #1 - Setup
[pbcode]
; PROJECT : Example-01-Setup
; AUTHOR : Kevin Picone - http://PlayBASIC.com
; CREATED : 2/02/2012
; EDITED : 3/05/2021
; ---------------------------------------------------------------------
// include the PBFX 2D Core engine
#include "..\..\Engine\PBFX2DCORE.PBA"
// open the scene driver
if PBFX2D_OPEN()
// turn off the PB break key, as we now have to now close the driver
// upon exit before before our program completes
breakkey off
// Open the Screen / Device
global ScreenWidth =1280
global ScreenHeight =ScreenWidth*(9.0/16) ;0.75
PBFX_OpenScreen(ScreenWidth,ScreenHeight,32,0)
HDpath$="..\..\Media"
File$=HDpath$+"\Sun.png"
TileTexture=PBFX_loadImage(File$,8)
TileX=PBFX_GetImageWidth(TileTexture)
TileY=PBFX_GetImageHeight(TileTexture)
File$=HDpath$+"\bubble_64x64c.png"
BubbleTexture=PBFX_loadImage(File$,8)
PBFX_MakeImageAlpha(BubbleTexture,0)
// ---------------------------------------------------
do
// ---------------------------------------------------
// Draw to the SCREEN 0 ='s SCREEN
PBFX_RenderTo 0
// Clear it to the GREEB
PBFX_Cls($00ff00)
t=timer()
// --------------------------------------------
// DRAW TILED BACKDROP
// --------------------------------------------
PBFX_CaptureStart()
Colour=$fff880
Colour =rndrgb()
For ylp =-1 to (ScreenHeight/TileY)
y1=(ylp*TileY)
y2=(y1+TileY)
For xlp =-1 to ScreenWidth/TileX
X1=xlp*TileX
x2=x1+TileX
PBFX_DrawQuad(TileTexture,ScrollX+x1,ScrollY+y1,x2,ScrollY+y2,Colour,0)
next
next
PBFX_CaptureEnd()
ScrollY+=1
ScrollY&=TileY-1
// --------------------------------------------
// DRAW BUBBLE RING AROUND MOUSE POSITION
// --------------------------------------------
mx=PbFX_MouseX()
my=PbFX_MouseY()
x#=mx
y#=my
for ring=0 to 5+(10*PBFX_MouseButton())
Radius#=ring*75
for lp =0 to 359 step 10
Angle#=wrapangle(BaseAngle#+(lp))
x#=mx+cos(Angle#)*Radius#
y#=my+sin(Angle#)*Radius#
PBFX_DrawIMage(BubbleTexture,x#,y#,1)
next
next
BaseAngle# =wrapangle(BaseAngle#+1)
// Update the GL drive display
pBFX_SYNC()
// refresh PB SCREEN
cls
Print_TextureInfo(TileTexture)
// update PB SCreen
sync
frames++
// ---------------------------------------------------
loop spacekey() or GetScreenClose() or frames>1000
// ---------------------------------------------------
// open the scene driver
PBFX2D_CLOSE()
endif
end
function Print_TextureInfo(ThisTexture)
i=ThisTexture
if i
print PBFX_GetIMageWidth(i);
print PBFX_GetIMageHeight(i)
print PBFX_GetIMagePointer(i)
print PBFX_GetIMageModulo(i)
print PBFX_GetIMageFormat(i)
print PBFX_GetIMageType(i)
endif
EndFunction
[/pbcode]
PBFX 2D Core - Demo #2 - Setup
[pbcode]
; PROJECT : Example-02- Primitives
; AUTHOR : Kevin Picone - http://PlayBASIC.com
; CREATED : 2/02/2012
; EDITED : 4/05/2021
; ---------------------------------------------------------------------
// include the PBFX 2D Core engine
#include "..\..\Engine\PBFX2DCORE.PBA"
// open the scene driver
if PBFX2D_OPEN()
// turn off the PB break key, as now have to close the driver
// upon exit before our program completes
breakkey off
// Open the Screen / Device
global ScreenWidth =1280
global ScreenHeight =ScreenWidth*(9.0/16) ;0.75
PBFX_OpenScreen(ScreenWidth,ScreenHeight,32,0)
HDpath$="..\..\Media"
File$=HDpath$+"\Sun.png"
TileTexture=PBFX_loadImage(File$,8)
File$=HDpath$+"\bubble_64x64c.png"
BubbleTexture=PBFX_loadImage(File$,8)
PBFX_MakeImageAlpha(BubbleTexture,2)
// ---------------------------------------------------
do
// ---------------------------------------------------
// Draw to the SCREEN 0 ='s SCREEN
PBFX_RenderTo 0
// Clear screen
PBFX_Cls($204020)
t=timer()
// --------------------------------------------
// DRAW TILED BACKDROP
// --------------------------------------------
DrawTiledBackDrop(TileTexture)
PbFX_RenderTo 0
radius =100
baseangle=wrapangle(baseangle,1)
for angle=0 to 360 step 1
x1=screenwidth/2
y1=screenheight/2
x2=x1+Cos(BaseAngle+Angle)*RAdius
y2=y1+Sin(BaseAngle+Angle)*RAdius
PBFX_Ink $ff00ff00
PBFX_Line(x1,y1,x2,y2)
Radius+=5
PBFX_Ink $ffff0000
PBFX_Box(x2,y2,x2+20,y2+20)
next
if pbfx_mousebutton()
Colour = $113344
for z =100 to 4000 step 20
PBFX_Ink $00000 + ((Colour*z) and $00ffffff)
Radius#=(100*400.0)/(z+zoffset)
PBFX_Circle(pbfx_mousex(),PBfx_Mousey(),RAdius#)
next
zoffset=mod(zoffset-1,100)
endif
// Update the GL drive display
pBFX_SYNC()
// refresh PB SCREEN
cls
print "Sprites#"+str$(SpriteCount)
Print_TextureInfo(TileTexture)
// update PB SCreen
sync
frames++
// ---------------------------------------------------
loop spacekey() or GetScreenClose() or frames>500
// ---------------------------------------------------
// open the scene driver
PBFX2D_CLOSE()
endif
end
Function DrawTiledBackDrop(TileTexture)
static ScrollX,ScrollY
TileX=PBFX_GetImageWidth(TileTexture)
TileY=PBFX_GetImageHeight(TileTexture)
PBFX_CaptureStart()
Colour=$fff880
Colour =rndrgb()
For ylp =-1 to (ScreenHeight/TileY)
y1=(ylp*TileY)
y2=(y1+TileY)
For xlp =-1 to ScreenWidth/TileX
X1=xlp*TileX
x2=x1+TileX
PBFX_DrawQuad(TileTexture,ScrollX+x1,ScrollY+y1,x2,ScrollY+y2,Colour,0)
next
next
PBFX_CaptureEnd()
ScrollY+=1
ScrollY&=TileY-1
EndFunction
function Print_TextureInfo(ThisTexture)
i=ThisTexture
if i
print PBFX_GetIMageWidth(i);
print PBFX_GetIMageHeight(i)
print PBFX_GetIMagePointer(i)
print PBFX_GetIMageModulo(i)
print PBFX_GetIMageFormat(i)
print PBFX_GetIMageType(i)
endif
EndFunction
[/pbcode]
PBFX 2D Core - Demo #3 - Sprites
[pbcode]
; PROJECT : Example-03- Sprite Scene
; AUTHOR : Kevin Picone - http://PlayBASIC.com
; CREATED : 2/02/2012
; EDITED : 4/05/2021
; ---------------------------------------------------------------------
// include the PBFX 2D Core engine
#include "..\..\Engine\PBFX2DCORE.PBA"
// open the scene driver
if PBFX2D_OPEN()
// turn off the PB break key, as now have to close the driver
// upon exit before our program completes
breakkey off
// Open the Screen / Device
global ScreenWidth =1280
global ScreenHeight =ScreenWidth*(9.0/16) ;0.75
PBFX_OpenScreen(ScreenWidth,ScreenHeight,32,0)
HDpath$="..\..\Media"
File$=HDpath$+"\Sun.png"
TileTexture=PBFX_loadImage(File$,8)
File$=HDpath$+"\bubble_64x64c.png"
BubbleTexture=PBFX_loadImage(File$,8)
PBFX_MakeImageAlpha(BubbleTexture,2)
Type tSprite
X#,Y#,Z#
SpeedX#,SpeedY#
TintColour
endtype
Dim Sprites(25000) as tSprite
// ---------------------------------------------------
do
// ---------------------------------------------------
// Draw to the SCREEN 0 ='s SCREEN
PBFX_RenderTo 0
// Clear screen
PBFX_Cls($204020)
t=timer()
// --------------------------------------------
// DRAW TILED BACKDROP
// --------------------------------------------
DrawTiledBackDrop(TileTexture)
// --------------------------------------------
// DRAW BUBBLE RING AROUND MOUSE POSITION
// --------------------------------------------
SpriteCount= Render_Sprites(BubbleTexture)
// Update the GL drive display
pBFX_SYNC()
// refresh PB SCREEN
cls
print "Sprites#"+str$(SpriteCount)
Print_TextureInfo(TileTexture)
// update PB SCreen
sync
frames++
// ---------------------------------------------------
loop spacekey() or GetScreenClose() or frames>500
// ---------------------------------------------------
// open the scene driver
PBFX2D_CLOSE()
endif
end
Function Render_Sprites(ThisIMage)
ProjectX#=400
ProjectY#=400
Width =PBFX_GetImageWidth(ThisIMage)
Height=PBFX_GetImageHeight(ThisIMage)
Width2=Width/2
Height2=Height/2
scx=ScreenWidth/2
scy=ScreenHeight/2
Pad=100
MaxZ=5000
For lp =0 to GetArrayElements(Sprites())
if Sprites(lp)=0
Sprites(lp)= New tSprite
Sprites(lp).x = rndrange(Pad,screenWidth-Pad)-scx
Sprites(lp).y = rndrange(Pad,screenHeight-Pad)-scy
Sprites(lp).z = rnd(MaxZ)
Sprites(lp).TintColour =rnd($ffffff)
Speed=8
repeat
sx# = rndrange(-Speed,speed)
sy# = rndrange(-Speed,speed)
until sx#<>0 and sy#<>0
Sprites(lp).SpeedX=sx#
Sprites(lp).SpeedY=sy#
endif
x#=Sprites(lp).x;+Sprites(lp).SpeedX
y#=Sprites(lp).y;+Sprites(lp).SpeedY
z#=Sprites(lp).z-5
x1#=(((x#-Width2))*ProjectX#)/z#
y1#=(((y#-Height2))*ProjectY#)/z#
x2#=(((x#+Width2))*ProjectX#)/z#
y2#=(((y#+Height2))*ProjectY#)/z#
PBFX_DrawQuad( ThisImage,scx+x1#,scy+y1#,scx+x2#,scy+y2#, Sprites(lp).TintColour,1+8)
Sprites(lp).x=x#
Sprites(lp).y=y#
Sprites(lp).z=Z#
if z#<pad
Sprites(lp).x = rndrange(Pad,screenWidth-Pad) -scx
Sprites(lp).y = rndrange(Pad,screenHeight-Pad) -scy
Sprites(lp).z = MaxZ
endif
spritecount++
next
EndFunction SpriteCount
Function DrawBubbleRing(ThisTexture)
static BaseAngle#
mx=PbFX_MouseX()
my=PbFX_MouseY()
x#=mx
y#=my
for ring=0 to 5+(10*PBFX_MouseButton())
Radius#=ring*75
for lp =0 to 359 step 10
Angle#=wrapangle(BaseAngle#+(lp))
x#=mx+cos(Angle#)*Radius#
y#=my+sin(Angle#)*Radius#
PBFX_DrawIMage(ThisTexture,x#,y#,1)
next
next
BaseAngle# =wrapangle(BaseAngle#+1)
EndFunction
Function DrawTiledBackDrop(TileTexture)
static ScrollX,ScrollY
TileX=PBFX_GetImageWidth(TileTexture)
TileY=PBFX_GetImageHeight(TileTexture)
PBFX_CaptureStart()
Colour=$fff880
Colour =rndrgb()
For ylp =-1 to (ScreenHeight/TileY)
y1=(ylp*TileY)
y2=(y1+TileY)
For xlp =-1 to ScreenWidth/TileX
X1=xlp*TileX
x2=x1+TileX
PBFX_DrawQuad(TileTexture,ScrollX+x1,ScrollY+y1,x2,ScrollY+y2,Colour,0)
next
next
PBFX_CaptureEnd()
ScrollY+=1
ScrollY&=TileY-1
EndFunction
function Print_TextureInfo(ThisTexture)
i=ThisTexture
if i
print PBFX_GetIMageWidth(i);
print PBFX_GetIMageHeight(i)
print PBFX_GetIMagePointer(i)
print PBFX_GetIMageModulo(i)
print PBFX_GetIMageFormat(i)
print PBFX_GetIMageType(i)
endif
EndFunction
[/pbcode]