RFO Basic! is a BASIC interpreter that lets users create attractive programs for Android without the fuss of Java and other programming languages. There is no easier way to write programs for Android, and it can be done with or without a computer. By using the BASIC! Compiler, you can produce APK files that are easily distributed, even through the Google Play Store.
Unfortunately that ease of use comes at a cost. The cost comes includes somewhat slow performance and a lack of features that would make game design easier. There are better tools for aspiring game designers to try, but if you want to tinker on your Android Phone or tablet, and if you have the patient and the creative mind necessary, you can develop games with RFO Basic.
If you are new to programming but want to make a game then this tutorial may not be enough help. Try a game creation tool like godot on a PC to get started. If you must make your game with an android device, you might have better luck with LibGDX than with RFO Basic! It uses Java, which is generally more difficult, but there tons of books and tutorials to get you started. Aide, a Java compiler for Android, supports LibGDX and even includes a game making tutorial built in.
Since you're still reading, you must have an interest or a need to develop Android games with RFO Basic, so let us begin.
The RFO Basic! App - free from the app store
The RFO Basic! Manual and a PDF viewer to read it
The Basic! Compiler - 3$ from the app store
A keyboard or a soft keyboard that has easy access to symbols used in Basic!, such as ",',<,$, and others
A vector graphics app for Android, such as Ivy Draw(6$), Inker(10$), or Paper Simple(free)
A pixel graphics app for Android, such as Pixly(free)
SFXR to create retro sound effects with ease (free)
An audio editor such as WavePad(10$,free)
A good understanding of Basic programming. There may not be good tutorials for RFO Basic!, but there are countless for other basic dialects
You cannot make 3D games with RFO Basic!
You cannot make advanced games on par with many of those found on the Play Store
You CAN make simple games and learn good game design practices
Many simple games for Android have made people very wealthy, and with a good idea and LOTS of luck, you could be the next one
A basic interpreter cannot handle the number of calculations that some games might need
If you have ten monsters on the screen and ten bullets, that's at least 100 possible collisions to test for, perhaps too many
If you want the enemies to effect enemies and the bullets to effect bullets, that's WAY too many collisions to test for!
If you're smart and careful, you can recreate most games that were available for Nintendo or Genesis, but with better graphics
The first game we will build together is a simple affair. You move your character around a small map and collect the gems scattered about. If you step in a hole you will die. There is plenty of room for improvements, and I will continue this tutorial if anyone asks me to.
The graphics functions included with RFO Basic! are meant for creating the user interfaces for apps, not for making state of the art games. If you want to use RFO Basic! you must understand that you cannot find a graphics library on the internet and add it to your program. Instead, you have to make the most of what is offered.
You should read the entire manual before you try making a game. Then read the graphics section twice more. You need to understand it fully, then consider the advice that I am about to offer you.
There are basically two ways to do
graphics in RFO Basic!. One way is to create and manipulate graphics
objects on the screen, the other is to draw into a bitmap. To develop
real-time action games, you must do both. Graphic objects are memory
and resource intensive, and if you create too many, your app will
slow to a halt or even crash. You can draw into a bitmap all you want
without those problems, but other problems will present themselves,
such as erasing and moving the objects around without leaving a mess
beneath them.
When planning your game, think of which objects need to move around and which ones are part of the background. The player's character and his enemies should be graphic objects. Also, any text or icons that need to stay visible above the characters should be graphic objects. The background, usually built by a grid of objects, should be drawn into a bitmap. Also, if you are going to have a menu then you should probably draw that into a bitmap too, because the borders and all those lines of text will make more graphics objects than you want.
So basically, any object you need to move smoothly around, as well as the icons and the text of your user interface, will all be graphic objects. The rest will be drawn into a single bitmap that is called a buffer. You can draw into the buffer all you want, but erasing it is a little more tricky.
All of your graphic objects will be drawn before the games starts. Then, during the game, you will use gr.modify to move them around and change their frame.
When you're just playing around with demos on your phone you can make things any size you want. If you want to share the game with other people then you need to be aware of the differences between the size and resolution of the screens. Considering the DPI, or dots per inch, is important to professional programmers designing mobile apps, but we'll skip that part and just worry about resolution.
Try to avoid the urge to use specific numbers when placing objects and setting their size. If you do that, and then later you decide to share the game, you'll have quite a time rearranging everything. There are two ways to solve this problem, the easy way and my way. You could make your game based on the resolution of your screen, lets say 1000 x 700 pixels. Then, when you want to make it work on other devices, you could just scale the whole display to the resolution of the device that's running it. This will work, but for some reason, the graphics are very blocky. Instead of scaling the entire screen with the scaling feature of Basic!, we will scale the individual graphic objects and the text size based on a percentage of the screen.
Objects that move around are called sprites. Objects that are part of the background grid are called cells. Lets say you want the game to be a grid of squares that's 20 cells wide and 12 high. We will use a variable called gs, or grid size, to measure its size. When the game starts, we'll calculate gs by dividing the screen's height by 12. If your device was 1000x700 pixels, we would have a grid size of 700/12, or 58. That makes the width 20 cells wide times 58 pixels, or 1,160 pixels. Unfortunately that's too wide for the screen, so we'd need to rethink the grid size.
Designing menus and placing icons should be done in a similar way. Set the text height based on the screen height, such as screen_height/20. If you want an object at the middle right edge of the screen, calculate it based on that.
x=SCREEN_WIDTH-(SCREEN_WIDTH*0.1) % ten percent from the right edge
y=SCREEN_HEIGHT/2 % at the vertical center
It's almost time to start looking at the tutorial game's code. First, let's just discuss the files. There are three images, two sound files, and a map. Player.png, cells.png, pad.png, pickup.mp3, falling.mp3, and map.txt. These files should be placed in the data directory of RFO Basic!, usually "/rfo-basic/data/". The source file, "tut.bas", should be in "/rfo-basic/source". Later we might experiment with level editors, saved settings, and sub folders, and discuss how to compile your app into an APK with those items intact.
The source file is heavily commented and presented in a logical order. I will add a properly formatted tutorial to this document very soon.