DarkBASIC Pro Tutorial: Bitmaps and Images

James Cloud
Almost all games use bitmaps and images either for visual effects, graphical user interfaces(GUI), textures, billboards, and many more features. Therefore it is imperative to learn how to properly load and manipulate images in your DarkBASIC Professional game or application. The two parts covered in this tutorial should put you in the right direction.

Part One - Load Images

DarkBASIC Professional supports the following image formats, .DDS, .JPG, .BMP, .PNG, and .DIB. Loading the image itself is fairly simple using the LOAD BITMAP function as shown below.

Example:

LOAD BITMAP "path\to\my\image\myimage.jpg", 12

You will need to supply a number as the second parameter. You will be able to refer to this reference number in the future when you want to do something with that specific image.

If you need to, later on, you can delete or even copy a bitmap using two built in commands. To delete a previously loaded bitmap use the DELETE BITMAP command. Make sure to give the desired bitmaps number as a parameter.

To copy a bitmap you will need a bitmap to copy and a bitmap to paste it over or into, so make sure to create two bitmaps first. Use the COPY BITMAP command and supply the source bitmaps number as the first parameter and the destination bitmaps number as the second parameter.

Part Two - Manipulating Images

There are four different built in commands to manipulate a bitmap once it is loaded. FLIP BITMAP, MIRROR BITMAP, FADE BITMAP, and BLUR BITMAP.

To flip an image or bitmap vertically use the FLIP BITMAP command. Make sure to give your desired images reference number as a parameter so DarkBASIC Pro knows which bitmap to actually flip.

The MIRROR BITMAP function will mirror the specified bitmap or image horizontally. This function, basically, is the horizontal version of the FLIP BITMAP command shown above. You will need to supply the desired image number as a parameter.

Fading an image in DarkBASIC Pro is accomplished by calling the FADE BITMAP command. The first parameter to the fade command is your desired bitmaps number. The second parameter is a number or integer between 1 and 100. This value will set how much of the image to fade. This function could be combined with timer for a nice fading visual effect.

End

Putting these simple and easy to use functions and commands into practice in your project should put you on the right start when building you game or application using DarkBASIC Professional.

Published by James Cloud

I like to program and do basically anything that has to do with technology and computers.  View profile

To comment, please sign in to your Yahoo! account, or sign up for a new account.