NEWS ARTICLES


PlayBASIC Tutorial: From Variables To Arrays (Intro To Arrays)

PlayBASIC Tutorial: From Variables To Arrays (Intro To Arrays) 2017-09-17

    Welcome programmers, in this tutorial we're going to introduce the concept of arrays starting out from variables. So first we build a simple game loop that controls two characters using only variables. The characters are represented on screen as filled circles. After we get up to speed with the variable version we then move onto how we can use parallel integer arrays to store the various properties of the characters. The array version can control as many or as few characters as you like, which is the benefit of Arrays over Variables

Want to learn 2D game programming ?


Video:



Example #1 - Variables Example

PlayBASIC Code:
   Xpos1  = 400
   Ypos1  = 300
      
   Xpos2  = 100
   Ypos2  = 100

      
   setfps 20   
      
  do    

    cls rgb(10,20,40)

; Draw circle 1        
     Circle Xpos1,Ypos1, 32, true
   
     Xpos1 = Xpos1 + 2
     Ypos1 = Ypos1 - 4
  
   Xpos1 = WrapValue(Xpos1,0,800)  
    Ypos1 = WrapValue(Ypos1,0,600)  
   
   

; Draw circle 2      
     Circle Xpos2,Ypos2, 64, true
   
     Xpos2 = Xpos2 + 2
     Ypos2 = Ypos2 + 2
    Xpos2 = WrapValue(Xpos2,0,800)  
    Ypos2 = WrapValue(Ypos2,0,600)  
  
     sync
  loop
COMMANDS USED: SETFPS | CLS | RGB | CIRCLE | WRAPVALUE | SYNC |






Example #2 - Arrays Example - Using Parallel Arrays To Store Character Properties


PlayBASIC Code:
 Setfps 20

   Number_Of_Characters = 50 

   dim Xpos( Number_Of_Characters  )
   dim Ypos( Number_Of_Characters  )
   dim size( Number_Of_Characters  )
   dim Xspeed( Number_Of_Characters )
   dim Yspeed( Number_Of_Characters )
   dim Colour( Number_Of_Characters )
   
   
   for lp = 1 to Number_Of_Characters
      Xpos(lp)  = rnd(800)
   Ypos(lp)  = rnd(600)
   Size(lp)  = rndrange(16,50)
   Xspeed(lp) = rndrange(-5, 5)
    Yspeed(lp) = rndrange(-5,5)
    Colour(lp) = rndrgb()
   next
   
   
  do 
  
     Cls rgb(0,400,20)
     
     for lp=1 to Number_Of_Characters
        
        Radius = Size(lp)

        circlec xpos(lp),ypos(lp),Radius,true,Colour(lp)
        
      //  xpos(lp) = Xpos(lp) + Xspeed(lp)
      //  ypos(lp) = ypos(lp) + Yspeed(lp)
        
        xpos(lp) = wrapvalue(xpos(lp) + Xspeed(lp) , -Radius, 800 + Radius)
        ypos(lp) = wrapvalue(ypos(lp) + Yspeed(lp) , -Radius, 600 + Radius)
                
  next
    
     Sync
  loop
COMMANDS USED: SETFPS | DIM | RND | RNDRANGE | RNDRGB | CLS | RGB | CIRCLEC | WRAPVALUE | SYNC |

PlayBASIC (retro) Video Gallery

     PlayBASIC (retro) Video Gallery

     Hi, just wanted to let you know that we've been creating lots of videos of some the older PlayBASIC game / demo projects from over the years. Check em out on the forums.

     Watch PlayBASIC (retro) Video Gallery

PlayBASIC V1.65B _Retail Upgrade_ Now Available (23rd, June, 2017)





PlayBASIC V1.65B _Retail Upgrade_ Now Available (23rd, June, 2017)



     The PlayBASIC V1.65B package includes updates of PlayBASIC Compiler, Release / Debug Runtimes, SLIBS, DOCS & IDE V1.17b.

     The V1.65B includes the second release of the next generation of the PlayBASIC virtual machine. In this build 99.99% of the commands now executed upon the new VM side, giving much higher execution performance. There are still some 'commands' tied to the legacy VM such as the debugger commands and few text commands such as Print and TEXT and the Sync command which is actually a VM TRIGGER, but they'll be moved in the next build..

     Performance wise this is easily the fastest edition of PlayBASIC to date, even though the runtime is missing some of the byte code optimization modes found in V1.64 builds, which will tackled in the next revision of the 1.65, but for now get stuck into it.

     Reminder: The new runtime doesn't support reading from types that don't exist, which can cause old programs to fail at runtme. For a full V1.65B development story read the PlayBASIC V1.65 blogs and for V1.65 related errors, post them in the V1.65 bug reporting thread on the forums.


Downloads


     Download PlayBasic V1.65B Retail Upgrades From Forum

PlayBASIC LIVE - Intro to G2d (openGL for PlayBASIC)

PlayBASIC LIVE: Intro to G2D (openGL library for PlayBASIC) 2017-05-07

PlayBASIC Live: 2D Optimization Tips (2 videos)

PlayBASIC Live: 2D Optimization Tips - Dirty Rects (2017-06-19)

     Welcome... Today we continue with some rendering optimization ideas, focusing on a concept known as dirty rectangles in programming circles. While there's a number of different methods, in this video we look through code that uses a map as background replacement, allowing the redraw code to selectively refresh parts of the backdrop each frame instead of the whole thing. The code computes the redraw percentage each frame, which is often lower than 50%, in the sprite scene saving not only processing time by lowering a games system requirements.



PlayBASIC LIVE: Basic Optimization with overview of forums (2017-04-29)

     Here's a live video basically talking about the forums and code optimizations mainly.. I'm really just testing video recording on a different machine with a head set mic etc.. sadly the results are pretty sucky, but content is ok so here it is