I built a game in BASIC

Show us what you're working on, (preferably with screenshots).
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: 681
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: 3100
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: 766
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: 766
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: 2641
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: 766
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: 3270
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
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2641
Joined: Mon Nov 13, 2017 3:16 pm

Re: I built a game in BASIC

Post by Ast A. Moore »

Hedge1970 wrote: Tue Mar 26, 2019 8:43 am Hehe the irony is not lost on me, editing a game built in a zx spectrum so it works on a zx spectrum emulator :-)
Well, it’s not so much the fault of an emulator as one of the quirks of the Spectrum itself. Some emulators have an option of enabling or disabling the pre–Issue 3 Spectrum keyboard behavior; others don’t. In this instance, the game was (presumably) developed on a later 48K Speccy, which returns a different value of Bit 6 upon reading from port 254. As is, the game wouldn’t work on real Issue 1 and Issue 2 Spectrums either.

There were a bunch of commercial games that suffered from the same problem, so in that respect the game is as genuine as they come. ;)
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
Joefish
Rick Dangerous
Posts: 2058
Joined: Tue Nov 14, 2017 10:26 am

Re: I built a game in BASIC

Post by Joefish »

Can't you just put something in the code to, e.g. do an IN on the title screen when no keys are pressed, then put that in a variable and then do something like key = var - IN xxxxx to work out the key being pressed? That way you don't lose the ability to move diagonally, as you do with INKEY$.

I think the use of keys B/N for left/right so they're in separate IN commands is clever, though you don't need to detect both of those pressed at once so O/P with the same IN isn't too hard.

It's a good game and very fast and responsive for BASIC. I did think about the suggestion of a penalty for missing a drop, but losing time is probably all the penalty you need. I do think the time limit is a bit tight though, especially as the third screen gets very crowded. You may have got too good at your own game while working on it!
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2641
Joined: Mon Nov 13, 2017 3:16 pm

Re: I built a game in BASIC

Post by Ast A. Moore »

Joefish wrote: Tue Mar 26, 2019 11:08 am That way you don't lose the ability to move diagonally, as you do with INKEY$.
I don’t think the ship can move diagonally now, so, nothing is lost.
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.
Post Reply