I built a game in BASIC

Show us what you're working on, (preferably with screenshots).
User avatar
Hedge1970
Manic Miner
Posts: 388
Joined: Mon Feb 18, 2019 2:41 pm

I built a game in BASIC

Post by Hedge1970 »

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 :cry:

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. :lol:

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.

Image

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?
User avatar
Hedge1970
Manic Miner
Posts: 388
Joined: Mon Feb 18, 2019 2:41 pm

Re: I built a game in BASIC

Post by Hedge1970 »

Anyone know how to add attachments to a post?
User avatar
R-Tape
Site Admin
Posts: 6353
Joined: Thu Nov 09, 2017 11:46 am

Re: I built a game in BASIC

Post by R-Tape »

Hedge1970 wrote: Fri Mar 22, 2019 8:22 pm Anyone know how to add attachments to a post?
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 😊
User avatar
Hedge1970
Manic Miner
Posts: 388
Joined: Mon Feb 18, 2019 2:41 pm

I built a game in BASIC

Post by Hedge1970 »

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 :)
User avatar
R-Tape
Site Admin
Posts: 6353
Joined: Thu Nov 09, 2017 11:46 am

Re: I built a game in BASIC

Post by R-Tape »

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.)
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2640
Joined: Mon Nov 13, 2017 3:16 pm

Re: I built a game in BASIC

Post by Ast A. Moore »

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:

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.
User avatar
R-Tape
Site Admin
Posts: 6353
Joined: Thu Nov 09, 2017 11:46 am

Re: I built a game in BASIC

Post by R-Tape »

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:
True, but I must say that I loved this touch as part of the backstory:
Your story begins at "RUN"...
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2640
Joined: Mon Nov 13, 2017 3:16 pm

Re: I built a game in BASIC

Post by Ast A. Moore »

R-Tape wrote: Fri Mar 22, 2019 10:15 pm True, but I must say that I loved this touch as part of the backstory:
Your story begins at "RUN"...
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.
User avatar
R-Tape
Site Admin
Posts: 6353
Joined: Thu Nov 09, 2017 11:46 am

Re: I built a game in BASIC

Post by R-Tape »

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.
In true type-in style, it's 48K mode only, 128K gives the "SPECTRUM" text issue.
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2640
Joined: Mon Nov 13, 2017 3:16 pm

Re: I built a game in BASIC

Post by Ast A. Moore »

R-Tape wrote: Fri Mar 22, 2019 10:23 pm
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.
In true type-in style, it's 48K mode only, 128K gives the "SPECTRUM" text issue.
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.

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.
hikoki
Manic Miner
Posts: 576
Joined: Thu Nov 16, 2017 10:54 am

Re: I built a game in BASIC

Post by hikoki »

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..
dfzx
Manic Miner
Posts: 673
Joined: Mon Nov 13, 2017 6:55 pm
Location: New Forest, UK
Contact:

Re: I built a game in BASIC

Post by dfzx »

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.
User avatar
Hedge1970
Manic Miner
Posts: 388
Joined: Mon Feb 18, 2019 2:41 pm

Re: I built a game in BASIC

Post by Hedge1970 »

R-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.)
Yeah I think thats the plan, this was a good learning experience, but I need more power :)
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
Good to know, thank you for that.

hikoki wrote: Sat Mar 23, 2019 12:52 am Too bright anf too little contrasat for me. Could you make it on a Mars-like planet? dark red, dark green..
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.
User avatar
Kweepa
Manic Miner
Posts: 311
Joined: Sat Feb 03, 2018 6:14 pm
Location: Albuquerque, New Mexico

Re: I built a game in BASIC

Post by Kweepa »

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!
User avatar
Einar Saukas
Bugaboo
Posts: 3070
Joined: Wed Nov 15, 2017 2:48 pm

Re: I built a game in BASIC

Post by Einar Saukas »

R-Tape wrote: Fri Mar 22, 2019 10:15 pm
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:
True, but I must say that I loved this touch as part of the backstory:
Your story begins at "RUN"...
I recommend to keep this sentence, but use SAVE LINE anyway, for convenience.

It's going to feel even more authentic, since there's a long tradition of small mismatches between type-ins and their instructions :)
User avatar
5MinuteRetro
Manic Miner
Posts: 755
Joined: Mon Nov 13, 2017 12:21 pm
Location: UK
Contact:

Re: I built a game in BASIC

Post by 5MinuteRetro »

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
Magnus
Dizzy
Posts: 61
Joined: Sat Jan 06, 2018 6:47 am
Location: Sweden

Re: I built a game in BASIC

Post by Magnus »

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?
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.

A very nice game by the way. It really has that authentic feel.
My ZX Spectrum emulator project: https://softspectrum48.weebly.com.
User avatar
5MinuteRetro
Manic Miner
Posts: 755
Joined: Mon Nov 13, 2017 12:21 pm
Location: UK
Contact:

Re: I built a game in BASIC

Post by 5MinuteRetro »

Magnus wrote: Mon Mar 25, 2019 4:39 am
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?
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.
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!
Retro stuff, real quick
YouTube: http://bit.ly/5MinuteRetro
Twitter: https://twitter.com/5MinuteRetro
Magnus
Dizzy
Posts: 61
Joined: Sat Jan 06, 2018 6:47 am
Location: Sweden

Re: I built a game in BASIC

Post by Magnus »

5MinuteRetro wrote: Mon Mar 25, 2019 10:17 am
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.
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!
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.
My ZX Spectrum emulator project: https://softspectrum48.weebly.com.
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2640
Joined: Mon Nov 13, 2017 3:16 pm

Re: I built a game in BASIC

Post by Ast A. Moore »

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?
No, but you could play around with the Issue 2 Keyboard feature, if the emulator has it.

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:

Image
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.
User avatar
5MinuteRetro
Manic Miner
Posts: 755
Joined: Mon Nov 13, 2017 12:21 pm
Location: UK
Contact:

Re: I built a game in BASIC

Post by 5MinuteRetro »

Magnus wrote: Mon Mar 25, 2019 11:04 am 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.
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
User avatar
Morkin
Bugaboo
Posts: 3251
Joined: Mon Nov 13, 2017 8:50 am
Location: Bristol, UK

Re: I built a game in BASIC

Post by Morkin »

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.. :oops:

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.. :lol:
My Speccy site: thirdharmoniser.com
Magnus
Dizzy
Posts: 61
Joined: Sat Jan 06, 2018 6:47 am
Location: Sweden

Re: I built a game in BASIC

Post by Magnus »

5MinuteRetro wrote: Mon Mar 25, 2019 11:35 am
Magnus wrote: Mon Mar 25, 2019 11:04 am 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.
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. :(
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.
My ZX Spectrum emulator project: https://softspectrum48.weebly.com.
Magnus
Dizzy
Posts: 61
Joined: Sat Jan 06, 2018 6:47 am
Location: Sweden

Re: I built a game in BASIC

Post by Magnus »

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.. :oops:

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.. :lol:
Yes, it's a much better situation for us emulator authors :D.
My ZX Spectrum emulator project: https://softspectrum48.weebly.com.
User avatar
Hedge1970
Manic Miner
Posts: 388
Joined: Mon Feb 18, 2019 2:41 pm

Re: I built a game in BASIC

Post by Hedge1970 »

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
Post Reply