News:

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

Main Menu

PlayBASIC V1.64N2 / V164N3 (Work In Progress) Gallery

Started by kevin, April 22, 2012, 12:07:12 AM

Previous topic - Next topic

micky4fun

PlayBASIC V1.64N3 - Beta 6

working fine for me

mick :)

OldNESJunkie

PlayBASIC V1.64N3 - Beta 6

working fine for me as well...

stevmjon

PlayBasic V1.64N3 beta 6

cool banana's.

stevmjon
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

kevin

#78
 PlayBASIC V1.64N3 - Beta 7

      A new beta ? Yep, was right on the eve of releasing this update today (docs completed) when few issues have been spotted.  The main one apparently dates back to the Learning Edition (almost years ago), because all the subsequent versions I tested had the same drama, given the same situation.   Where the camera wasn't waiting fort the blitter to complete it's work before locking it, potentially killing the app.  Not good.    
 
      It just so happens to occurs in an example I was writing for the doc's,  where sometimes the circle would be 'flashy' (drawing while the blitter was drawing) or if you ran it full screen exclusive it'd generally die.    So would very much appreciate some feedback on if that's been solved in this beta from you guys also.   Just un-comment the OpenScreen statement.  


PlayBASIC Code: [Select]
    ; 
// openScreen 800,600,32,2

; -----------------------------------------------------
; --------->> SET UP <<------------
; -----------------------------------------------------


Setfps 100


; Radius of test circle
Radius=100


; create the random map from some circles
Map,Level=Build_Random_Map(32,32)


; make a backdrop picture
BackDrop=NewIMage(800,600)
rendertoimage Backdrop
c1=rndrgb()
c2=rndrgb()
shadebox 0,0,800,600,c1,c1,c2,c2
rendertoscreen


; create a camera to view the scene with
Cam=NewCamera()
CameraCls Cam,Off



; -----------------------------------------------------
; --------->> MAIN LOOP OF PROGRAM <<------------
; -----------------------------------------------------

Do

; Get the camera current position
CamX=getCameraX(cam)
CamY=getCameraY(cam)

; Get the mouse position
MX=MouseX()+CamX
MY=MouseY()+CamY

Method$="CircleHitMap"
if Method=0
; Test if the Circle Hits the Map blocks
Collision=CircleHitMap(Map,Level,MX,MY,RAdius)
else
; Test if the Circle Hits the Map at pixel level
Collision=CircleHitMapPixels(Map,Level,MX,MY,RAdius)
Method$+="Pixels"
endif


if Collision
Colour=$ff0000
Message$="Hit"
else
Colour=$0000ff
Message$="Missed"
endif


; tell PB to capture the following drawing commands
CaptureToScene

; clear the scene buffer so it's empty
ClsScene

; set the capture depth of the next item to a depth of
; 100 units
capturedepth 100
drawimage BackDrop,CamX,CamY,false


; draw the map level
CaptureDEpth 10
Drawmap map,Level,0,0


; draw the circle at this depth
CaptureDEpth 20
Circlec MX,MY,Radius,true,colour


; draw the scene with this camera
drawcamera cam


; Check if the Space key was pressed
if Spacekey()
; if so, change the collision method
Method=1-Method
flushkeys
endif

; check if the ENTER key was pressed
if EnterKey()
; If so, toggle Debug mode on the map
MapDebug Map,1-GetMapDebug(Map)
flushkeys
endif


; check if the users wanted to move the camera
if LeftKey() then MoveCamera Cam,-2,0
if RightKey() then MoveCamera Cam,2,0
if upKey() then MoveCamera Cam,0,-2
if downKey() then MoveCamera Cam,0,2

setcursor 0,0
ink $ffffff
print "Press Space To Change Methods"
print "Method:"+Method$
print Message$
Sync
loop


; -----------------------------------------------------
; ------------->> Build Random Map Scene <<------------
; -----------------------------------------------------


Function Build_Random_Map(BlockWidth,BlockHeight)


BackdropColour=$008f00

screen=newfximage(2400,1600)
rendertoimage screen
cls BackdropColour
circlec 800,400,400,true,$8f8f8f
circlec 1700,400,400,true,$0f8faf

for lp=0 to 150
x=rnd(2400)
y=rnd(1600)
rx=rndrange(50,150)
ry=rndrange(10,50)
ellipsec x,y,rx,ry,true, BackdropColour
next

Login required to view complete source code



Download

   obsolette file removed


stevmjon

#79
PlayBasic v1.64N3 beta 6 : i couldn't see the mouse circle at all, in window mode or fullscreen mode (no crash in fullscreen).

PlayBasic v1.64N3 beta 7 : beautiful. all systems a go captain. i could see the mouse circle in both window and fullscreen mode, display was very smooth.

tested in windows 7 home premium.

stevmjon
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

ATLUS


stevmjon

PlayBasic v1.64N  :  could only partially see mouse circle with a flickering, in both fullscreen & window mode.

PlayBasic v1.64N3 beta 7  :  worked perfect, in both fullscreen & window mode.

tested in windows XP pro.

     stevmjon
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

OldNESJunkie

Seems to work here too, except I get an error if I don't change this line:

if Tile==GetMapBlocks(Map) then exitfor ylp

to this:

if Tile=GetMapBlocks(Map) then exitfor ylp

for some reason...

kevin

#83
 that'd be because == isn't a supported operator.

It would appear PBCODE highlighter parses  "=>"  as "==" will fix that after.    (Fixed: PBCode parser updated 2012-09-18)

 

kevin


  PlayBASIC V1.64N3 - Beta 8

       Today (so far) has been all about optimizing.  As you've no doubt gathered i'm constantly trying to trim much  fat off the bones as I can, without breaking the bank.  Made some tweaks with the shape command sets again,  looking to improve the edge generation mainly, but have added a couple of special case render routines for drawing dots and lines.    Simple changes  that give a pretty sizable bang for your buck.   The changes help win about another say 10-25% (depending on the density of the shape) and more in some examples.     Seeing about a 50fps increase in the shape particle demo between today's build over V1.64N2...   But only about 15fps increase "Shape Particle Sprinkler"  (35000-36000 alpha adds points)


        Here's i'm just testing the span filling fill rate...

PlayBASIC Code: [Select]
   loadfont "arial",1,24

max =500

; ShapeQuantity Max*2

For lp =1 to max
CreateConvexShape lp,100,3+(lp and 7)
next

Do

Cls

frames++

t=timer()
xpos=0
ypos=0
lockbuffer
For lp=1 to max
ink rndrgb()
offset=lp*2
drawshape lp,xpos+offset,ypos+offset,2
next
unlockbuffer
tt#+=TImer()-t

ink -1

print tt#/frames

Sync
loop









 

kevin

#85
  PlayBASIC V1.64N3 - Beta 9 - Shape Tweaking

       Spent last night updating the Shape section of the help, which was pretty old.  Mainly just house keep stuff, cleaning the examples, adding a few pictures and more text etc.  Thrilling stuff.      In previous session I've been tackling shape filler routines, mostly getting some wins, but not always.  The filler is marginally quicker in today's build, but nothing you're likely to notice in everyday programs.   The brute force test ( the one posted above) runs about 4 milliseconds quicker.  Really a span clipper would run rings around that, but anyway.        

       While picking over the shape library (which is one of the oldest parts of PB)  noticed some legacy functions that are less than optimal as well as few that are no longer in use even.  So been fine tuning those bits over the last day or so.

        Result wise, it's pretty pleasing, the spacial partition demo from years and years ago which uses some asteroid looking shapes running about twice as quick (390 average fps) in today's build when compared back to V1.64L  upgrades (160 average fps).    There's not really any one change that makes the difference, it's more a bunch of often small changes over time.    


kevin

#86
 PlayBASIC V1.64N3 - Beta 9

      I'm pretty much done with this now,  so here's what i'm hoping will be the final beta in this mini upgrade..  Give it run on your stuff and if there's nothing found in the next day or so, we'll package up the upgrade and upload it.



Download

   obsolete file removed



kevin


  Ignore..  Just testing for the moment....


PlayBASIC Code: [Select]
   ; Inlude the Blit Image functions
#include "BlitImage"


; Create an FX image the size of the screen

Depth=32
Width=800
Height=600
MyImage=NewfxImage(GetScreenWidth(),GetScreenHeight())
CReateFXIMageEx MyIMage,Width,Height,Depth

Screen=GetFreeIMage()
CReateFXIMageEx Screen,Width,Height,Depth
imageviewport screen,100,100,400,400

; Start of Demo loop
Do

; redirect all drawing to this image
RenderToimage MyImage



; Set the Ink mode drawing pen to ALPHA 50 (50% blend)
InkMode 1

c2=-1
; shadebox 0,0,width,height,c1,c1,c2,c2

; Set the Ink mode drawing pen to ALPHA 50 (50% blend)
InkMode 1+32

; draw a circle at the mouses current position
Circle mousex(),Mousey(),100

; redirect all drawing to screen back buffer
rendertoimage Screen

; To do combined Blit (copy) our Image, with combined CLS of image.
; to the PB screen
BlitImageClear(MyImage,0,0,rgb(30,50,100))


rendertoscreen
drawimage Screen,0,0,false

setcursor 0,0
print GetImageDepth(Screen)


; Display Message
print "Using BlitImageClear to draw MyImage with Clearing"

; flip the back buffer to the front, so the user can see it
Sync

loop




kevin

#88
 PlayBASIC V1.64N3 - Beta 9b - Threading Test

   Just uploaded  PlayBASIC V1.64 N3  Beta #09b, this represents an experiment in threading.   Threads are a way to offload the execution of parts of your program from the main cpu and onto any other cores your system may have.   Thus sharing the load across the CPU cores in your computer, potentially resulting in better frames rate..  Meaning more action in your games.   We've fooled around with threading before, namely by attempting to split large blit jobs into swarms, which is slightly easier on the user, but very problematic to implement.    I've messed around with this a lot now and it would seem that just because the work load is shared, doesn't mean necessarily mean it'll would run quicker !

    Anyway, another solution is to attach threading into the BLITFX functions again, but this time treat each call as a JOB push.  So when we call a blit fx function, the request is passed off onto a secondary thread.   The render functions are customized so that once the job is pushed, we can then change surfaces and render something else while it's doing the bigger job in parallel.   This is easier to include in PB, but means you need to specifically write your code to take advantages of it.

     As for how well it works..  well i've no idea yet..  So get testing :)


Download

 Get Latest Beta (login required)



Threading Example

  This example, demo's asynchronous rendering.  At it's heart it's drawing a batch of circles, while it's copying the screen sized image to the PB screen.   We're using two separate FX screens here to avoid stalling.   If we only used one, it couldn't run them it parallel, as we'd be copying to the screen with altering the same image at potentially at the same time.  

PlayBASIC Code: [Select]
   #include "BlitIMage"

Type tCircle
x#,y#
SpeedX#
Size
Colour
EndType


Dim Object as tcircle list

For lp =0 to 500
Object= New tCircle
Object.x# =rndrange(-800,1600)
Object.SpeedX# =rndrange#(1,5)
Object.y# =rnd(600)
Object.size =rndrange(10,50)
Object.Colour =rndrgb() and $0f0f0f
next


Dim Screens(1)

; CReate two FX buffers. We'll be doubling buffer the rendering
Screens(0)=NewImage(800,600,2)
Screens(1)=NewImage(800,600,2)

FrontBUffer=0


; Enable Threading on BlitFX functions (At this point only BlitIMageClear is supported)
BlitFXThreadingMode 1



do

BackBUffer=1-FrontBUffer


; start the blitting the from buffer to the PB screen
rendertoscreen

; Calling this function, pushes this rendering task onto a second thread
; when threading is ensabled. So
BlitIMageClear Screens(FrontBuffer),0,0,$304050


; While the back ground thread is working drawing the Front Buffer image to
; the PB screen, we start drawing on to our backbuffer screen image.
; Meaing it's doing two things at once, we're drawing circle, while it's BlitIMageClear'ing

rendertoimage Screens(BackBuffer)

Inkmode 1+64
For each Object()
x#=Object.x+Object.SpeedX#

circlec x#,Object.y,Object.Size,true,Object.Colour

if x#>1600
x#=-800
endif
Object.x=x#
next
inkmode 1



rendertoscreen

; Check if threaded blitting is enabled ?
if GetBlitFXThreadingMode()
WaitStates=0

; wait until the thread is complete
while GetBlitFXStatus()=1
WaitStates++
wait 1
endwhile
endif


; Press Space to toggle Threading
if Spacekey()
BlitFXThreadingMode 1-GetBlitFXThreadingMode()
flushkeys
endif

Setcursor 0,0
print "Threading:"+Str$(GetBlitFXThreadingMode())
print "Wait States:"+Str$(WaitStates)
print "Fps:"+str$(Fps())

FRontBUffer=1-FrontBuffer
Sync
loop





ATLUS