PlayBasic TUTORIALS


     New to programming and need some help getting started ? - Well, then our tutorial section will help kick start your programming adventure. If you're looking for more Source Code / Tutorials & Media ? - Then remember to visit the PlayBasic Resource board on our forums.

Found #4 items in Arrays category by Kevin Picone


 PlayBasic Tutorial: From Arrays To Types (Intro To Types)

By: Kevin Picone Added: June 14th, 2018

Category: All,Video,Beginner,Types,List,Arrays,Variables,Getting Started,Learn To Code

    This tutorial picks up where the previous variables to arrays tutorial left off, in that it takes the array code, demos that code then we set about converting the parallel array approach shown in the previous tutorial and we build a structure (TYPE) to hold each characters properties. Once the type has been defined that includes all the required properties, we then define a typed array that will house the collection of characters. Later in the video take a look at using typed lists also. So if your struggling with types this could be a good place to start.



Links:

    * PlayBasic Tutorial: From Arrays To Types (Intro To Types) Source Code





 PlayBasic Tutorial: From Variables To Arrays

By: Kevin Picone Added: September 20th, 2017

Category: All,Video,Beginner,Arrays,Variables,Getting Started,Learn To Code

    Welcome PlayBasic 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



Example #1 Variables

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 Array Version

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 |






 Object management (Character Life Cycles)

By: Kevin Picone Added: November 27th, 2009

Category: All,Arrays

     This tutorial introduces a concept of managing the life cycles of a many characters within our game. If we think about it, the characters in our games will generally have three main life states. They're Born, they live out their purpose and ultimately they die.

     So in this tutorial we're going to use a Typed Array to hold handle various game characters. The initially version starts out simple, and shows how we can presents characters in typed arrays, with each revision we progress the code until we've create create a frame work that can allow us to manage the life cycles of as many characters as need be.




 Game Programming For Beginners

By: TDK_Man , Kevin Picone Added: April 20th, 2008

Category: All, Beginner,Getting Started,Variables,Arrays,Functions, Learn To Code

Learn basic game programming in this 10 part tutorial series for beginners. This series covers everything from Variables, Arrays, Program Structure, Loops, Functions through to various articles on game timing and logic.

Highly Recommended





Viewing Page [1] of [1]





Looking for More Tutorials?:



 

 
     
 
       

(c) Copyright 2002 / 2024 Kevin Picone , UnderwareDesign.com  - Privacy Policy   Site: V0.99a [Alpha]