10 line BBC BASIC game (@-man)

User avatar
0xC0DE
Posts: 671
Joined: Tue Mar 19, 2019 7:52 pm
Location: The Netherlands
Contact:

10 line BBC BASIC game (@-man)

Post by 0xC0DE » Wed Feb 12, 2020 10:57 pm

Meet @-man, a Pacman look alike.
In only 10 lines of BBC BASIC (with no more than 120 chars each). Works on Acorn Electron and BBC.
Features: sound, increasing difficulty, up to 4 chasers, extra lives, highscore, full-screen maze.

Code: Select all

0MO.6:V.28,6,24,32,2:DIMF(26,20),C 4,G 20:H=0:S=0:F$="9069041190112714413111531821316129043111214113141411413130":V=0
1!C=&232E20:i=0:v=1:F.y=0TO10:F.x=0TO13:i=i-(v=1):v=v-1-(v=1)*VA.MI.F$,i,1):u=v=0:IFV=0L=3:K=1:H=-(S>H)*S-(S<=H)*H:S=0
2c=1+(1A.i):s=26-x:t=20-y:F(x,y)=c:F(s,y)=c:F(x,t)=c:F(s,t)=c:x=x+u:v=v-u:N.,:CLS:F.y=0TO20:F.x=0TO26:V.C?F(x,y):N.,:P=0
3F(1,1)=0:V.23,1,0;0;0;0;:X=1:Y=1:G!4=&1301:G!8=&119:G!12=&1319:G!16=&707:IFL=0SO.1,-10,150,5:SO.1,-10,99,5:V=0:G.1
4P.TAB(0,22)"0xC0DE:@-man ";L;" ";S;" (";H;")";:D=INKEY-98-INKEY-67:E=(D=0)*(INKEY-102-INKEY-71):X=X-D*(F(X+D,Y)<2)
5V=31:Y=Y-E*(F(X,Y+E)<2):V.V,X,Y,64:s=F(X,Y):SO.1,-10,128,s:S=S+s:P=P+s:IFP=281K=K+1+(K=4):L=L+1:SO.1,-10,200,10:G.1
6F(X,Y)=0:F.i=1TOK:A=G+4*i:g=?A:h=A?1:q=A?2:r=A?3:?G=(F(g,h-1)<2)*((r=255)+(r=0)):IF(D ORE)V.V,X-D,Y-E,C?F(X-D,Y-E)
7G?1=(F(g+1,h)<2)*((q=1)+(q=0)):G?2=(F(g,h+1)<2)*((r=1)+(r=0)):G?3=(F(g-1,h)<2)*((q=255)+(q=0)):IFg=X A.h=Y:G.9
8REP.I=RND(4)-1:U.G?I:V.V,g,h,C?F(g,h):A?2=(1A.I)+2*(I=3):g=g+A?2:A?3=(1A.(I+1))+2*(I=0):h=h+A?3:V.V,g,h,96:?A=g:A?1=h
9IFg=X A.h=Y i=K:N.:L=L-1:SO.0,-10,6,10:V.V,X,Y,C?F(X,Y):F.i=1TOK:A=G+4*i:V.V,?A,A?1,C?F(?A,A?1):N.:G.3EL.N.:G.4
Post your highscores here 8)

Edit:
@-man.ssd
(2.5 KiB) Downloaded 33 times
Last edited by 0xC0DE on Thu Feb 13, 2020 9:44 am, edited 1 time in total.
0xC0DE
"I program my home computer / Beam myself into the future"
:arrow: Follow me on Twitter
:arrow: Visit my YouTube channel featuring my demos for Acorn Electron and BBC Micro

User avatar
Lardo Boffin
Posts: 2156
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by Lardo Boffin » Thu Feb 13, 2020 9:11 am

Any chance of a beeb disc image please? Chances of me typing that lot in correctly are slim at best!
Adventure Language on GitHub
Atom, issue 5
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA

User avatar
daveejhitchins
Posts: 5847
Joined: Wed Jun 13, 2012 6:23 pm
Location: Newton Aycliffe, County Durham
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by daveejhitchins » Thu Feb 13, 2020 9:13 am

=D> =D> =D> =D>

Excellent . . . I packed it for you and saved 3 6 bytes - still works . . . :lol:

Dave H :D

Edit: Save another 3 :D
Last edited by daveejhitchins on Thu Feb 13, 2020 10:37 am, edited 1 time in total.

User avatar
daveejhitchins
Posts: 5847
Joined: Wed Jun 13, 2012 6:23 pm
Location: Newton Aycliffe, County Durham
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by daveejhitchins » Thu Feb 13, 2020 9:14 am

Lardo Boffin wrote:
Thu Feb 13, 2020 9:11 am
Any chance of a beeb disc image please? Chances of me typing that lot in correctly are slim at best!
Copy it - paste it into one of the emulators (BeebEm supports that) - save it to SSD

Dave H :D

User avatar
0xC0DE
Posts: 671
Joined: Tue Mar 19, 2019 7:52 pm
Location: The Netherlands
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by 0xC0DE » Thu Feb 13, 2020 9:45 am

Lardo Boffin wrote:
Thu Feb 13, 2020 9:11 am
Any chance of a beeb disc image please? Chances of me typing that lot in correctly are slim at best!
Added to original post for your convenience!
0xC0DE
"I program my home computer / Beam myself into the future"
:arrow: Follow me on Twitter
:arrow: Visit my YouTube channel featuring my demos for Acorn Electron and BBC Micro

User avatar
0xC0DE
Posts: 671
Joined: Tue Mar 19, 2019 7:52 pm
Location: The Netherlands
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by 0xC0DE » Thu Feb 13, 2020 9:45 am

daveejhitchins wrote:
Thu Feb 13, 2020 9:13 am
=D> =D> =D> =D>

Excellent . . . I packed it for you and saved 3 bytes - still works . . . :lol:

Dave H :D
Think of all the extra features I could add! :mrgreen:
0xC0DE
"I program my home computer / Beam myself into the future"
:arrow: Follow me on Twitter
:arrow: Visit my YouTube channel featuring my demos for Acorn Electron and BBC Micro

User avatar
Lardo Boffin
Posts: 2156
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by Lardo Boffin » Thu Feb 13, 2020 10:02 am

0xC0DE wrote:
Thu Feb 13, 2020 9:45 am
Lardo Boffin wrote:
Thu Feb 13, 2020 9:11 am
Any chance of a beeb disc image please? Chances of me typing that lot in correctly are slim at best!
Added to original post for your convenience!
Thanks! Don’t tend to use emulators much.
Adventure Language on GitHub
Atom, issue 5
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA

User avatar
barbarossa69
Posts: 163
Joined: Mon Aug 14, 2017 1:12 pm
Location: London
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by barbarossa69 » Thu Feb 13, 2020 10:04 am

Brilliant!
For anyone who doesn't know they codes (like me!), the keys are Z, X, K and M ...

User avatar
0xC0DE
Posts: 671
Joined: Tue Mar 19, 2019 7:52 pm
Location: The Netherlands
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by 0xC0DE » Thu Feb 13, 2020 10:38 am

barbarossa69 wrote:
Thu Feb 13, 2020 10:04 am
Brilliant!
For anyone who doesn't know they codes (like me!), the keys are Z, X, K and M ...
Thanks! And yeah I should have mentioned those keys of course.... whoops
0xC0DE
"I program my home computer / Beam myself into the future"
:arrow: Follow me on Twitter
:arrow: Visit my YouTube channel featuring my demos for Acorn Electron and BBC Micro

User avatar
lurkio
Posts: 2853
Joined: Wed Apr 10, 2013 12:30 am
Location: Doomawangara
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by lurkio » Thu Feb 13, 2020 11:13 am

0xC0DE wrote:
Wed Feb 12, 2020 10:57 pm
Meet @-man, a Pacman look alike.
In only 10 lines of BBC BASIC
Great but mindboggling! =D> =D> =D>

Here's a URL for in-browser play if you need it. (You might have to click once to kickstart sound.):
:idea:

User avatar
0xC0DE
Posts: 671
Joined: Tue Mar 19, 2019 7:52 pm
Location: The Netherlands
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by 0xC0DE » Thu Feb 13, 2020 11:52 am

lurkio wrote:
Thu Feb 13, 2020 11:13 am
0xC0DE wrote:
Wed Feb 12, 2020 10:57 pm
Meet @-man, a Pacman look alike.
In only 10 lines of BBC BASIC
Great but mindboggling! =D> =D> =D>

Here's a URL for in-browser play if you need it. (You might have to click once to kickstart sound.):
:idea:
Great, thanks! I couldn't get it to work with jsbeeb! tried from google drive, github, etc.
0xC0DE
"I program my home computer / Beam myself into the future"
:arrow: Follow me on Twitter
:arrow: Visit my YouTube channel featuring my demos for Acorn Electron and BBC Micro

User avatar
lurkio
Posts: 2853
Joined: Wed Apr 10, 2013 12:30 am
Location: Doomawangara
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by lurkio » Thu Feb 13, 2020 12:29 pm

0xC0DE wrote:
Thu Feb 13, 2020 11:52 am
I couldn't get it to work with jsbeeb! tried from google drive, github, etc.
You should have tried Dropbox! It's something to do with CORS, apparently. Dropbox has enabled CORS. So you can link to .SSDs on Dropbox from JSBeeb if you do some mild URL-wrangling. (Change "www" to "dl", and change "dropbox" to "dropboxusercontent".)

:idea:

User avatar
Lardo Boffin
Posts: 2156
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by Lardo Boffin » Thu Feb 13, 2020 12:39 pm

Impressive stuff!

How large was the program before you crunched it?
Adventure Language on GitHub
Atom, issue 5
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA

User avatar
0xC0DE
Posts: 671
Joined: Tue Mar 19, 2019 7:52 pm
Location: The Netherlands
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by 0xC0DE » Thu Feb 13, 2020 12:53 pm

Lardo Boffin wrote:
Thu Feb 13, 2020 12:39 pm
Impressive stuff!

How large was the program before you crunched it?
Thanks! Actually, I didn't crunch anything, I just wrote it this way (gradually of course) :mrgreen:
0xC0DE
"I program my home computer / Beam myself into the future"
:arrow: Follow me on Twitter
:arrow: Visit my YouTube channel featuring my demos for Acorn Electron and BBC Micro

User avatar
BigEd
Posts: 3347
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by BigEd » Thu Feb 13, 2020 12:56 pm

Scored 843 but I think this might be a game of patience and endurance.

User avatar
0xC0DE
Posts: 671
Joined: Tue Mar 19, 2019 7:52 pm
Location: The Netherlands
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by 0xC0DE » Thu Feb 13, 2020 1:08 pm

BigEd wrote:
Thu Feb 13, 2020 12:56 pm
Scored 843 but I think this might be a game of patience and endurance.
Well done!
0xC0DE
"I program my home computer / Beam myself into the future"
:arrow: Follow me on Twitter
:arrow: Visit my YouTube channel featuring my demos for Acorn Electron and BBC Micro

User avatar
Richard Russell
Posts: 1660
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by Richard Russell » Thu Feb 13, 2020 2:28 pm

0xC0DE wrote:
Wed Feb 12, 2020 10:57 pm
Meet @-man, a Pacman look alike.
I appreciate that it's intended only for a Beeb or Electron but it looks as though it would work on other versions of BBC BASIC if it included something to slow it down to a usable speed. Is there somewhere that an INKEY() delay could be added to achieve that?

User avatar
0xC0DE
Posts: 671
Joined: Tue Mar 19, 2019 7:52 pm
Location: The Netherlands
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by 0xC0DE » Thu Feb 13, 2020 2:32 pm

Richard Russell wrote:
Thu Feb 13, 2020 2:28 pm
0xC0DE wrote:
Wed Feb 12, 2020 10:57 pm
Meet @-man, a Pacman look alike.
I appreciate that it's intended only for a Beeb or Electron but it looks as though it would work on other versions of BBC BASIC if it included something to slow it down to a usable speed. Is there somewhere that an INKEY() delay could be added to achieve that?
Would *FX19 do?

Edit: never mind, I read it's not supported.
0xC0DE
"I program my home computer / Beam myself into the future"
:arrow: Follow me on Twitter
:arrow: Visit my YouTube channel featuring my demos for Acorn Electron and BBC Micro

User avatar
Richard Russell
Posts: 1660
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by Richard Russell » Thu Feb 13, 2020 2:49 pm

0xC0DE wrote:
Thu Feb 13, 2020 2:32 pm
Would *FX19 do?
Would that be enough delay? I could use an equivalent (e.g. WAIT or *REFRESH in those BASICs that support them) if so. Where should I put it?

User avatar
0xC0DE
Posts: 671
Joined: Tue Mar 19, 2019 7:52 pm
Location: The Netherlands
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by 0xC0DE » Thu Feb 13, 2020 2:54 pm

Richard Russell wrote:
Thu Feb 13, 2020 2:49 pm
0xC0DE wrote:
Thu Feb 13, 2020 2:32 pm
Would *FX19 do?
Would that be enough delay? I could use an equivalent (e.g. WAIT or *REFRESH in those BASICs that support them) if so. Where should I put it?
I have no way to test this. But here's my best guess. I added WAIT at 2 different places (I aim to keep each line max 120 chars). Choose either (or both!) and see what happens :mrgreen:

Code: Select all


0MO.6:V.28,6,24,32,2:DIMF(26,20),C 4,G 20:H=0:S=0:F$="9069041190112714413111531821316129043111214113141411413130":V=0
1!C=&232E20:i=0:v=1:F.y=0TO10:F.x=0TO13:i=i-(v=1):v=v-1-(v=1)*VA.MI.F$,i,1):u=v=0:IFV=0L=3:K=1:H=-(S>H)*S-(S<=H)*H:S=0
2c=1+(1A.i):s=26-x:t=20-y:F(x,y)=c:F(s,y)=c:F(x,t)=c:F(s,t)=c:x=x+u:v=v-u:N.,:CLS:F.y=0TO20:F.x=0TO26:V.C?F(x,y):N.,:P=0
3F(1,1)=0:V.23,1,0;0;0;0;:X=1:Y=1:G!4=&1301:G!8=&119:G!12=&1319:G!16=&707:IFL=0SO.1,-10,150,5:SO.1,-10,99,5:V=0:G.1
4WAIT:P.TAB(0,22)"0xC0DE:@-man ";L;" ";S;" (";H;")";:D=INKEY-98-INKEY-67:E=(D=0)*(INKEY-102-INKEY-71):X=X-D*(F(X+D,Y)<2)
5V=31:Y=Y-E*(F(X,Y+E)<2):V.V,X,Y,64:s=F(X,Y):SO.1,-10,128,s:S=S+s:P=P+s:IFP=281K=K+1+(K=4):L=L+1:SO.1,-10,200,10:G.1
6F(X,Y)=0:F.i=1TOK:A=G+4*i:g=?A:h=A?1:q=A?2:r=A?3:?G=(F(g,h-1)<2)*((r=255)+(r=0)):IF(D ORE)V.V,X-D,Y-E,C?F(X-D,Y-E)
7G?1=(F(g+1,h)<2)*((q=1)+(q=0)):G?2=(F(g,h+1)<2)*((r=1)+(r=0)):G?3=(F(g-1,h)<2)*((q=255)+(q=0)):WAIT:IFg=X A.h=Y:G.9
8REP.I=RND(4)-1:U.G?I:V.V,g,h,C?F(g,h):A?2=(1A.I)+2*(I=3):g=g+A?2:A?3=(1A.(I+1))+2*(I=0):h=h+A?3:V.V,g,h,96:?A=g:A?1=h
9IFg=X A.h=Y i=K:N.:L=L-1:SO.0,-10,6,10:V.V,X,Y,C?F(X,Y):F.i=1TOK:A=G+4*i:V.V,?A,A?1,C?F(?A,A?1):N.:G.3EL.N.:G.4

0xC0DE
"I program my home computer / Beam myself into the future"
:arrow: Follow me on Twitter
:arrow: Visit my YouTube channel featuring my demos for Acorn Electron and BBC Micro

User avatar
Richard Russell
Posts: 1660
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by Richard Russell » Thu Feb 13, 2020 3:11 pm

0xC0DE wrote:
Thu Feb 13, 2020 2:54 pm
I added WAIT at 2 different places (I aim to keep each line max 120 chars).
I can work with that, thanks. Using INKEY for a delay would be more universally compatible, and has the valuable side-effect of stopping the keyboard buffer filling (which can cause an annoying beep on some systems) but admittedly it is longer so might break your limit.

User avatar
0xC0DE
Posts: 671
Joined: Tue Mar 19, 2019 7:52 pm
Location: The Netherlands
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by 0xC0DE » Thu Feb 13, 2020 3:16 pm

Richard Russell wrote:
Thu Feb 13, 2020 3:11 pm
0xC0DE wrote:
Thu Feb 13, 2020 2:54 pm
I added WAIT at 2 different places (I aim to keep each line max 120 chars).
I can work with that, thanks. Using INKEY for a delay would be more universally compatible, and has the valuable side-effect of stopping the keyboard buffer filling (which can cause an annoying beep on some systems) but admittedly it is longer so might break your limit.
But doesn't INKEY(<delay in csecs>) return as soon as a key is pressed?
0xC0DE
"I program my home computer / Beam myself into the future"
:arrow: Follow me on Twitter
:arrow: Visit my YouTube channel featuring my demos for Acorn Electron and BBC Micro

User avatar
Richard Russell
Posts: 1660
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by Richard Russell » Thu Feb 13, 2020 3:28 pm

0xC0DE wrote:
Thu Feb 13, 2020 3:16 pm
But doesn't INKEY(<delay in csecs>) return as soon as a key is pressed?
Yes, but often the effect isn't that noticeable unless you are really hammering the keys, or hold them down long enough for the auto-repeat to kick in. Perhaps your game would be adversely impacted, I don't know. It's a shame that BBC BASIC doesn't universally support a delay statement (in my dialects WAIT has been extended to take a parameter for precisely that purpose) but we're stuck with what we've got.

User avatar
BigEd
Posts: 3347
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by BigEd » Thu Feb 13, 2020 3:57 pm

(Autorepeat can be disabled, I think?)

User avatar
Richard Russell
Posts: 1660
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by Richard Russell » Thu Feb 13, 2020 5:52 pm

BigEd wrote:
Thu Feb 13, 2020 3:57 pm
(Autorepeat can be disabled, I think?)
That's not guaranteed, in a cross-platform context (which is when the delay is needed). There's also the issue that the keyboard may be shared between multiple applications running in different windows, and you're unlikely to be able to disable autorepeat for just one of them. So it's better to assume it can't be disabled.

User avatar
SimonSideburns
Posts: 554
Joined: Mon Aug 26, 2013 9:09 pm
Location: Purbrook, Hampshire
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by SimonSideburns » Fri Feb 14, 2020 10:45 pm

I gave up playing at 3091 score after I don't know how many levels. I was still in-game but my fingers were cramping.
High score (@-Man).png
Just remember kids, Beeb spelled backwards is Beeb!

dominicbeesley
Posts: 1118
Joined: Tue Apr 30, 2013 12:16 pm
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by dominicbeesley » Fri Feb 14, 2020 10:51 pm

Bravo!

User avatar
0xC0DE
Posts: 671
Joined: Tue Mar 19, 2019 7:52 pm
Location: The Netherlands
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by 0xC0DE » Sat Feb 15, 2020 11:17 am

SimonSideburns wrote:
Fri Feb 14, 2020 10:45 pm
I gave up playing at 3091 score after I don't know how many levels. I was still in-game but my fingers were cramping.

High score (@-Man).png
Excellent Simon! It does get a bit tedious after a while doesn't it? :lol:
0xC0DE
"I program my home computer / Beam myself into the future"
:arrow: Follow me on Twitter
:arrow: Visit my YouTube channel featuring my demos for Acorn Electron and BBC Micro

User avatar
SimonSideburns
Posts: 554
Joined: Mon Aug 26, 2013 9:09 pm
Location: Purbrook, Hampshire
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by SimonSideburns » Sat Feb 15, 2020 10:30 pm

0xC0DE wrote:
Sat Feb 15, 2020 11:17 am
Excellent Simon! It does get a bit tedious after a while doesn't it? :lol:
Funnily enough, the first level where there is only one enemy is a bit too quick, but after that it slows down to a more manageable pace, and when you get all four enemies it is an ok speed, there are just more chances to get caught in the wrong place.

At one point an enemy (ghost?) walked right through me, and I managed to stay alive. I don't know how that happened.

All in all, though, it's a really fun game. Yes, I'm not sure if tedious is the word, but I just couldn't go on. I don't know how some game players can play a game for hours on end straight. Maybe when I was younger I could have done, but not nowadays.

I suppose the only way it could speed up further is to be run in MODE 7, as you're using ASCII characters anyway. I might have to try that now just to see how different it is.
Just remember kids, Beeb spelled backwards is Beeb!

User avatar
SimonSideburns
Posts: 554
Joined: Mon Aug 26, 2013 9:09 pm
Location: Purbrook, Hampshire
Contact:

Re: 10 line BBC BASIC game (@-man)

Post by SimonSideburns » Sat Feb 15, 2020 11:12 pm

I had another go in MODE 7, which I found easier to play as it was easier on the eyes, and achieved another high score. I had to stop again after playing for some time.
New High Score - @-man by 0xC0DE.png
Just remember kids, Beeb spelled backwards is Beeb!

Post Reply

Return to “miscellaneous new bbc and electron games”