Wave's~ BlitzMax Tutorial for NG | ~ November, 2015 ~ Version 11
Beginners guide to BlitzMax |
Then
When to use Then? You can put it after your If expression. The use of "Then", is not required. Like this, ( If A = 1 Then B = 2 ) is equal to ( If A = 1 B = 2 ). If you take a BlitzMax file and delete all "Then", it will run the same. Use "Then" If you think it helps you read the code. When I use then, then it is to make an if-statement on one line more readable, like in the example above and in the example below.
Not True or <> False?
True and False can be used in If-statements, usually to make the code a little easier to read, you can live without them. Note: BlitzMax doesn't have Boolean variables which only accepts True or False. False means something is equal to 0, True if it's not equal to 0. Many functions return 1 if success and 0 if fail.
This can be used in an if-statement like this:
If KeyDown(Space) = True Then A = 10 Else A = 0 End If
This is also the same as writing:
If KeyDown(Key_Space) Then A = 10 Else A = 0 End If
Because " = True" is assumed. You can also use "Not" after an IF to see if something is Not True (That is false), Like this:
If KeyDown(Key_Space) = False Then A = 10 Else A = 0 End If
Can be written:
If Not KeyDown(Key_Space) Then A = 10 Else A = 0 End If
The two sections above do the exact same thing. You can also check objects with true and false, if an object is "null" (does not exist) it's false else it's true. Example:
If Not Car Then Print "Car not Found" End If
<> means "greater or higher than" and is therefore the same as not.
If A <> 10
above is the same as: |
If Not A = 10
Start with Graphics
DrawRect, DrawOval, DrawLine, DrawText and Plot are some of the built in graphics commands. They simply draw a filled Rect/Oval, line, text and pixel respectively. If you want to know how to use these commands check out the Module Reference. To be able to use your graphics card you will first need to set a graphics mode - specifying the resolution you want to use. Just enter Graphics 800,600 for a full screen resolution of 800x600. Graphics 800,600,0 gives you windowed mode, very good for debugging. There is a sample on page 6!
Loops
A loop is a way to tell Blitz to do one thing several times, or in games to update the game until the game is ended. Loops are what makes games run in real-time. This loop below starts at Repeat and when the program reaches until x >= 800 it will jump back to "Repeat" unless the condition is met. So it will loop depending on X. Try to run the example on the page 6:
To Index | Next Page | page 5