Release three of Half-Byte Tiny Basic ate up about eight more bytes of memory than the previous release, so there are now 938 bytes free for user code to reside. My last version of Zapp the Moon Man—previously unpublished—featured the Moon man’s ability to move down the screen and attack as well as the user’s ability to move the cannon back and forth. Sadly, for this release, I’ve had to remove the downward mobility of the Moon Man, but I have left in the user’s ability to move and also made the ‘hit box’ better, resulting in a somewhat easier game play.
This game shows off just how versatile Tiny Basic can be, how speedy the ATMega 328 is and how quickly Tiny Basic can interpret your code.
At any one time in the game, both your cannon and the Moon Man can be moving as well as the torpedo you are shooting at the moon man. Three objects to track on the screen. In interpreted BASIC. Running on a microcontroller that was meant for turning relays on and off, not playing video games. And, it does it rather smoothly. The jerkiness that is there is there by design, to mimmick those games from the 1970’s.
The game is pretty primitive. It resembles Space Invaders, but there is only one ‘invader’, the Moon Man, and there are no protective shields…heck, the Moon Man does not even shoot at you…yet. It does feature some primitive, character based, animated graphics. The Moon Man sort of looks like a Space Invader. As it moves back and forth, its antennae move and its ‘feet’ swivel side to side. You use a Wii Nunchuck’s thumb stick to move and the Z button to fire your torpedo. The game keeps a score…10 points for every Moon Man you destroy. You hear a launch tone when you fire and, when you hit a Moon Man, you see a little explosion like effect. And…that’s it. Simple and not earth shattering (that will be in a future update.)
So, with out any further delay…(One note: when typing in the code, do not put in extra spaces. Use one space between the line number and the code, and one space before line numbers in things like GOTO or GOSUB. The listing below inserted additional spacing, you can ignore it.)
100 CLS:ECHO 0
140 LINE 0,48,80,48,1
150 GOSUB 700
160 GOSUB 900
180 IF P=1 F=1:TONE 200,100
190 IF F=1 GOSUB 1000
192 IF Q>200 GOSUB 600
194 IF Q<100 GOSUB 600
210 IF A>15 D=-1
220 IF A<3 D=1
230 GOSUB 1200
290 GOTO 140
600 CURSOR X,Y:?” “;
610 IF Q>200 I=1
620 IF Q<200 I=-1
640 IF X<2 X=2
650 IF X>17 X=17
660 GOSUB 900
700 IF D=1 CURSOR A,B:?CHR(152);:DELAY O:CURSOR A,B:?CHR(153);:DELAY O:CURSOR A,B:?” “;
710 IF D=-1 CURSOR A,B:?CHR(153);:DELAY O:CURSOR A,B:?CHR(152);:DELAY O:CURSOR A,B:?” “;
900 CURSOR X,Y:?CHR(150);
1000 CURSOR X,Z:?”|”;:DELAY 20:CURSOR X,Z:?” “;:DELAY 20
1060 IF Z=0 IF A=X Z=5: GOTO 1100
1070 IF Z=0 IF A=X+1 Z=5: GOTO 1100
1080 IF Z=0 Z=5:F=0
1100 CURSOR A,B
1110 ?”***”;:DELAY 180:CURSOR A,B:?”XXX”;:DELAY 170:CURSOR A,B:?” “;:A=0:B=0:F=0
1200 CURSOR 0,5:?”SCORE:”,S;
If you come up with any improvements, optimization, etc., please let us know.
Oh, one big caveat…as it does use up all but 15 bytes of RAM, your keyboard buffer is limited to 15 bytes…Tiny Basic does not set aside a dedicate memory for keyboard input. It dwindles as you use up memory. So, keep in mind that you may have to delete a long line and split it up—which will use at least three bytes plus the content of the line.