Lesson 1
Textbook
Programmer's Vocabulary | |
---|---|
Execute. | To run code. |
Function. | A command that tells FreeBASIC to do something. |
Data. | Information. Things like a character's name or hit points. |
String. | Data that is text. |
Integer. | Data that is a number. |
Variable. | Used to hold data. |
Literal. | Data put directly into your game code. |
Console Window. | A text-only window. |
FB Vocabulary | |
End | Ends the game instantly. |
Sleep | Pauses the game until the player presses a key. |
Displays data to the screen. | |
; | Pastes two bits of data together in Print |
Input | Gets a line of data from the player. |
; | Separates Input from a variable. |
$ | Shows that a variable contains string data. |
Code Examples
Example A.
End
Example B.
Sleep
End
Example C.
Print "Hello World"
Sleep
End
Example D.
Print 42
Print "Fourty Two"
Sleep
End
Explanation
1. End is a function ends the game instantly whenever it is executed. FreeBASIC will naturally end the game when it runs out of code to execute, however, there will be times when you will want to be able to end your game in multiple places.
2. Sleep is a function that pauses the game and waits for the user to press a key. If it is not used, FreeBASIC will execute the code in the above examples so fast that the console window will open and then instantly close. Therefore, Sleep is used to keep the window open long enough so that the player can read the displayed text (if any).
3. Print is a function that displays whatever follows it.
Exercise
1. Make FreeBASIC say :
I am your obedient and loyal robot slave.
page revision: 11, last edited: 02 Jun 2007 06:13