I built a game in BASIC
I built a game in BASIC
Three years ago I thought about creating a game in BASIC. I was thinking of a defender style game - I created a 4 key control of a ship then did some static landscape, then animated the landscape - the whole thing ground to a halt
So I thought ok need to learn Machine Code / assembly language. well this was OK but I got caught up trying a simple press key move square block.
I then stumbled on this site and found a reference to a recent book on games called "ZX Spectrum Games Code Club" by Gary Plowman. What this book gave me was both the inspiration and the Game Loop definition - I know this sounds stupid but it was something I had not realised the importance of when thinking "I want to build a game".
So this was mid feb and now I present my game to you. I will start learning Machine code again now and will look to do a sequel to this game.
Escape From Tau Ceti
Its the year 2020 and we are in the early years of exploration of our near solar systems. Your part of a 2000 man team who are tasked with surveying Planet 000291 in the solar system Tau Ceti. The teams arrive in the mothership and park in high orbit, multiple dropships deliver you and many other survey craft to the surface.
Your survey ship is a very capable ship. It has three berths, cockpit, living room, replicators and stasis chambers for long flights. However when working in atmospheric worlds it runs on aviation fuel where as for interstella flight it requires rocket fuel.
Your story begins at "RUN"...
####################################
The game was built on a 48k Spectrum.
I have tested the game on the following emulators
- Fuse on my PSP
- Spectaculator 8.0 on my PC
I would love feedback for making this better. Its a "bucket list item" and I am pleased with the result, however its just simple BASIC, nothing clever, no tricks nothing. Would love shooting and moving aliens.
Not sure how to add the TAP file to the posting?
So I thought ok need to learn Machine Code / assembly language. well this was OK but I got caught up trying a simple press key move square block.
I then stumbled on this site and found a reference to a recent book on games called "ZX Spectrum Games Code Club" by Gary Plowman. What this book gave me was both the inspiration and the Game Loop definition - I know this sounds stupid but it was something I had not realised the importance of when thinking "I want to build a game".
So this was mid feb and now I present my game to you. I will start learning Machine code again now and will look to do a sequel to this game.
Escape From Tau Ceti
Its the year 2020 and we are in the early years of exploration of our near solar systems. Your part of a 2000 man team who are tasked with surveying Planet 000291 in the solar system Tau Ceti. The teams arrive in the mothership and park in high orbit, multiple dropships deliver you and many other survey craft to the surface.
Your survey ship is a very capable ship. It has three berths, cockpit, living room, replicators and stasis chambers for long flights. However when working in atmospheric worlds it runs on aviation fuel where as for interstella flight it requires rocket fuel.
Your story begins at "RUN"...
####################################
The game was built on a 48k Spectrum.
I have tested the game on the following emulators
- Fuse on my PSP
- Spectaculator 8.0 on my PC
I would love feedback for making this better. Its a "bucket list item" and I am pleased with the result, however its just simple BASIC, nothing clever, no tricks nothing. Would love shooting and moving aliens.
Not sure how to add the TAP file to the posting?
Re: I built a game in BASIC
Anyone know how to add attachments to a post?
Re: I built a game in BASIC
You can't, sorry. Can you link to dropbox, google drive or sommat?
Failing that, I'll send you a PM and I can give a temporary link. Then hopefully you'll let us host it here in the SC archive
I built a game in BASIC
Thank you I had not thought about that.
Here you go.
https://drive.google.com/file/d/1HuWIeq ... sp=sharing
8 levels
Purple fuel is worth more than red
Bonus for completing a level without crashing or running out of time
Extra life at level 6
Hope you like its limited capability
Here you go.
https://drive.google.com/file/d/1HuWIeq ... sp=sharing
8 levels
Purple fuel is worth more than red
Bonus for completing a level without crashing or running out of time
Extra life at level 6
Hope you like its limited capability
Re: I built a game in BASIC
Love it—it's 1982 again!
Overall, I like the look of it and it's a fun to play. The sprite moves at just the right speed, and the hazards aren't overwhelming. In its current state it would be a well above average type-in, or a CGC entry that is too good for the comp!.
I don't know about improvements. I liked the idea that if the fuel cells hit the background you lose a life, but that would mean a pretty big redesign of the backgrounds. A few moving baddies that gobble up the fuel cells and are fatal to the player might be fun later on, but not too many as it would slow things down a lot. Perhaps some timed laser beams? (hyphens or underscores to the unitiated!).
I think it's pretty good as it is, especially as it was done on a real Speccy. Personally, I'd take everything I've learned from this and put it into practise in a new project, but some people like to keep refining their work.
(Small & easy fix: "Altitude" is spelt wrong on level 2.)
Overall, I like the look of it and it's a fun to play. The sprite moves at just the right speed, and the hazards aren't overwhelming. In its current state it would be a well above average type-in, or a CGC entry that is too good for the comp!.
I don't know about improvements. I liked the idea that if the fuel cells hit the background you lose a life, but that would mean a pretty big redesign of the backgrounds. A few moving baddies that gobble up the fuel cells and are fatal to the player might be fun later on, but not too many as it would slow things down a lot. Perhaps some timed laser beams? (hyphens or underscores to the unitiated!).
I think it's pretty good as it is, especially as it was done on a real Speccy. Personally, I'd take everything I've learned from this and put it into practise in a new project, but some people like to keep refining their work.
(Small & easy fix: "Altitude" is spelt wrong on level 2.)
- Ast A. Moore
- Rick Dangerous
- Posts: 2641
- Joined: Mon Nov 13, 2017 3:16 pm
Re: I built a game in BASIC
Looks really good. It like the gameplay and the color scheme!
One tiny improvement would be to make the game run automatically after loading. Simply add a LINE 1 statement when you save the game, as in:
One tiny improvement would be to make the game run automatically after loading. Simply add a LINE 1 statement when you save the game, as in:
Code: Select all
SAVE "EscapeTC" LINE 1
Every man should plant a tree, build a house, and write a ZX Spectrum game.
Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
Re: I built a game in BASIC
True, but I must say that I loved this touch as part of the backstory:Ast A. Moore wrote: ↑Fri Mar 22, 2019 10:08 pm One tiny improvement would be to make the game run automatically after loading. Simply add a LINE 1 statement when you save the game, as in:
Your story begins at "RUN"...
- Ast A. Moore
- Rick Dangerous
- Posts: 2641
- Joined: Mon Nov 13, 2017 3:16 pm
Re: I built a game in BASIC
It is sweet . . . on a 48K machine, but requires too many additional keypresses on 128K machines. I get impatient somewhere between U and N.
Every man should plant a tree, build a house, and write a ZX Spectrum game.
Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
Re: I built a game in BASIC
In true type-in style, it's 48K mode only, 128K gives the "SPECTRUM" text issue.Ast A. Moore wrote: ↑Fri Mar 22, 2019 10:18 pm It is sweet . . . on a 48K machine, but requires too many additional keypresses on 128K machines. I get impatient somewhere between U and N.
- Ast A. Moore
- Rick Dangerous
- Posts: 2641
- Joined: Mon Nov 13, 2017 3:16 pm
Re: I built a game in BASIC
Haven’t noticed it yet. The SPECTRUM and PLAY tokens only take up two UDGs, and this game doesn’t seem to be using them.R-Tape wrote: ↑Fri Mar 22, 2019 10:23 pmIn true type-in style, it's 48K mode only, 128K gives the "SPECTRUM" text issue.Ast A. Moore wrote: ↑Fri Mar 22, 2019 10:18 pm It is sweet . . . on a 48K machine, but requires too many additional keypresses on 128K machines. I get impatient somewhere between U and N.
But, yeah, I used to have Fuse run the 48K Speccy at launch at all times. Recently, I changed it to the 128K for testing some of my code.
Every man should plant a tree, build a house, and write a ZX Spectrum game.
Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
Re: I built a game in BASIC
Nice!!
Suggestions:
what about a fake RUN ?
If inkey$="R" then Print "RUN"
followed by another inkey$ to wait for Enter
A key to speed up the aircraft and another one to shoot a laser which destroys mountains and aliens. Make an energy bar decrease when hitting such keys.
Too bright anf too little contrasat for me. Could you make it on a Mars-like planet? dark red, dark green..
Suggestions:
what about a fake RUN ?
If inkey$="R" then Print "RUN"
followed by another inkey$ to wait for Enter
A key to speed up the aircraft and another one to shoot a laser which destroys mountains and aliens. Make an energy bar decrease when hitting such keys.
Too bright anf too little contrasat for me. Could you make it on a Mars-like planet? dark red, dark green..
Re: I built a game in BASIC
I thought that was pretty good! For a BASIC game, ala 1982, it had the right ingredients: colour, sound, cheesy UDG graphics mixed with vectors, and simple gameplay. I couldn't help smiling as I played it.
Derek Fountain, author of the ZX Spectrum C Programmer's Getting Started Guide and various open source games, hardware and other projects, including an IF1 and ZX Microdrive emulator.
Re: I built a game in BASIC
Yeah I think thats the plan, this was a good learning experience, but I need more powerR-Tape wrote: ↑Fri Mar 22, 2019 9:58 pm I think it's pretty good as it is, especially as it was done on a real Speccy. Personally, I'd take everything I've learned from this and put it into practise in a new project, but some people like to keep refining their work.
(Small & easy fix: "Altitude" is spelt wrong on level 2.)
Good to know, thank you for that.Ast A. Moore wrote: ↑Fri Mar 22, 2019 10:08 pm Looks really good. It like the gameplay and the color scheme!
One tiny improvement would be to make the game run automatically after loading. Simply add a LINE 1 statement when you save the game
I know whet you mean, I did try on level 7. Space to have a black background, unfortunately the way I move the ship is to move forward then, print " " over where the ship was. By just adding print paper 0;" " it slowed everything down so I was stuck using just white. Until/if I master Machine Code.. then we can have what we want
Thanks for all the positivity..
For those interested the code is pretty heavily REM'ed.
To check all the levels just edit line 9170 set Q to a number between 1 and 8 for the 8 levels.
The code is
0-999 Game Loop
1000 - 1999 Game Screen
2000-2999 Levels
6000-6999 UDGs
9000 - 9999 Set Up
The following are the Variables
A - Cell1 posx
B - Cell1 posy
C - Number of cells caught
D - Time bar delete 8x8 square
E - Cell2 posx
F - Cell2 posy
G - Ground
H - Target number of cells to collect
i - loop var
J - Array Counter for cells start X position
K
L - Lives
M - Fuel Cell 1 Active
N - Fuel Cell 2 Active
O
P
Q - Level your on/next level
R - Speed of the cells
S - Score
T - Time
U - next move posx ship
V - next move posy ship
W - Time bar counter
X - Ship current posx
Y - Ship current posy
Z - Counter for speed and animation of cells
######
HS - High Score
TBF - Time Bonus Flag (0 on, 1 off)
During development I timed the "Kessel Run" that is from the far left of the screen - hit stop watch and "n", stop stop watch when you get to the other side. make sure no fuel cells are caught or hit the ground.
Initially the game loop as at 3000 - 3999 and the run was roughly 7.8secs. On recommendation i moved the game loop to the top of the program and the run dropped to approx. 6.2 secs! I tried other variations of optimisation but nothing else had such a drastic effect.
Re: I built a game in BASIC
Note: you can set the paper colour outside of any print statements, just by writing PAPER 0. You'd probably want to change the border colour too, and you'll obviously need to change the message colours.
Nice game, thanks!
Nice game, thanks!
- Einar Saukas
- Bugaboo
- Posts: 3097
- Joined: Wed Nov 15, 2017 2:48 pm
Re: I built a game in BASIC
I recommend to keep this sentence, but use SAVE LINE anyway, for convenience.R-Tape wrote: ↑Fri Mar 22, 2019 10:15 pmTrue, but I must say that I loved this touch as part of the backstory:Ast A. Moore wrote: ↑Fri Mar 22, 2019 10:08 pm One tiny improvement would be to make the game run automatically after loading. Simply add a LINE 1 statement when you save the game, as in:
Your story begins at "RUN"...
It's going to feel even more authentic, since there's a long tradition of small mismatches between type-ins and their instructions
- 5MinuteRetro
- Manic Miner
- Posts: 762
- Joined: Mon Nov 13, 2017 12:21 pm
- Location: UK
- Contact:
Re: I built a game in BASIC
I just tried this, on ZXDS. Looks nice but it doesn't respond to the suggested controls. Perhaps I'm doing something wrong?
Retro stuff, real quick
YouTube: http://bit.ly/5MinuteRetro
Twitter: https://twitter.com/5MinuteRetro
YouTube: http://bit.ly/5MinuteRetro
Twitter: https://twitter.com/5MinuteRetro
Re: I built a game in BASIC
I don't know, but it could be the same issue that I had in my emulator, namely that when the keys are polled (beginning at line 170), the value that is matched includes the ear bit (bit 6). If, after loading a tape, bit 6 is set, the keys won't be identified correctly. You could add a line 171 PRINT AT 0,0; IN 32766 to see what happens.5MinuteRetro wrote: ↑Sun Mar 24, 2019 10:07 pm I just tried this, on ZXDS. Looks nice but it doesn't respond to the suggested controls. Perhaps I'm doing something wrong?
A very nice game by the way. It really has that authentic feel.
My ZX Spectrum emulator project: https://softspectrum48.weebly.com.
- 5MinuteRetro
- Manic Miner
- Posts: 762
- Joined: Mon Nov 13, 2017 12:21 pm
- Location: UK
- Contact:
Re: I built a game in BASIC
I barely understand that but I think I'll probably figure out/remember how to add a line of BASIC, so I'll give that a go -- thanks!Magnus wrote: ↑Mon Mar 25, 2019 4:39 amI don't know, but it could be the same issue that I had in my emulator, namely that when the keys are polled (beginning at line 170), the value that is matched includes the ear bit (bit 6). If, after loading a tape, bit 6 is set, the keys won't be identified correctly. You could add a line 171 PRINT AT 0,0; IN 32766 to see what happens.5MinuteRetro wrote: ↑Sun Mar 24, 2019 10:07 pm I just tried this, on ZXDS. Looks nice but it doesn't respond to the suggested controls. Perhaps I'm doing something wrong?
Retro stuff, real quick
YouTube: http://bit.ly/5MinuteRetro
Twitter: https://twitter.com/5MinuteRetro
YouTube: http://bit.ly/5MinuteRetro
Twitter: https://twitter.com/5MinuteRetro
Re: I built a game in BASIC
Sorry if this was a bit cryptic, but if you add the line I suggested, the program would print 255 in the upper left corner of the screen if my theory is correct and bit 6 is set. It doesn't solve anything though, the emulator should be modified in that case.5MinuteRetro wrote: ↑Mon Mar 25, 2019 10:17 amI barely understand that but I think I'll probably figure out/remember how to add a line of BASIC, so I'll give that a go -- thanks!Magnus wrote: ↑Mon Mar 25, 2019 4:39 am I don't know, but it could be the same issue that I had in my emulator, namely that when the keys are polled (beginning at line 170), the value that is matched includes the ear bit (bit 6). If, after loading a tape, bit 6 is set, the keys won't be identified correctly. You could add a line 171 PRINT AT 0,0; IN 32766 to see what happens.
My ZX Spectrum emulator project: https://softspectrum48.weebly.com.
- Ast A. Moore
- Rick Dangerous
- Posts: 2641
- Joined: Mon Nov 13, 2017 3:16 pm
Re: I built a game in BASIC
No, but you could play around with the Issue 2 Keyboard feature, if the emulator has it.5MinuteRetro wrote: ↑Sun Mar 24, 2019 10:07 pm I just tried this, on ZXDS. Looks nice but it doesn't respond to the suggested controls. Perhaps I'm doing something wrong?
The keyboard polling in the game should be changed from polling ports and expecting a particular value to a simple INKEY$ statement. Then the game will work on all Spectrums:
Every man should plant a tree, build a house, and write a ZX Spectrum game.
Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
- 5MinuteRetro
- Manic Miner
- Posts: 762
- Joined: Mon Nov 13, 2017 12:21 pm
- Location: UK
- Contact:
Re: I built a game in BASIC
Still not entirely sure what this is meant to do but... I just added the line successfully. The number 255 does indeed appear at the top-left corner, and the it changes as I press the game's control keys, so clearly the code knows I'm inputting something -- but still no movement from the ship.
Retro stuff, real quick
YouTube: http://bit.ly/5MinuteRetro
Twitter: https://twitter.com/5MinuteRetro
YouTube: http://bit.ly/5MinuteRetro
Twitter: https://twitter.com/5MinuteRetro
Re: I built a game in BASIC
Had a go at it, it's a nice game and very responsive considering it's written in BASIC. I didnt managed to see all the levels but broke into the game so I could see them, along with the victory screen..
So was it completely written on a Speccy? If so, the discussions about getting it to work on various emulators is quite funny, it's usually the other way round..
So was it completely written on a Speccy? If so, the discussions about getting it to work on various emulators is quite funny, it's usually the other way round..
My Speccy site: thirdharmoniser.com
Re: I built a game in BASIC
Well, that confirms my theory at least . Maybe the author would be kind enough to change the code to use inkey$ as Ast A. Moore proposed in a previous post. Or, you could give it a try yourself.5MinuteRetro wrote: ↑Mon Mar 25, 2019 11:35 amStill not entirely sure what this is meant to do but... I just added the line successfully. The number 255 does indeed appear at the top-left corner, and the it changes as I press the game's control keys, so clearly the code knows I'm inputting something -- but still no movement from the ship.
My ZX Spectrum emulator project: https://softspectrum48.weebly.com.
Re: I built a game in BASIC
Yes, it's a much better situation for us emulator authors .Morkin wrote: ↑Mon Mar 25, 2019 1:06 pm Had a go at it, it's a nice game and very responsive considering it's written in BASIC. I didnt managed to see all the levels but broke into the game so I could see them, along with the victory screen..
So was it completely written on a Speccy? If so, the discussions about getting it to work on various emulators is quite funny, it's usually the other way round..
My ZX Spectrum emulator project: https://softspectrum48.weebly.com.
Re: I built a game in BASIC
Hehe the irony is not lost on me, editing a game built in a zx spectrum so it works on a zx spectrum emulator
I will make the inkey() change plus add recognition that you’ve set a new high score and there are a couple of bugs that I might try and solve. Won’t be able to do anything till next week though - sry.
Thanks again for all the positivity
I will make the inkey() change plus add recognition that you’ve set a new high score and there are a couple of bugs that I might try and solve. Won’t be able to do anything till next week though - sry.
Thanks again for all the positivity