NEWS ARTICLES


    What's News in the PlayBasic world ? - Find out here.




 PlayBasic Tutorial: Intro To Functions - (2018-07-06)

By: Kevin Picone Added: July 7th, 2018

Category: All,Video,Beginner,Types,List,Functions,Variables,Getting Started,Tutorials

PlayBasic Tutorial: Intro To Functions - (2018-07-06)

     Hi welcome to our Intro to Functions tutorial. In this tutorial we start out with some revision of Gosub / Return statements, which are used to create a simple sub routine. Sub routines are changes in program flow, allowing the programmer to execute a chunk of code that's external to the section they may be writing, then upon completion the control returns to the caller. This is the same basic model that functions introduction to our programming, except functions are more formalized. Meaning they have some strict rules about syntax and intro a new concepts such as scope changes, which sub routines don't have.

The types of functions shown in video are very simple, initially we start by taking a sub routine that prints rows of text and convert that to function. Through this process we encounter our first problem which is variable scope and look at ways to solve it, such as making our variable global, or better yet passing a variable into the function as a parameter . Later in the video, we create our own custom distance function, as well building a function that does some simple string manipulation

NOTE: This video was recorded alive with only a few changes for length..




Example Code:
PlayBasic Code:
      print ProcessString( "-------Hello World-------")
         print ProcessString( "    1234     " )
         

         Dist# = CustomDistance( 100,100,700,300)
         
         print dist#


         for lp =0 to 10
               Print_Lines_function( lp )         
         next
         print "--------------------------------------------------"
         
         sync
         waitkey
   
         end      
      



function Print_Lines_function( LoopCounter )
         print "--------------------------------------------------"
         print "Loop Counter="+str$(LoopCounter)
endfunction 

         
         
Function CustomDistance( X1#,Y1# , X2#,Y2#)
   
         DX# = abs(X1#-X2#)
         DY# = abs(Y1#-Y2#)
         
         DistResult# = sqrt( DX# * DX# + Dy# * DY#)   
   
EndFunction DistResult#

         
         
Function ProcessString( MyString$)   

         MyString$ = trim$(MyString$,"-")

         MyString$ = Replace$( MyString$," ","~" )

EndFunction MyString$


COMMANDS USED: PRINT | SYNC | WAITKEY | STR$ | ABS | SQRT | TRIM$ | REPLACE$ |
Links:

     Get Source Code Example For This Tutorial





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

By: Kevin Picone Added: June 27th, 2018

Category: All,Video,Beginner,Types,List,Arrays,Variables,Getting Started,Tutorials

PlayBasic Tutorial: From Arrays To Types (Intro To Types) - (2018-06-12)

    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.



Example #1 - Converting the Parallel Arrays To Typed Array

PlayBasic Code:
   Setfps 20

   Number_Of_Characters = 50

   type tCharacter
         Xpos#
         Ypos#
         Xspeed#
         Yspeed#
         Colour
         Size
   endtype


   dim Characters(Number_Of_Characters) as tCharacter 

   
   for lp = 1 to Number_Of_Characters

         ;  Allocate a newe tCharacter and place it's handle
         ;  into the Character(lp) array / container at this position         
         Characters(lp) = new tCharacter
                  
         Characters(lp).Xpos  = rnd(800)
         Characters(lp).Ypos  = rnd(600)
         Characters(lp).Size  = rndrange(16,50)
         Characters(lp).Xspeed = rndrange(-5, 5)
         Characters(lp).Yspeed = rndrange(-5,5)
         Characters(lp).Colour = rndrgb()
         
   next
   
  
  //-------------------------------------------------------
  //---[ MAIN LOOP ]---------------------------------------
  //-------------------------------------------------------
   
  do 
     
        Cls rgb(0,400,20)
        
        for lp = 1 to Number_Of_Characters
           Radius = Characters(lp).Size
            x#=Characters(lp).Xpos
            y#=Characters(lp).Ypos
   

           circlec X#,Y#,Radius,true,Characters(lp).Colour
                    
           x# = wrapvalue(x# + Characters(lp).Xspeed , -Radius, 800 + Radius)
           y# = wrapvalue(y# + Characters(lp).Yspeed , -Radius, 600 + Radius)
          
           Characters(lp).xpos= x#
           Characters(lp).ypos= y#             
        next
          
        Sync
     loop


COMMANDS USED: SETFPS | DIM | NEW | RND | RNDRANGE | RNDRGB | CLS | RGB | CIRCLEC | WRAPVALUE | SYNC |



Example #2 - Converting Typed Array To Typed List

PlayBasic Code:
   Setfps 20

   Number_Of_Characters = 50

   type tCharacter
         Xpos#
         Ypos#
         Xspeed#
         Yspeed#
         Colour
         Size
   endtype


   dim Characters as tCharacter  list 

   
   for lp = 1 to Number_Of_Characters
      
         Characters = new tCharacter
                  
         Characters.Xpos  = rnd(800)
         Characters.Ypos  = rnd(600)
         Characters.Size  = rndrange(16,50)
         Characters.Xspeed = rndrange(-5, 5)
         Characters.Yspeed = rndrange(-5,5)
         Characters.Colour = rndrgb()
         
   next
   
  
  //-------------------------------------------------------
  //---[ MAIN LOOP ]---------------------------------------
  //-------------------------------------------------------
   
  do 
     
        Cls rgb(0,400,20)
        
        for each Characters()
           
           Radius = Characters.Size
            x#=Characters.Xpos
            y#=Characters.Ypos
   

           circlec X#,Y#,Radius,true,Characters.Colour
                    
           x# = wrapvalue(x# + Characters.Xspeed , -Radius, 800 + Radius)
           y# = wrapvalue(y# + Characters.Yspeed , -Radius, 600 + Radius)
          
           Characters.xpos= x#
           Characters.ypos= y#             
        next
          
        Sync
     loop


 


COMMANDS USED: SETFPS | DIM | LIST | NEW | RND | RNDRANGE | RNDRGB | CLS | RGB | CIRCLEC | WRAPVALUE | SYNC |


Links:

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





 PlayBasic LIVE : Intro Converting Amos To PlayBasic

By: Kevin Picone Added: December 3rd, 2017

Category: All,Video,Beginner,Amos

PlayBasic LIVE : Intro Converting Amos To PlayBasic (2017-12-03)

     Welcome... Today we'll take a look back at a free tool created to help Amos & AmosPro programmers begin the conversion process to PlayBasic. The tool is simply called AmosToPlayBasic and can be found on our forums and includes conversion support for the core Amos to PlayBasic syntax through to exporting the various hidden data banks within Amos such as Sprites/Pictures/Samples and Music modules.

         Note: Later in the video we go through how to improve the conversion by adding your own Amos command tokens to the instruction sets.

Video:







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

By: Kevin Picone Added: September 21st, 2017

Category: All,Variables,Array,Tutorials,Beginner

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 Tutorial: Intro to GOTO & GOSUB statements

By: Kevin Picone Added: April 16th, 2017

Category: All,Video,Tutorials,Beginner

PlayBasic Tutorial: Intro to GOTO & GOSUB statements

     Welcome, in this tutorial we take a look at some none conditional control change statements, or otherwise known as Goto and Gosub statements in PlayBasic.



    Commands used in this tutorial. Goto / Gosub / Return / For / Next / If / EndIf / Mousex() / MouseY() / MouseButton() / Print / Circle / Sync and possibly a few others.


Watch On YouTube




 Pumpkin Patch

By: Kevin Picone Added: November 4th, 2010

Category: All,Beginner,Games,Video

     Pumpkin Patch is a mini game written over a day for the PlayBasic Halloween Mini Game Challenge. The challenge was to make a pumpkin themed game over the Halloween weekend (in 48 to 72 hours). Pushed for time and artwork, I recycled some graphics and threw together Pumpkin Patch.

     The game play is clearly Boulder Dash inspired, but with a few small differences. Namely it's far less polished, and the game only features two interactive character types. Those being Rocks and Pumpkins. The players objective is to collect enough pumpkins to open the exit. However the level doesn't have enough Pumpkins on it's own, so the player must create them. New pumpkins can be created by dropping rocks on them. This makes them explode . Much like the dropping a rock on diamond in Boulder Dash. All the player has to do is explode enough pumpkins and get to the exit safely. Sounds easy..



Download

See Challenge #21 - Halloween Pumpkin Mini Game thread for downloads






 User Games In Development

By: Kevin Picone Added: October 18th, 2010

Category: All,Beginner,Games,Video



Fisut


    Laskiapina has completed his third game release. This one is inspired by a game called Fishy. Except this version supports single and two player modes.

    Your objective is to avoid bigger fish and eat the smaller. When you grow in size - you get to eat more bigger fish!


Read More



Tile Creation 3


     XpMe_v1.2 is back working on a new version of his Tile Creation application. The program has been rewritten from the ground up with many tweaks and features.


Read More



Holly


     Stevmjon's platformer is really starting to take shape after his rewrite. The most recent update see's the return of the various bad guys, menus and a bigger first test world.


Read More



Zombie Shoot


     This is simple tech demo/game made in a few hours. The player simply runs forward shooting as many shiny zombies as they can. We'll release the source onto forums soon.


Read More






 Aliens From Space

By: Kevin Picone Added: July 27th, 2010

Category: All,Beginner,Games,Video

     This is a Space Invaders tech demo (shock, horror), with a couple of key conceptual differences to the original arcade game ! - Those being, in this version the game throws multiple attack waves in unison, but the more interesting change is that all of the objects are now destructible in some way. So when an impact occurs between a ship and a bullet for example, the impact chips away these pixels. When the pixel mass gets bellow the threshold, the object dies.

     I've been sitting this idea since I was kid playing the Space Invaders Arcade at lunch time. Game play wise, It sort of works, but it needs tweaking to get the balance right. Style wise, I've intentionally gone for that real 1970's look. Didn't really have much choice though, being a programmer and not an graphic artist

     The demo (like most of the video in this channel) was written as example to help teach game programming in PlayBasic.

     Anyway, I hope this was bit of a trip down memory lane in a parallel universe kind of way.







Viewing Page [1] of [1]



 

 
     
 
       

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