20 Lines: Robovic

Discussion, Reviews & High-scores

Moderator: Moderators

IsaacKuo
Vic 20 Hobbyist
Posts: 147
Joined: Tue Aug 04, 2009 5:45 am

20 Lines: Robovic

Post by IsaacKuo »

Here's my Robotron style game. There are two "special" characters in line 1, {CLR} and {WHT}, so you'll have to change that after cut/paste.

The controls are:

Code: Select all

WER  UIO
S+F  J+L
XCV  M,.
The object is simply to kill as many robots as possible. Each game loop, one random robot moves, so they move faster when fewer are left! Complicating your life is that the robots relentlessly shoot at you; I added this to prevent simple "turtling" tactics from working.

Let me know if the game is still too easy...there may be some "trick" tactic that lets you easily wipe out the robots consistently.

Code: Select all

1 poke36879,8:?"{clr}{wht}":s=32:l=22:w=86:dimx(99):px=7910:bx=33333:mx=33333
2 fort=.tol:poke7680+t,w:poke8185-t,w:poke7723+t*l,w:poke8142-t*l,w:next
3 pc=28:dimc(23):c(1)=67:c(21)=78:c(22)=93:c(23)=77:gosub18
4 pokepx,s:pokebx,s:bx=bx+bv:ifpeek(bx)=wthenbx=33333:bv=.
5 pokebx,bc:px=px-pv*(peek(px+pv)=s):pokepx,pc
6 t=rnd(.)*n:v=int((px-2)/l)-int((x(t)-2)/l):v=sgn(v)*l+sgn(px-x(t)-v*l)
7 ifpeek(x(t))-xcthenn=n-1:x(t)=x(n):t=.:ifn=.thengosub18:t=.
8 ifmv=.thenmx=x(t):mv=v:mc=c(abs(v))
9 pokex(t),s:pokemx,s:mx=mx+mv:ifpeek(mx)=wthenmx=33333:mv=.
10 pokemx,mc:x(t)=x(t)-v*(peek(x(t)+v)<=s):pokex(t),xc
11 pokebx,s:bx=bx+bv:ifpeek(bx)=wthenbx=33333:bv=.
12 pokebx,bc:ifpeek(px)-pcthen?"you died on level";lv:inputa$:run
13 geta$:ifa$=""then4
14 v=((a$="u")-(a$="."))*23+((a$="i")-(a$=","))*l+((a$="o")-(a$="m"))*21
15 v=v+(a$="j")-(a$="l"):ifvthenpokebx,s:bx=px:bv=v:bc=c(abs(v)):goto4
16 pv=((a$="w")-(a$="v"))*23+((a$="e")-(a$="c"))*l+((a$="r")-(a$="x"))*21
17 pv=pv+(a$="s")-(a$="f"):goto4
18 lv=lv+1:n=5+(63andlv):xc=94:fort=.ton-1
19 x(t)=7680+int(rnd(.)*506):ifpeek(x(t))-sthen19
20 pokex(t),xc:next:pokepx,pc:return
Each game loop, there are five "moves". The player, enemy missile, and one random enemy move once. The player's bullet moves twice.

[edit: changed typo in line 16; an extra left parenthesis]
Last edited by IsaacKuo on Sat Aug 08, 2009 4:56 pm, edited 2 times in total.
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

Post by Jeff-20 »

Awww... give me a PRG. :(
High Scores, Links, and Jeff's Basic Games page.
IsaacKuo
Vic 20 Hobbyist
Posts: 147
Joined: Tue Aug 04, 2009 5:45 am

Post by IsaacKuo »

I don't seem to be able to save a PRG file...I have been able to save to a .gdx disk image, but I don't know how to extract anything from a .gdx image.
User avatar
Mike
Herr VC
Posts: 4843
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Code: Select all

?SYNTAX
 ERROR IN 16
READY.
█
IsaacKuo wrote:[edit: changed typo in line 16; an extra left parenthesis]
Here's the (corrected) conversion to robovic.prg.
Last edited by Mike on Sat Aug 08, 2009 5:04 pm, edited 1 time in total.
IsaacKuo
Vic 20 Hobbyist
Posts: 147
Joined: Tue Aug 04, 2009 5:45 am

Post by IsaacKuo »

Sorry about the typo! It's near then end of the line--change ...((a$="x"))*21 to ...(a$="x"))*21.
rhurst
Omega Star Commander
Posts: 1371
Joined: Thu Jan 31, 2008 2:12 pm
Website: https://robert.hurst-ri.us
Location: Providence, RI
Occupation: Tech & Innovation

Post by rhurst »

Effficient. Reminds me of a game we wrote on a VAX called DROIDS for serial terminals.

These kinds of BASIC programs that do not have any custom fonts, ML routines, etc. can be friendlier by soft-coding VIC screen locations, i.e., SP=PEEK(648)*256 as the screen page address, so memory expansion can stay in place to play this.

:idea: I'd like to see this modified so that the "next level" is painted first, then waits for my robot's first command/move, then enter "real-time" action loop.
Any technology distinguishable from magic is insufficiently advanced.
https://robert.hurst-ri.us/rob/retrocomputing
IsaacKuo
Vic 20 Hobbyist
Posts: 147
Joined: Tue Aug 04, 2009 5:45 am

Post by IsaacKuo »

Thanks! I never had a memory expansion, so I'm not familiar with dealing with them.

To make the game wait, the easiest modification would be to change the two instances of "gosub18" to "goto18" and add a geta$ loop to the end of line 20...Something like this:

Code: Select all

20 pokex(t),xc:next:pokepx,pc:fort=-1to0:geta$:t=a$="":next:goto14
Hmm...that does indeed make the game more playable. Great! It loses some of the oppressive sense of relentless assault, though...a matter of personal preference.

I have since realized the user input routine eats up too many lines. The code for an a%(255) lookup array is more compact, although it gobbles up a lot of memory. I'm using a lookup array for my current 20-liner, a simplistic roguelike with D.R.O.D. gameplay.
IsaacKuo
Vic 20 Hobbyist
Posts: 147
Joined: Tue Aug 04, 2009 5:45 am

Post by IsaacKuo »

Another mod to make the game easier:

Code: Select all

8 ifmv=.theniflv>9thenmx=x(t):mv=v:mc=c(abs(v))
With this mod, the robots only shoot at you starting with level 10. This lets you hone your basic skills without the threat of enemy fire.
TarkaTOtter
Vic 20 Dabbler
Posts: 73
Joined: Mon Apr 23, 2007 3:57 pm

robovic

Post by TarkaTOtter »

Now this game I like.

But only once I included the above 2 mods.

Great code :D
User avatar
orion70
VICtalian
Posts: 4341
Joined: Thu Feb 02, 2006 4:45 am
Location: Piacenza, Italy
Occupation: Biologist

Post by orion70 »

Congrats on your 20 line game. Great result for such a short code. The programming skills of you VIC guys always impress me :D .

Keep up the quality of this contest with new works!
User avatar
Mayhem
High Bidder
Posts: 3027
Joined: Mon May 24, 2004 7:03 am
Website: http://www.mayhem64.co.uk
Location: London

Post by Mayhem »

Anyone got a PRG with the latest changes to it? :)
Lie with passion and be forever damned...
TarkaTOtter
Vic 20 Dabbler
Posts: 73
Joined: Mon Apr 23, 2007 3:57 pm

Robovic Disk

Post by TarkaTOtter »

Hi,

this is a disk image with robovic.prg with both mods already loaded

http://www.megaupload.com/?d=X3M9YJEF
IsaacKuo
Vic 20 Hobbyist
Posts: 147
Joined: Tue Aug 04, 2009 5:45 am

Post by IsaacKuo »

Thanks for the compliments and comments! I really appreciate it.

I've made another improvement, changing the enemies with each level. Even though it's only a graphics change, it's a really important touch. It feels a lot better getting to the next level when the enemies look different.

Here's the prg: http://members.cox.net/mechdan/vic/robovic.prg Good luck getting past level 4! :twisted:

The modified lines are 17 and 18:

Code: Select all

17 pv=pv+(a$="s")-(a$="f"):goto4:data94,88,65,90,87,88,38,83,.
18 lv=lv+1:n=5+(63andlv):readxc:fort=.ton-1:ifxc=.thenrestore:readxc
The source code now looks like this:

Code: Select all

1 poke36879,8:?"{clr}{wht}":s=32:l=22:w=86:dimx(99):px=7910:bx=33333:mx=33333
2 fort=.tol:poke7680+t,w:poke8185-t,w:poke7723+t*l,w:poke8142-t*l,w:next
3 pc=28:dimc(23):c(1)=67:c(21)=78:c(22)=93:c(23)=77:goto18
4 pokepx,s:pokebx,s:bx=bx+bv:ifpeek(bx)=wthenbx=33333:bv=.
5 pokebx,bc:px=px-pv*(peek(px+pv)=s):pokepx,pc
6 t=rnd(.)*n:v=int((px-2)/l)-int((x(t)-2)/l):v=sgn(v)*l+sgn(px-x(t)-v*l)
7 ifpeek(x(t))-xcthenn=n-1:x(t)=x(n):t=.:ifn=.then18
8 ifmv=.theniflv>3thenmx=x(t):mv=v:mc=c(abs(v))
9 pokex(t),s:pokemx,s:mx=mx+mv:ifpeek(mx)=wthenmx=33333:mv=.
10 pokemx,mc:x(t)=x(t)-v*(peek(x(t)+v)<=s):pokex(t),xc
11 pokebx,s:bx=bx+bv:ifpeek(bx)=wthenbx=33333:bv=.
12 pokebx,bc:ifpeek(px)-pcthen?"you died on level";lv:inputa$:run
13 geta$:ifa$=""then4
14 v=((a$="u")-(a$="."))*23+((a$="i")-(a$=","))*l+((a$="o")-(a$="m"))*21
15 v=v+(a$="j")-(a$="l"):ifvthenpokebx,s:bx=px:bv=v:bc=c(abs(v)):goto4
16 pv=((a$="w")-(a$="v"))*23+((a$="e")-(a$="c"))*l+((a$="r")-(a$="x"))*21
17 pv=pv+(a$="s")-(a$="f"):goto4:data94,88,65,90,87,88,38,83,.
18 lv=lv+1:n=5+(63andlv):readxc:fort=.ton-1:ifxc=.thenrestore:readxc
19 x(t)=7680+int(rnd(.)*506):ifpeek(x(t))-sthen19
20 pokex(t),xc:next:pokepx,pc:fort=-1to0:geta$:t=a$="":next:goto14
This leaves only one "short" line left, line 13. If I rewrote things a bit, I could tighten up the input routine and perhaps squeeze in a custom bitmap character for the player...
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

Not tested, but can't you rewrite line 13 to get rid of the IF?

13 geta$:onabs(a$="")goto4

I'm not sure though if ON .. GOTO will allow other statements on the same row.
Anders Carlsson

Image Image Image Image Image
IsaacKuo
Vic 20 Hobbyist
Posts: 147
Joined: Tue Aug 04, 2009 5:45 am

Post by IsaacKuo »

Slick! I just tested, and you can place more statements after an ON ... GOTO. That sure opens up more possibilities.

You can tighten it up slightly by replacing ABS(A$="") with -(A$=""). Another option if the opposite logic is requires is to use ONLEN(A$)GOTO{keyroutine}.
Post Reply