-->

Coding with FUZE BASIC – Part 2

Moving on from the previous FUZE BASIC tutorial, let’s expand everything you’ve done so far and see if we can apply it to something other than counting numbers or asking for someone’s name. In the grand tradition of BASIC programming, let’s create a text adventure.

PALE BULBOUS EYES STARE AT YOU…


A text adventure game is an ideal genre to explore your BASIC skills in. There are variables, events, user input, counting and if you want, even a few graphics here and there to inject and use.

You May Also Like:

Step 1

Enter the Program Editor and begin with a simple clear screen, as it’s always a good way to start. What we need to do is set some basic parameters first, so start with the number of lives a player has, for example 3.

ClsLet lives=3

Coding with FUZE BASIC – Part 2
Coding with FUZE BASIC – Part 2


Step 2

Now you can introduce the game and let the player know how many lives they currently have. You can do this by adding the following to the code:

  1. Printat (41,0); “You have “; lives; “ lives left.”
  2. Printat (0,0); “Welcome to Cosmic Adventure!”

The printat command will specify a location on the screen to display the text using x,y.



Step 3

Let’s add a way whereby the user is required to press a key to continue, this way you can leave instructions on the screen for an indefinite period:

  1. Printat (15,15); “Press the Spacebar to continue…”
  2. While inkey <> 32 cycle
  3. Repeat

This prints the message whilst waiting for the specific key to be pressed on the keyboard: the Spacebar.



Step 4

Now we can start the ‘story’ part of the adventure:

  1. Cls
  2. Print “You awake to find yourself in an airlock
  3. onboard a space station.”
  4. Input “There are two buttons in front of you:
  5. Green and Red. Which do you press?”, button$
  6. If button$=”Red” then
  7. Let lives=lives-1
  8. Print “You just opened the airlock into space. You
  9. are dead!”
  10. Print “You now have “;lives; “ lives left.”



Step 5

Now add:

  1. If lives=0 then goto 25
  2. Print “Press the Spacebar to try again.”
  3. While inkey <> 32 cycle
  4. Repeat
  5. Goto 8
  6. Else
  7. Print “The door to the interior of the space
  8. station opens, lucky for you.”

The Goto command goes to a line number and continues with the code. Here you can use it to start an end of game routine.



Step 6

Let’s finish this routine off with:

  1. Endif
  2. Endif
  3. Goto 29
  4. Print “Sorry, you are dead. End of game. Press
  5. Spacebar to start again.”
  6. While inkey <> 32 cycle
  7. Repeat
  8. Goto 1

This closes the If statements, then goes to line 29 (if you pressed the Green button) to continue the game, skipping the end of game routine.



Step 7

From line 25 we start the end of game routine as stated on line 15, goto 25. This only works if the variable lives equals 0; the player’s lives have run out. It prints a ‘sorry you are dead’ message and asks to press the Spacebar to start the game all over again from line 1, the goto 1 part.



Step 8

We can now continue the game from line 29, adding another press the Spacebar routine, followed by a clear screen ready for the next part of the adventure.

  1. Print “Press the Spacebar to continue…”
  2. While inkey <> 32 cycle
  3. Repeat
  4. Cls



Step 9

You can now Save the code, call it Adventure (or something), and Run it from the menu. Whilst it’s not the most elegant code you will ever see, it brings in many different elements and shows you what can be done with FUZE BASIC.



Step 10

Before you continue with the adventure, and map the fate of our reluctant space hero, we’re going to improve our code with some graphics. FUZE BASIC has some great graphical commands at its disposal, along with some other useful and interesting extras.


0 Response to "Coding with FUZE BASIC – Part 2"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel