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.
This command will remove the image from the screen, allowing you to include a new image for the next step in the game.
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:
Make sure the image is called before the Input command!
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.
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:
Fullscreen=1 Spriteindex=newsprite(1) Earth$=”planetEarth.png” Loadsprite (earth$, spriteindex, 0) Plotsprite (spriteindex, 200, 200, 0)
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 redand green buttons and copied to the /Desktop/fuze-basic/extras/ images folder. Now we need to add it to our code from line 15:
buttons$=”buttons.png” loadsprite (buttons$, spriteindex, 0) 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.
Hidesprite (spriteindex) U;date Print “The door to space station opens..” ISS$=”ISS.png” Loadsprite (ISS$, spriteindex, 0) 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:
Print “Sorry, you are dead.” Gameover$=”gameover.png” Loadsprite (gameover$, spriteindex, 0) Plotsprite (spriteindex, 200, 200, 0) While inkey <> 32 cycle Repeat Hidesprite (spriteindex) Goto 1
Step 8
Once more, the code has now expanded and as such you need to ensure that any reference to anotherline 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.
0 Response to "Coding with FUZE BASIC – Part 3"
Post a Comment