This page was last modified on 8 June 2016, at 21:57.
|Developer||Blitz Research Ltd.|
|Implementation language||Compiled to C++, but the languages are dialects of BASIC|
|OS||IDE for Microsoft Windows, Mac OS X, Linux|
Blitz BASIC refers to the programming language dialect that was interpreted by the first [Blitz]] compilers, devised by New Zealand-based developer Mark Sibly. Being derived from BASIC, Blitz syntax was designed to be easy to pick up for beginners first learning to program. The languages are game-programming oriented but are often found general-purpose enough to be used for most types of application. The Blitz language evolved as new products were released, with recent incarnations offering support for more advanced programming techniques such as object-orientation and multi-threading. This led to the languages losing their BASIC moniker in later years.
- 1 History
- 2 Versions
- 3 BlitzMax
- 4 Blitz3D
- 5 BlitzPlus
- 6 References
- 7 External links
The first iteration of the Blitz language was created for the Amiga platform and published by the Australian firm Memory and Storage Technology. Returning to New Zealand, Blitz2 was published several years later by Acid Software (a local Amiga game publisher). Since then, Blitz compilers have been released on several platforms.
BlitzMax is a BASIC dialect, and the latest Blitz language by Blitz Research Limited. It is the first to run on multiple operating systems; it runs on Mac OS, Linux and Microsoft Windows. The language is converted to assembler, then assembled - allowing it to be somewhat platform agnostic. From a gaming standpoint this is possible because, unlike earlier versions, BlitzMax can use OpenGL for rendering.
- BlitzMax compiler
- Core BlitzMax modules
- Max2D graphics module
- sample code and documentation.
Data Types BlitzMax
All constants, variables, functions and expressions have an associated type. BlitzMax supports the following types:
|Description||Syntax||Minimum value||Maximum value|
|8 bit unsigned integer||Byte||0||255|
|16 bit unsigned integer||Short||0||65535|
|32 bit signed integer||Int||−2^31||+2^31-1|
|64 bit signed integer||Long||−2^63||+2^63-1|
|32 bit floating point||Float||(+/-)10^-38||(+/-)10^38|
|64 bit floating point||Double||(+/-)10^-308||(+/-)10^308|
|16 bit unicode string||String||-||-|
|Pointer||Pointer ValueType Ptr||-||-|
|Sub expression||( Expression )|
|New object||New Typename|
|Minimum||Min ( Expression1 , Expression2 )|
|Maximum||Max ( Expression1 , Expression2 )|
|Member||Expression . Identifier|
|Index||Expression [ IndexExpressions ]|
|Call||Expression ( Parameters )|
|Bitwise complement||~ Expression|
|Boolean not||Not Expression|
|Absolute value||Abs Expression|
|Value byte size||SizeOf Expression|
|Variable address||Varptr Variable|
|Convert type expression||Type Expression|
|Power||Expression ^ Expression|
|Multiply||Expression * Expression|
|Divide||Expression / Expression|
|Remainder||Expression Mod Expression|
|Bitwise shift left||Expression Shl Expression|
|Bitwise shift right||Expression Shr Expression|
|Arithmetic shift right||Expression Sar Expression|
|Add||Expression + Expression|
|Subtract||Expression - Expression|
|Bitwise and||Expression & Expression|
|Bitwise exclusive or||Expression ~ Expression|
|Equal||Expression = Expression|
|Not equal||Expression <> Expression|
|Less than||Expression < Expression|
|Greater than||Expression > Expression|
|Less than or equal||Expression <= Expression|
|Greater than or equal||Expression >= Expression|
|Conditional and||Expression And Expression|
|Conditional or||Expression Or Expression|
Variables are used to store values that change during the execution of your program.
Variables should be declared in your program before use. Declaring a variable means defining a name and type for the variable and, optionally, an initial value.
The general syntax for declaring a variable is:
- Declaration Identifier : Type = Expression
Multiple variables may be declared in one statement using the comma separator.
If the type of a variable is omitted, the variable defaults to being of type Int. If the initial value expression is omitted, the variable is assigned an initial value of Null.
There are 3 kinds of variable, each of which differs by how and where the variable is stored:
Local variables are used to store temporary values that will eventually be discarded. Local variables are associated with the block of code they are declared in, and are only visible to code within that block. A block of code is represented by one of the following:
- The body of a function or loop
- The body of an if/then/else statement
- The body of a case or default statement
To declare a local variable, use a Local declaration:
Local int_var Local string_var:String="Str",float_var:Float=10.5
Comment: You should prefer the use of local variables, as they are the fastest to use.
Global variables are variables that exist for the entire lifetime of a program.
To declare a global variable, use a Global declaration:
Global int_var Global string_var:String="Str",float_var:Float=10.5
Field variables are declared within user-defined types using a Field declaration:
Field int_var Field string_var:String="Str",float_var:Float=10.5
Once declared, a variable's value may be changed using an assignment statement:
- Variable = Expression
You can also perform 'modifying' assignments, which are shorthand for Variable = Variable Operator Expression. The syntax for modifying assignments is:
|:~||Bitwise exclusive or|
|:Shl||Bitwise shift left|
|:Shr||Bitwise shift right|
|:Sar||Arithmetic shift right|
For example, the code my_var:+1 can be used in place of my_var=my_var+1.
A function is a self contained block of code that can be called from multiple points in your program.
Functions are declared using the syntax:
- Function Identifier : ReturnType ( Parameters )
- Function statements...
- End Function
If ReturnType is omitted, the function defaults to returning an Int.
Parameters is a comma separated list of parameters for the function. The syntax of each parameter is similar to a variable declaration: Identifier : Type. Function parameters may be used inside a function in the same way as local variables.
The Return statement is used to return a value from a function.
Here is an example of a simple function that adds 2 integers and returns their sum:
Function AddInts:Int( x:Int,y:Int ) Return x+y End Function
This function can then be called by other code:
Print AddInts( 10,20 ) 'prints 30!
Function parameters can be assigned constant 'default values' using syntax similar to initializing a variable: Identifier : Type = ConstantExpression.
Default parameters can then be optionally omitted when the function is called:
Function IncInt:Int( n:Int,p:Int=1 ) Return n+p End Function Print IncInt( 1 ) 'Prints 2 Print IncInt( 1,3 ) 'Prints 4
Blitz3D was released for Microsoft Windows in September 2001, competing with other similar PC game-development languages of the time (such as Dark Basic). Blitz3D extended BlitzBasic's command-set with the inclusion of an API for a DirectX 7-based 3D engine.
Although originally Blitz3D's distribution rights were owned by Idigicon, Blitz Research Ltd. later signed a deal with the firm so as to allow Blitz Research Ltd. to distribute Blitz3D themselves. In return, Idigicon were granted full rights to distribute BlitzBasic and to clear any outstanding stock copies of Blitz3D.
Blitz3D was released as Open Source on 4 August 2014.
Blitz3D provides a simple yet powerful environment for game creation - simple, because its based around the popular and easy to use BASIC programming language; and powerful, thanks to a highly optimized underlying 2D/3D engine.
Blitz3D includes many commands to help you out with game creation - but not too many! Rather than confuse you with tons of commands, Blitz3D's command set has been carefully designed to provide maximum flexibility for minimum effort.
And if you get stuck, there is always the huge Blitz3D user community to call upon for help. Buying Blitz3D provides you with access to the official Blitz Research forums, home to thousands of dedicated and talented Blitz3D enthusiasts.
Can you write commercial quality games in Blitz3D? Why not - others are! Great titles such as Best Friends, Wonderland and Juno Nemesis were written in Blitz. In fact, many shareware authors are moving to Blitz from languages such as C++ due to the faster development time.
Super flexible entity system
Blitz3D is designed around the idea of entities. Typically, a 3D game will consist of many types of 3D elements such as cameras, lights, meshes and so on. In Blitz3D, these are all considered to be entities. This means that the same commands can be used to manipulate and deal with a wide range of 3D objects - for example, the TurnEntity command can be used to turn a camera, a light, a mesh, or even a massive terrain!
Meshes are the workhorse of any 3D engine. Blitz allows you to either create your own meshes from scratch, or load existing meshes in either X, 3DS or B3D format. The B3D format is unique to Blitz3D, and has been designed to provide for all the features of the Blitz3D engine. B3D exporters are available for a wide range of modelling software including 3D Studio, Lightwave and Truespace. Blitz3D meshes provide features such as vertex colors and multiple texture coordinate sets.
Blitz3D terrains can be used to generate apparently HUGE scenes! This is achieved through a trick known as LOD (level-of-detail) reduction. This completely automatic process works by picking a set of polygons which approximates the shape of a very high resolution heightmap. Blitz3D terrains can also be modified in realtime - great for blowing holes in things!
Sprites are simply textured 2D rectangles - easy to setup and great for things like particle effects, heads-up-displays and so on. Sprites can be setup to automatically orient themselves to face the camera, giving the illusion of a spherical object, but without the overhead of drawing a ton of polygons.
Blitz3D cameras offer the programmer direct control over viewport, zoom, clipping range, fog effects and even offer an isometric mode. Multiple cameras are also no problem - simply use CreateCamera as many times as you want!
Blitz3D offers directional lights, point lights and spot lights. You can control the color, range and 'cone' of lights with ease.
Super flexible brush system
Blitz3D makes extensive use of the idea of brushes to color, texture and otherwise manipulate the appearance of entities. Brushes offer a wide range of effects such as tinting, multitexturing and specular highlights.
Multitexturing allows you to apply up to 8 layers of texture to an entity. This can be used to achieve such effects as lightmapping, detail texturing, specular highlights and a host more. The multitexturing system in Blitz3D also allows you to precisely control how textures are combined together.
Environment mapping creates the illusion of reflections with in a scene. Blitz3D provides 2 forms of environment mapping - spherical or cubic. Cubic environment maps can even be updated in realtime, providing for awesome, dynamic reflection effects.
Examples of programs
Graphics 800,600 ; - Graphic mode 800x600 While Not KeyDown(1) ; - Start the main loop Cls() ; - Clean the screen Text 10, 20, "Hello, World!" ; - Write the text "Hello world" in point 10,20 Flip() ; - Output on display Wend ; Stop the cycle by pressing the button Esc End ; The end programm
Нello world with using variables
Graphics 800,600 Global a$="Hello" Global b$="World" While Not KeyDown(1) Cls() Text 0,0,a$+b$ Flip() Wend End
Working woth images
Graphics 800,600 Global Image = LoadImage("picture.bmp") While Not KeyDown(1) Cls() DrawImage Image,100,100 Flip() Wend End
Working with 3D-Grafics
Graphics3D 800,600 ;Setting graphics mode Global model = LoadMesh("helloworld.3ds") ;Loading the three-dimensional model lettering "Hello, World" PositionEntity model,0,0,0 ;Setting the mode in point 0,0,0 Global camera = CreateCamera() ;Creating the cemera PositionEntity camera,0,0,-10 ;Setting the cemera behind the object While Not KeyDown(1) ;Beginning of the loop Cls() ; Cleaning of display RenderWorld() ; Doing rander of image Flip() ; Output on display Wend ;The end of loop End ;The end of programm
BlitzPlus provides developers with a complete 2D programming solution for the PC. Utilising a BASIC/C hybrid language for use with its compiler, BlitzPlus is capable of creating any type of 2D program, with minimal development-time and with minimal hassle. Just run the included IDE (or use one of your own), type your code and your Windows executable file will be created, ready to be run on any computer running Windows 95/NT 4 or later.
BlitzPlus' language is a BASIC/C hybrid. As well featuring the classic BASIC constructs such as goto and gosub, it also features C influences such as functions and types. On top of this, BlitzPlus' command set features over 500 commands. This command set is highly streamlined meaning complete programs require very few lines of code indeed.
BlitzPlus' 2D engine is based on 'pure' 2D blitting operations, as opposed to 'fake' 3D ones. This has the combined benefit of allowing for pixel-perfect graphics, as well as allowing for compatibility with virtually all graphics cards, 2D or 3D. The 2D engine itself is highly capable, with the capability of performing thousands of blitting operations per second.
BlitzPlus' GUI support is implemented via an event-driven 'Gadget' system. Simply by adding GUI gadgets to your program, and setting up a small loop which deals with program events, you instantly have yourself a fully-blown application to compare with anything created by other languages.
BlitzPlus comes with its very own Integrated Development Editor (IDE). The IDE allows you to edit, test, debug and compile your program all from the one environment. If the included IDE is not to your liking, then you are free to use the code editor of your choice, as the Blitz compiler features command line capabilities.
Creating executable files (i.e. program files) in BlitzPlus is simply a matter of clicking a button. Once you have done so, the executable will then be able to run on any Windows95/NT4 or later compatible machine independently of BlitzPlus. You are free to do with BlitzPlus executable files what you want, with absolutely no restrictions or obligations with regards to distributing them or selling them.
Included with Blitz is a full and thorough documentation. All 500+ commands have their own help pages, explaining what that command does, and most commands have their own examples too. There are also a language reference and tutorials included with Blitz to help you get started.
The Blitz community is a large and active one. Its main areas of activity are the official Blitz forums on this site and the unofficial, but still busy BlitzCoder forums. Should you ever be in need of assistance with your Blitz programming, or just want someone to take a look at your game - these are the places to go.
- Blitz Product History
- BlitzMax Types
- BlitzMax Operators
- BlitzMax Variables
- About Blitz3D
- About Blitzplus