The programs you can make with the beginner's development language QBasic include games. Slot machine simulators fall into this category. Making such a game involves several steps. One of those steps, for some approaches to coding this type of game, includes designing the interface that mimics the facade of a slot machine. Another step is calling on QBasic's statements for producing random numbers, RANDOMIZE and RND. One advantage of making a QBasic slot machine game is the ability to display custom, hand-drawn graphics in the slot windows.
- Skill level:
Other People Are Reading
Things you need
Open, in a word processor, the source files of an open source program that simulates a slot machine. Sample slot machine programs include Casino Sim and Tuty Fruty Slot. These are not QBasic programs, but you'll convert them to QBasic.
Print the source files and make a new set of blank source files with the same names as the originals.
Type into each new source file the statements from the corresponding non-blank file. This task requires you to read closely the original slot machine's source code. This close reading provides insight into how the game works.
Write comments, as you're typing each statement, that describe the statement's purpose. For example, for the statement "if (slot1==slot2==slot3) blnJackPot = true;" you may write "This statement is comparing the values of each slot with the other slots. If all slots have the same value, a jackpot is flagged."
Write these comments using the characters that delimit comments, as defined by the slot machine's programming language. Many programming languages use the characters "/ and /" to bracket comments. If you don't know or aren't sure of a statement's purpose, put a question mark in the comment's brackets.
Retype the program's source files again but do so from memory this time. You'll need to refer to the printouts at first but after a few typing sessions you'll be able to recite the program from memory. According to Texas A&M neuroscience professor Bill Klemm, since memorisation builds understanding, finishing this task successfully will complete your understanding of the program. You can then translate it to QBasic.
Write a translation of each statement from the original slot machine game in your QBasic programming editor. Read a description of QBasic's syntax in your editor's help file if don't know how to translate a particular statement.
Run the program after translating all statements in the original slot machine program to play the QBasic slot machine. If the program doesn't work, use your editor's code-stepping tools to find and fix all errors. (Code-stepping is executing a program one statement at a time.)
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for