Today I'm featuring an article from :

Small Basic: Sprite Arrays

 

This article describes using arrays of sprites in a Small Basic program.  A sprite is an image that is moved in a graphical game, they may be aliens for example.

Loading sprite images

The image for a sprite exists in a file (e.g. jpg or png).  This file may be local as a file on your PC or be stored online as a URL.  If it is local then you will need to share the images with your game in zip download, therefore it may be better to host the file on the web if you can.

It is often best to create the sprite with a transparent boundary and with a carefully chosen width and height in pixels.

Once the sprite is created, it is most efficient to load it into your program once only using the ImageList method, and this is usually done before the game starts as it may take some time to download.  The loaded image may then be used many times for multiple copies of the sprite.  The following code is an example loading a sprite image from an online URL and testing it appears correctly.

sprite = ImageList.LoadImage("http://litdev.hostoi.com/game_images/football.png")
Shapes.AddImage(sprite)

 Football Sprite

  

Read the full article (Small Basic: Sprite Arrays) as it takes you through the steps to make the complete sample, and you'll get a nice array like this:

 

Thanks to LitDev again for this great article in June!

Small Basic: Sprite Arrays

- Ninja Ed