-->

Coding with FUZE BASIC – Part 3

The last tutorial had you creating the foundations for a text-based adventure game. Whilst it works perfectly fine, it would be nice to include some graphics and maybe a few other elements to have it stand out from the usual BASIC programs.

ADDING GRAPHICS


FUZE BASIC employs a variety of different commands to display graphics, either drawn on the screen or by displaying an image file.


Step 1

You’re going to start by making the game full screen, then adding an appropriate image that sets the theme of the adventure. From line 2 press Enter, to create a new line 3, and type in the following:

  1. Fullscreen=1
  2. Spriteindex=newsprite(1)
  3. Earth$=”planetEarth.png”
  4. Loadsprite (earth$, spriteindex, 0)
  5. Plotsprite (spriteindex, 200, 200, 0)
Coding with FUZE BASIC – Part 3
Coding with FUZE BASIC – Part 3


Step 2

The code from Step 1 will import and display an image of the Earth; the image itself is already available in the /Desktop/fuze-basic/extras/images folder. It’s now classed as a sprite and can be manipulated through the various graphical commands of FUZE BASIC. Any unique images you want to include should be copied to this folder to add to your game.



Step 3

Now create a new line 13, by getting the cursor to the end of line 12 and pressing Enter. For the new line, type in:

Hidesprite (spriteindex)

This command will remove the image from the screen, allowing you to include a new image for the next step in the game.



Step 4

You may need to source your own images for your game. In our example, we found an image of red
and green buttons and copied to the /Desktop/fuze-basic/extras/ images folder. Now we need to add it to our code from line 15:

  1. buttons$=”buttons.png”
  2. loadsprite (buttons$, spriteindex, 0)
  3. plotsprite (spriteindex, 300, 400, 0)

Make sure the image is called before the Input command!



Step 5

Continuing, we can use images of the interior of the ISS if the Green button is pressed. Download the image, put it in the images folder, name it ISS.png and call it from the code whilst hidesprite hides the previous image.

  1. Hidesprite (spriteindex)
  2. U;date
  3. Print “The door to space station opens..”
  4. ISS$=”ISS.png”
  5. Loadsprite (ISS$, spriteindex, 0)
  6. Plotsprite (spriteindex, 200, 200, 0)

Step 6

By now your code is getting quite hefty. Don’t forget that with each new line you’re entering, the original Goto values will be different. It’s best to return to the code and update the lines where Goto is referenced.



Step 7

Additionally we can add an image for the End of Game routine and insert the code from line 39:

  1. Print “Sorry, you are dead.”
  2. Gameover$=”gameover.png”
  3. Loadsprite (gameover$, spriteindex, 0)
  4. Plotsprite (spriteindex, 200, 200, 0)
  5. While inkey <> 32 cycle
  6. Repeat
  7. Hidesprite (spriteindex)
  8. Goto 1



Step 8

Once more, the code has now expanded and as such you need to ensure that any reference to another
line is updated to reflect the new numbering; especially lines 24 and 38, which call either End of Game routine or continue the game if the Green Button has been pressed.



Step 9

Naturally you can continue with Cosmic Adventure yourself, adding choices, graphics and keeping tabs on the number of lives and whatever else you can think of. As we said, it’s not the most elegant code and it’s as far from a triple-A game as you can imagine; but at least it’s given you a head start with FUZE Basic.





Step 10

Here’s a recap of the images we’ve used for the graphics in our adventure game. The FUZE BASIC manual comes with countless more commands to make better use of the system, so read through it and expand on what you’ve learned here.





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

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel