Your Federal Quarterly Tax Payments are due April 15th

# Writing a game is like baking a cake! by luckboy

VIEWS: 21 PAGES: 2

Writing a game is like baking a cake!

• pg 1
```									Writing a game is like baking a cake!
Numeric Variables (Numbers) You will end up with 8 slices of cake player_lives = 3 String Variables (Words) This cake is chocolate flavoured player_name = “Mario” Conditionals (Test before you do something) If you want extra chocolate then add chocolate chips If player_health < 1 Then game_over() Iteratives (Repeat something a few times) Keep whipping the cream until it is really thick Do run_very_fast() Loop Until powerup_time = 0 Outputs (Getting across some kind of message) Pipe the words ‘Happy Birthday’ using the icing Print “Your score is “ + player_score

Dim forename As String Dim surname As String Dim age As Integer

First you need to create some variables. You do this using the ‘Dim’ statement. Next, a welcome message. You use the ‘Print’ statement. Now we ask a couple of questions. The ‘Input’ statement can set variables. Just to prove it worked OK.

Print "Welcome to my first FreeBasic program!" Print "--------------------------------------" Print
Input "What is your first name? ", forename Input "What is your second name? ", surname Print

Print "Hello " + forename + " " + surname + ", I hope you are well!" Print Input "How old are you? ", age Print

Str() is very important!

Another quick question.

If age < 21 Then Print "That's a great age, " + Str(age) + ", well done." Else Print "Holy Moses, " + Str(age) + "??? That's really old!" End If Print Print "Press any key to exit..." Sleep End

Now a conditional block using the ‘If’ and ‘Else’ statements.

The ‘Sleep’ statement waits patiently for the user to press any key. The ‘End’ statement finishes the program 

```
To top