Blitz2D Newbies: Getting Started with BlitzBasic
by Krylar

Introduction:

BlitzBasic is a tool that was originally created for the Amiga a long long time ago in a galaxy...well, it was this galaxy, but anyway. The idea was to create a really powerful game engine that had a simple programming interface. This concept is now being moved from the Amiga to the PC, and it's sweet!

Currently, the engine works with DirectX 7.0 or higher and sports the following features:

  • Full featured BASIC programming language
  • Built in IDE and compiler, with a pretty nice debugger to boot
  • REALLY high-speed 2D Graphics with Buffering
  • Tons of image functions (including PIXEL-Perfect collision detection!)
  • Font functions for putting up your text as you want
  • Input device functions (keyboard, mouse, and joystick)
  • Sound and Music functions
  • File I/O functions
  • String manipulation functions
  • Time functions (no more worrying about "how do I work the timers in Windows?")
  • All the necessary math functions for 2D (to be expanded with 3D, no doubt)
  • And, get this, Multiplayer functions!

I've been messing with this language for roughly 2 days now and I gotta say that this is one of the coolest toys I've played with. It's simple to use, but it still requires that YOU program your game. Basically, you still have to handle the AI, physics, game-play mechanics, balancing issues, level controls, hit points, modifiers, etc...the only thing you no longer have to worry about is working with DirectX.

In order to follow along, you'll need to download the latest version of BlitzBasic and you'll need to have DirectX 7.0 or higher. You can get BlitzBasic by going to the BlitzBasic Website.

Quick note, I'll likely use "BB" in place of writing "BlitzBasic" everywhere...so now you'll know what that means ;)

Simple, eh? Enough talk, show me!

Okay, I'm going to show you how simple this really is. This little piece of source will setup the graphics mode, display a .bmp image (I use a little ship that comes with the BlitzBasic download) and allow you to move that image all over the screen with your mouse.


Now I'm sure there are a few things that may look a bit odd, so let me explain.

First off, you use a ";" as a comment indicator. It will consider anything after that character a comment for the rest of that line.

Secondly, you'll notice that in the Type section there is a Field command. This command basically instructs the Type that this is a piece of it's element. You can put different vars and such in here.

Third, what's with that # next to x and y? Well, that little jobbie basically tells BB to use floating point. Thus, we can put x#=1.99834, which we couldn't do without the #. You won't get an error if you try, but everything after the decimal is dropped.

Finally, where C uses -> for struct references, BB uses a \. So when you see Ship\x=1, think Ship->x=1. For those of you who don't know C, think of the \ as pointing at the x. So, Ship\x=1 is basically saying, "make the value x, that sits inside the Type Ship, equal 1". I guess another way to look at is as Type Ship is a directory and x is a sub-directory within it. In order access that directory in DOS, you would have to type in the old CD ship\x...that might help you DOS-types (and Unix types, just flip the / in your world to \ ;)).

Conclusion:

In a nutshell, I think that this is one of the coolest toys for the hobbyist developer I've seen. But, if you're a good programmer, you should really be able to code darn near anything using this...especially when the 3D stuff is done.

I'll keep you posted of little accomplishments I make with this system and how I made them. In the meantime, you may consider playing around with BB a bit.

Until next time...cya!

-Krylar


For a printable copy of this article, please click HERE.


This site is Copyright© 2000-2004, BlitzCoder. All rights reserved.