"Time Travel to the Past of Coding: A Guide to Writing BASIC Code on Contemporary Computers"
In the realm of retro computing, a fresh and exciting development has emerged: QB64 Phoenix Edition (QB64 PE). This software serves as an alternative to MOS6502 BASIC for writing BASIC on a PC, offering a modern twist to the classic programming language.
QB64 PE is an offshoot of the original QB64 project, aiming to preserve the spirit of the old application while making it accessible to a wider audience. At its core, QB64 PE is built upon the same principles as the MOS,6502 BASIC from 1978, but with enhanced features and capabilities suitable for modern computers.
To get started with QB64 PE, one needs to download the package from the QB4 PE project page, extract the file, and double-click on the qb64pe.exe application. The software comes equipped with real-time input error checking, an online and offline help system, syntax highlighting, automatic source formatting, debugging, and compiles native binaries for Windows, macOS, and Linux. For those interested in more advanced applications and games with graphics and sound, QB64 PE also offers extended BASIC and OpenGL.
Let's delve into a simple yet engaging example of a game developed using QB64 PE. The game, titled "Escape the Planet," places the player in control of a spaceship, with the objective being to calculate the correct thrust to leave the planet.
The code begins by creating a label, START, which enables jumping to different sections of the code using a Go To command. The player's position on the screen is set at 0,0 (top left), and an image of the spaceship is displayed. The code then pauses, waiting for the user to press a key.
Next, the code creates two variables, g (gravity) and w (weight), which are random integers, multiplied by 20 and 40, respectively. These values represent the planet's gravity and the weight of the spaceship. The player's guess is stored in a variable, f, and compared to the answer, r. If the thrust is too high or low, the for loop repeats until the player runs out of guesses (a total of ten).
To compile the executable into the qb64pe folder, click on Run >> Make EXE Only. Wait for the code to compile. Check the status bar at the bottom of the screen to monitor the progress. Once compiled, double-click on the executable to run the game.
Throughout the game, the code makes use of pseudo-random numbers and an error handler to check that the image has been loaded correctly. If the player wins, the code prints a message and shows an image on the screen. If the player fails to make the correct calculations, the code prints "the bad ending" to the screen, accompanied by a graphic showing the ship losing against the alien onslaught.
The author of this game, who started coding with BASIC at the age of four or five on a Commodore 16, continues to write BASIC on a variety of platforms, including Commodore 64, ZX Spectrum, and a Raspberry Pi Pico. The author's dedication to the BASIC community is evident in the creation of QB64 PE, aiming to provide more people with the opportunity to experience the joy of programming in BASIC on their computers.
It's important to note that the resulting executable is bound to the OS it was created with, meaning that sharing the game with friends may result in the executable being flagged as a false positive by the antivirus. To avoid this, the author recommends distributing the source code instead.
In conclusion, QB64 Phoenix Edition is a powerful tool for those interested in learning and exploring the world of BASIC programming on a PC. With its user-friendly interface, enhanced features, and a vibrant community of developers and enthusiasts, QB64 PE is a valuable resource for both beginners and seasoned programmers alike.