My BASIC Roguelike

Basic and Machine Language

Moderator: Moderators

Post Reply
edinky
Vic 20 Newbie
Posts: 18
Joined: Sat Apr 07, 2018 10:34 am

My BASIC Roguelike

Post by edinky »

Hi there,

I'm working on a rudimentary roguelike game and thought i would share what i've done so far with this community.

It's a realtime strategy game in which the user needs to manage resources in order to grow a planetary colony and explore the planet before moving onto the the next planet. My aim is to make something super responsive and a little addictive, while allowing an interesting narrative emerge out of the gameplay. I have a playable version except for a few bugs and unfinished "launch" and "power managment" sections.

Eventually I want to code this completely in assembly in order to fit in more detail, graphics and sound. I currently have a BASIC framework of the game.

If you try running the BASIC code, note that you might need to press the keys a couple of times before the program registers it.
I think this is because my game loop is so long that it misses it, even though I try to capture the key press with peek 197 a few times during the loop. I need to buffer any input of the key somehow during the loop, and need to figure out how to do that as I think peek 197 just looks for if a key is pressed down at that moment?

So, my immediate tasks are in order of priority:

1. Capture key presses properly.
2. Create asm routines to draw the guages as i think this will capture the most time from game loop.
3. ASM routines for background processes i.e building things and calculating drain on vitals
4. once planet colonised, add series of planets as progressing "levels" using Fibonacci sequence
5. add complexity to random events and exploration
6. add graphics "monitor" which will display growing base, exploration animation and spaceship launch animation

I've been learning assembly, and I think I'm just about ready, and learning the CBM prg IDE however I'm stuck on CBM prg for a simple hello world tutorial! I've attached that code too, and cannot seem to see what is going wrong?

If anyone here has any feedback on the project, I would love your input.

Code: Select all

10 rem COLONY: A realtime roguelike game for the vic 20 8k+
20 rem by eoghan kidney
30 rem (c)2019
100 gosub 10000:goto 810
105 rem returning from exploration
110 if xp=1 OR xc=1 then return
120 on sc goto 1140,2005,2105,2215,2225
810 ?"{clear}":POKE 36878,10: poke 36879,10: rem start game with a sound
820 FOR T=210 TO 254
830 POKE 36874,T
850 FOR D=1 TO 2
860 NEXT D:NEXT T
870 POKE 36878,0
880 POKE 36874,0
900   rem (d)ay tp:temp (c)olonists (h)ab (l)food (lc)launch count (ox)ygen (fu)el
905   rem (w)ater (w)water ice (p)ower (s)ci-labs (r)overs (m)aterials (te)ch(micros) dr(o)nes
910   rem sol(a)r (b)atteries (g)ardens (f)orge sabat(i)er or(e) (mm)ars mapped
1000   D=234: tp=-20: C=1132: lc=0: X = RND(-TI)   :ox=50: fu=50   : fl=0
1002   H=40+INT(RND(1)*60): L=40+INT(RND(1)*60): W=40+INT(RND(1)*60): P=40+INT(RND(1)*60): S=3: R=1
1005   M=34: te=12: O=3: A=23: B=32: G=10: F=4: I=5: e=0: mm=1
1006   hr=1:lr=1:wr=1:pt=-2:cr=25: rem hab rate, food rate, water, powerloss rate, colonist
1008   rem pl = hab power ps = food power pu = water power q=daytime mt=maxtime la=launchbool?
1010   pl=25:ps=25:pu=50:sc=1:uc=200:q=0:mt=100:la=0:pw=1:dn$="day": rem pw=power state dn=day/night mt=time rate(increase 4 difficulty)
1015   n$ = "welcome commander":pz=p: rem n$ = newsfeed
1025 gosub 1138

1050 rem update loop
1060 kb=peek(197): ?"{home}{space*3}{left*3}";kb;"  ";q: rem buffer input state
1065 gosub 1125: gosub 1090: rem buffer vitals = power/water/food/habitat
1070 gosub 2500 : rem process changes
1080 gosub 1090: gosub 2600: gosub 1090: rem check for input, BG tasks, input check
1081 gosub 1110: rem update vital graph if changed
1083 gosub 1090
1085 goto 1050
1090 kc = peek(197):if kb<>kc then POKE36878,15: POKE36876,230: POKE36876,0: gosub 2260: rem key was pressed, goto input
1100 return
1110 if int(p)<>qp OR int(h)<>qh OR int(w)<>qw OR int(l)<>ql then gosub 2130
1120 return
1125 qp=int(p):qh=int(h):qw=int(w):ql=int(l): return

1138 sc=1: rem 1. monitor
1140   print"{clear}{white}{141}  m a r s gov.81{141}  systems online{141}{141} "C*10"colonists "
1150   print"{141}  i:inventory{141}{141}  a:activities"
1160   gosub 2130
1180 return

1999 rem /2.activities menu
2000 sc=2
2005   print"{clear}{white}{141}activities{141}{141}{reverse on}1{reverse off} mine for ore & ice{141}{reverse on}2{reverse off} repair habitat{141}{reverse on}3{reverse off} process ore{141}{reverse on}4{reverse off} harvest food{141}"
2010   print"{reverse on}5{reverse off} launch{141}{reverse on}6{reverse off} build{141}{reverse on}7{reverse off} divert power{141}{reverse on}8{reverse off} monitor{141}{reverse on}{blue}9{reverse off} explore{white}{141}"
2020   gosub 2130: return



2100 sc=3: rem /3. build menu
2105 print"{clear} resin";TAB(15);"{cm +}";m;"{141} tech";TAB(15);"X";te;"{141}"
2106 print"    {purple}cost";TAB(15);"{cm +}   X"
2107 for zx=0 to 8: print"{white}{141}{reverse on}"zx+1"{reverse off}"b$(zx+10);TAB(14);"{purple}"b%(zx*2);TAB(18);b%((zx*2)+1)"{white}";
2110 next zx
2115 print"{141}"

2120 rem display newsfeed
2130 print"{home}{down*15}{yellow}habi ";:na=qh:gosub2150:?"{141}{green}food ";:na=ql:gosub2150:?"{141}{blue}water";:na=qw:gosub2150:?"{141}{cyan}power";:na=qp:gosub2150
2135 print"{141}{white}"dn$;D"{141}                    {left*20}{red}"n$"{white}"
2138 if sc=4 then ?"{home}{down*3}{right*7}fff";fl
2140 return
2150 t=INT(na/8):tb=INT(((na/8)-t)*8):?"            {left*12}";
2160 for xq=1 to t:?"{reverse on}{space}{reverse off}";:next xq:?ba$(tb);:return

2210 rem /4. power menu
2215   sc=4
2216   print"{clear}{141}sabatier plant{141}{141}";"fuel:";fl;"{141}produce:{141}1.rocket fuel:"fu"%{141}2.oxygen:"ox"%"
2217   print"{141}hit 1 to change{141}power state"pw
2218 gosub 2130
2219 return

2220 rem /5. inventory
2225  ?"{clear}{141} materials";TAB(15);"{cm +}";m;"{141} tech";TAB(16);"X";t;"{141}"
2230 for jj=0 to 8:?b$(10+jj);tab(16);ws(jj*4): next jj
2240 gosub 2130: return

2260 rem /intepret input
2275   a$=str$(sc)+str$(kc):rem combine sc number and input
2280   if a$=" 1 0" then gosub 2000
2282   if a$=" 2 0" then gosub 3000
2285   if a$=" 2 56" then gosub 3300
2288   if a$=" 2 1" then gosub 3600
2290   if a$=" 2 57" then gosub 3700
2300   if a$=" 2 2" then gosub 4000
2310   if a$=" 2 58" then gosub 2100
2320   if a$=" 2 3" then gosub 2210
2325   if a$=" 2 59" then gosub 1138
2328   if a$=" 2 4" then gosub 4200
2338   if a$=" 3 0" then bm = 0: gosub 5000
2348   if a$=" 3 56" then bm = 1: gosub 5000
2358   if a$=" 3 1" then bm = 2: gosub 5000
2364   if a$=" 3 57" then bm = 3: gosub 5000
2367   if a$=" 3 2" then bm = 4: gosub 5000
2368   if a$=" 3 58" then bm = 5: gosub 5000
2370   if a$=" 3 3" then bm = 6: gosub 5000
2380   if a$=" 3 59" then bm = 7: gosub 5000
2390   if a$=" 3 4" then bm = 8: gosub 5000
2395   if a$=" 4 0" then gosub 5500
2400   if kc=17 then gosub 2000
2410   if kc=12 then gosub 2220
2490 return

2500 rem process changes
2510  q=q+1: if q>mt then gosub 2530
2511  rem ?"{home}{right*16}"q:rem daytimer
2512   if dn$="day" AND q>(mt/2) then dn$="night": poke 36879,8: gosub 2120
2514   if dn$="night" AND q<(mt/2) then dn$="day" : poke 36879,10: gosub 2120
2515   if h<1 OR l<1 OR w<1 OR p<1 then gosub 11000: rem death by zero  
2518   ifRND(1)<.001 then gosub 9000: rem check for random event
2520   if p>100 then p=100: gosub 2120
2521   if h>100 then h=100: gosub 2120
2522   if l>100 then l=100: gosub 2120
2523   if w>100 then w=100: gosub 2120
2526 pz=(pz+(pt/50)):h=h-ABS(hr*(pl/(250-ox))):w=w-ABS(wr*(pu/250)):l=l-ABS(lr*(ps/250)): rem update monitors INT(pt/500): CHECK INT LOGIC!!!!
2527 fl=fl+(1*(fu/25))
2529 return

2530 rem add a day
2540   tp=tp+INT(RND(1)*6)-3: rem change temp
2544   c=(c-cr)+INT(RND(1)*50): rem kill and birth colonists
2545   d=d+1: q=0 :p=p+INT((a+b)*0.03)
2552    if h<10 OR l<10 OR w<10 OR p<10 then n$="vitals low!":gosub 2120 
2560 return

2600 rem process background activity i.e building things
2610 for x=0 to 7:xq=x*4: rem cycle through all items to check
2620 if ws(xq+3)=1 then ws(xq+2)=(ws(xq+2))-1:gosub2700: rem if item is building, remove time ledt
2630 nextx
2640 return
2700 if ws(xq+2)=0 AND ws(xq+3)=1 then ws(xq)=ws(xq)+1:ws(xq+3)=0: gosub 2800
2710 return
2800 n$="built "+b$(10+x):gosub 7000
2810 gosub 120:return
 
3000 rem mine
3005 if r<2 then n$="2 rovers needed": goto 3018
3010   q=q+10:w=w-2:p=p-5:x=INT(RND(1)*6)
3012   if RND(1)<0.5 then e=e+x:n$=str$(x)+"t ore mined":goto 3018
3015   n$=str$(x)+"t ice mined":w=w+(x*10)
3018   gosub 2120
3020 return

3300 rem repair
3310    q=q+20:w=w-2:p=p-5:x=INT(RND(1)*10):h=h+x:ifh>100thenh=100
3320    n$="hab now"+str$(h)+"%"
3325 gosub 2120
3330 return

3600 rem process
3605    if e<1 then goto 3645
3610    q=q+10:w=w-3:p=p-5:m=m+INT(e/2):e=0
3620    n$=str$(m)+"x new resin"
3625 gosub 2120
3635 return
3645 n$="no ore to process":goto 3625

3700 rem harvest
3710   q=q+10:w=w-5:x=INT(RND(1)*10):l=l+x
3715   n$="food now"+str$(l)+"%"
3718   gosub 2120
3720 return

4000 rem launch
4010 if la=0 then GOTO 4180
4015 if p>50 then n$="need more power"
4020 n$="launching..."
4030 gosub 7000: gosub 120
4170 return
4180 n$="no ship!":gosub 2120
4190 return

4200 rem explore
4201 tt=mt: mt=20: xp=0:xc=1: fx=1:sx=15
4202 poke 36878,10:poke36877,180
4205 ex$="setting out"
4210 ?"{clear}exploring...{141}{141}"mm"% mars mapped{141}{141}";ex$;"!{return}{return}press any key to{return}return to base"
4225 b=peek(197)
4228 gosub 1125
4230 gosub 2500
4235 gosub 2120
4236 gosub 4500: rem do sfx
4238 if xp=1 then xp=0: goto 4202
4240 if rnd(1)<0.05 then mm=mm+0.2: on INT(RND(1)*10) goto 4310, 4320, 4330, 4340, 4350, 4360, 4370, 4380, 4390, 4400
4250 a=peek(197)
4255 if a<>b then mt=tt:gosub 2000:poke 36877,0: xp=0: xc=0: return 
4265 gosub 1110
4300 goto 4225
4310 ex$="found water": w=w+10: goto 4210
4320 ex$="colony established": c=c+100: goto 4210
4330 ex$="beautiful caves": goto 4210
4340 ex$="ancient structure": goto 4210
4350 ex$="invasive species": c=c-20: goto 4210
4360 ex$="curious dust": goto 4210
4370 ex$="more rocks": goto 4210
4380 ex$="mountain": goto 4210
4390 ex$="endless plain": goto 4210
4400 ex$="unpassable ridge": goto 4210
4500 if fx=0 then sx=sx+1
4510 if fx=1 then sx=sx-1
4520 if sx = 13 and fx=0 then fx=1
4530 if sx = 4 and fx=1 then fx=0
4540 poke 36878, sx
4550 return

5000 rem building (bm= item to build)
5015 mc=b%(bm*2):tc=b%((bm*2)+1)
5018 if ws((bm*4)+3)=1 then n$="in progress":goto 5034
5020 if mc>m AND tc>t THEN n$="under resourced"
5025 if mc>m THEN n$="need more mat."
5028 if tc>te THEN n$="need more tech"
5029 if mc<=m AND tc<=te THEN gosub 5040: rem if enough resources, then build
5034 gosub 2120: return
5040 n$="building "+b$(10+bm)+str$(bm)
5050 m=m-mc: te=te-tc
5051 gosub 5200: REM GO TO EXPERIMENTAL BUILDING
5052 ON bm+1 GOSUB 5070,5080,5090,5100,5110,5120,5130,5140,5150: rem build the thing
5055 gosub 2520: gosub 2100
5060 return
5070 o=o+1: return
5080 r=r+1: return
5090 a=a+1: return
5100 b=b+1: return
5110 g=g+1: return
5120 f=f+1: return
5130 i=i+1: return
5140 te=te+1: return
5150 H=H+20: return
5200 ws((bm*4)+1)=ws((bm*4)+1)+1
5205 ws((bm*4)+3)=1
5210 ws((bm*4)+2)=20: rem timeTaken 20 for all objects (temp)
5220 return

5500 rem sabatier (unfinished)
5510 pw=pw+1
5520 if pw>5 then pw=1
5530 if pw=1 then fu=100:ox=0: hr=hr+2
5540 if pw=2 then fu=75:ox=25: hr=hr+1
5550 if pw=3 then fu=25:ox=75
5560 if pw=4 then fu=0:ox=100: hr=hr-1 
5562 if pw=5 then fu=0:ox=0: hr=hr-2
5565 gosub 2210
5570 return 

6000 rem SFX for BAD
6010 ?"{clear}"
6060 FOR xx=15 TO 0 STEP -1
6070 gosub 6130: ? "{red}"n$
6080 NEXT
6090 POKE 36865,38: POKE 36864,12: POKE 36878,0
6100 POKE 36874,0: POKE 36875,0: POKE 36877,0
6105 poke 36879,10:  FOR mx=0 TO 1000: NEXT
6110 gosub 120: return 
6130 POKE 36878,xx: POKE 36877,200+xx*RND(1)
6140 POKE 36874,129: POKE 36875,190+xx
6150 POKE36865,38+4*(4*RND(l)-2)
6160 POKE36864,12+2*(2*RND(l)-2)
6170 IF xx=15 THEN POKE 36879,112: FOR mx=0 TO 100: NEXT
6180 POKE 36879,27
6190 return

7000 rem poke 36879,10:rem SFX for GOOD
7005 ?"{clear}"
7015 ? "{white}really "n$
7020 POKE36878,15
7030 FORfx=4TO0STEP-1:POKE36878,fx
7040 FORfy=1TO100:NEXT
7050 FORfz=220TO240:POKE36876,fz:NEXT:NEXT
7060 poke 36876,0
7070 poke 36878,0
7100 return

9000 rem random events
9010 x = INT(RND(1)*10)
9015 if x=0 then hr=hr+3: h=h-1: c=c-20: a=a-2: b=b-2
9025 if x=1 then wr=wr+3: g=g-1: cr=cr+20
9035 if x=2 then pt=pt+3
9045 if x=3 then pt=pt-1: c=c-5 
9055 if x=4 then wr=wr-3: c=c+100: cr=cr-20
9065 if x=5 then hr=hr-3: cr=cr-10
9075 if x=6 then c=c-20
9085 if x=7 then c=c-5: p=p-2: r=r-1
9095 if x=8 then c=c-20
9098 if x=9 AND la>1 then return
9102 if x=9 then m=m+20:w=w+20:t=t+20:c=c+100:la=la+1
9110 n$=b$(x)
9115 if x>5 then gosub 7000:goto 9120
9118 gosub 6000
9120 gosub110:q=q+1000:xp=1:return 

9999 end
10000 DATA "meteor hit!","disease!","dust storm!","riot","disappearances","rover crash!"
10010 DATA "med. discovery!","tech discovery!","celebration!","supply ship!"
10020 DATA "drone","rover","solar panels","batteries"
10030 DATA "growspace","forge","sab plant","tech","habitat"
10035 DIM b$(19)
10036 rem first 10 are random events, rest are buildable objects
10037 for x=0 to 18: read b$(x): next x
10038 rem below for each buildable item [(begin amount, material cost, tech cost),(),.]
10040 DATA 2,1,1,5,5,1,1,1,1,2,0,0,0,2,1,0,30,3,0,2,1,0,1,1
10045 DIM b%(23)
10050 for x=0 to 23: read b%(x): next x
10052 rem below for each buildable item [(number of, time remaining ,isBuilding?),(),.]
10055 DATA 3,0,0,0,0,0,0,0,23,0,0,0,32,0,0,0,10,0,0,0,4,0,0,0,5,0,0,0,12,0,0,0,2,0,0,0
10060 DIM ws(35)
10070 for x=0 to 35: read ws(x): NEXT X
10080 DIM ba$(7)
10085 rem below are characters for guages
10090 DATA " ","{cm g}","{cm h}","{cm j}","{cm k}","{reverse on}{cm l}{reverse off}","{reverse on}{cm n}{reverse off}","{reverse on}{cm m}{reverse off}"
10110 return

10500 rem end state
11000 poke 36877,0:?"{clear}the colony survived{141}"d-234"days of your{141}leadership."
11002 ?"yet without ";
11005 if p<1 then ? "power";
11006 if w<1 then ? "water";
11007 if l<1 then ? "food";
11008 if h<1 then ? "habitat"
11010 ?:?c*10;"perished"
11015 ?:?"{141}hit a key to try again"
11020 a=peek(197)
11025 if peek(197)<>a then clr: goto 100
11030 goto 11025

+++++++++++++++++++++++++++++++++++++++++++++++++++++
And here's the asm that i cant figure out why isnt working
+++++++++++++++++++++++++++++++++++++++++++++++++++++

Code: Select all

; 10 SYS (4864)

*=$1201

        BYTE    $0E, $12, $0A, $00, $9E, $20, $28,  $34, $38, $36, $34, $29, $00, $00, $00

*=$1300

start   LDX #$0
cycle   LDA hworld,X
        CMP #0
        BEQ exit
        JSR $FFD2
        INX
        JMP cycle
exit    RTS

hworld  text 'HELLO WORLD!',0
        byte 0
Forbidden64
Vic 20 Hobbyist
Posts: 146
Joined: Sun Feb 28, 2016 9:59 pm
Location: CA USA

Re: My BASIC Roguelike

Post by Forbidden64 »

I am going to test this game out later. I am no machine language expert, however, I did try out the code in a monitor.
The behavior is truly bizarre. However, I did just happen to see a working version of what this code is trying to do earlier today:

If you have a monitor cart, the routine in action is at $22A2 in this program:

http://s000.tinyupload.com/?file_id=189 ... 7647527036

Here is the abstracted routine:

Code: Select all

start   LDY #$0
cycle   LDA ABSL,Y
        JSR $FFD2
        INY
        CPY#$12
	BNE cycle
exit	RTS

This I confirmed works as expected.

As for his routine, I double checked to see if $FFD2 uses any other registers, and it doesn't. Any ML gurus out there see
what is wrong with it? It is not the shortest way to do it, but I can see why he would do it this way...he can have dynamic lengths of text and not
specify the length. On my computer, it spazzes out and changes the color to white, then breaks back into the monitor. The clearly defined text
which I put at 033C never gets printed even with an absolute,x load into the accumulator. Is this one of those weird 6502 bugs or did we both miss
something very crucial?
User avatar
vicist
Vic 20 Afficionado
Posts: 352
Joined: Tue Oct 09, 2012 5:26 am
Location: Sheffield, UK

Re: My BASIC Roguelike

Post by vicist »

The values that CBM Prg Studio outputs with text 'hello world!' are SCREEN POKE values.
$FFD2 outputs CHR$(x) values. You would have to use text "hello world!" (note the use of double quotes) for this to work properly.

Code: Select all

*=$1300

start   LDX #$0
cycle   LDA hworld,X
        CMP #0
        BEQ exit
        JSR $FFD2
        INX
        JMP cycle
exit    RTS

hworld  text "HELLO WORLD!",0
Forbidden64
Vic 20 Hobbyist
Posts: 146
Joined: Sun Feb 28, 2016 9:59 pm
Location: CA USA

Re: My BASIC Roguelike

Post by Forbidden64 »

Hey this game is actually really fun! I didn't mind the squirrely keys very much(you can just hold down the key).
This reminds me of outpost II for the PC, which is one of my all time favorites.

There are some things I can't seem to get going though. Max I was able to stay alive was 9 days(without cheating). Reason being power! It drains and drains. I built like 5 extra solar panels and it was still dropping. Then I died. basically because I couldn't get water or repair the habitat.

I eventually cheated and gave myself more power. I found if I gave myself too much, then the game wasn't a challenge anymore. Giving yourself int((a+b)*.03) isn't enough to stay alive beyond around 10 days. The yield is basically 1% units/day. Unless there is some strategy I am missing about how to manage the power? I easily would need that just to repair the habitat buildings. Let alone go mining etc.

I think this game could be sped up quite a bit without going into assembler at all. However, it would require a lot of structural changes.
nippur72
de Lagash
Posts: 574
Joined: Thu Sep 07, 2006 8:35 am

Re: My BASIC Roguelike

Post by nippur72 »

also, the "CMP #0" is not needed, because the Z flag is set after the "LDA hworld,X"

Code: Select all

*=$1300

start   LDX #$0
cycle   LDA hworld,X
        BEQ exit
        JSR $FFD2
        INX
        JMP cycle
exit    RTS

hworld  text "HELLO WORLD!",0
User avatar
J.E.E.K.
Vic 20 Drifter
Posts: 23
Joined: Wed Jan 25, 2017 12:31 pm
Website: http://klasek.at/8bit
Location: AT

Re: My BASIC Roguelike

Post by J.E.E.K. »

I like loop constructions preventing absolute jumps. It's also nice to melt together the exit decision branch and the one for the loop's back-jump ... not here, but maybe in other situations a matter of efficiency.

Code: Select all

*=$1300

start LDX #$0
        BEQ getchar
cycle
        JSR $FFD2
        INX
getchar
        LDA hworld,X
        BNE cycle
        RTS

hworld  text "HELLO WORLD!",0
edinky
Vic 20 Newbie
Posts: 18
Joined: Sat Apr 07, 2018 10:34 am

Re: My BASIC Roguelike

Post by edinky »

Forbidden64 wrote:Hey this game is actually really fun! I didn't mind the squirrely keys very much(you can just hold down the key).
This reminds me of outpost II for the PC, which is one of my all time favorites.

There are some things I can't seem to get going though. Max I was able to stay alive was 9 days(without cheating). Reason being power! It drains and drains. I built like 5 extra solar panels and it was still dropping. Then I died. basically because I couldn't get water or repair the habitat.

I eventually cheated and gave myself more power. I found if I gave myself too much, then the game wasn't a challenge anymore. Giving yourself int((a+b)*.03) isn't enough to stay alive beyond around 10 days. The yield is basically 1% units/day. Unless there is some strategy I am missing about how to manage the power? I easily would need that just to repair the habitat buildings. Let alone go mining etc.

I think this game could be sped up quite a bit without going into assembler at all. However, it would require a lot of structural changes.
Thanks! I've been working on this a bit, and have finished the guages in asm so they render much faster and doesnt slow the game down. thanks for testing it, i am going to use this feedback to help with the balancing.
Forbidden64
Vic 20 Hobbyist
Posts: 146
Joined: Sun Feb 28, 2016 9:59 pm
Location: CA USA

Re: My BASIC Roguelike

Post by Forbidden64 »

One thing you could do to offset balance or ease would be to have some alien attack mini game thrown in there... that would be pretty darn cool! Whatever they hit gets destroyed in the main game or something like that. How is this game progressing btw?

I hadn't played it for a while and today I was back at it. I also spent a while making some changes...This really is less of a roguelike and more of a space colony simulation. I was thinking if anyone ever made a sim city for VIC-20, this is about the closest I have seen in terms of a concept that is playable, and allows a growing colony in a simulator. Except it is more like Sim Mars than Sim City which is cool because it is also more original. hehe

In my copy I changed these things for playability and clarity:

-A few randomizer changes to make farming and repair a little more predictable. I also changed power to be a little more forgiving(as in you actually get some from your solar panels :D ) .

-Changed the screen update to have a looped timer so the game overall is less jerky. It is now much smoother. I changed the keyboard scan a little so that it is more conventional. There are still times where keypresses don't register but I think it is a little better than before. You can hold down a key if that is the case. Once the key is registered, the keyboard buffer variable is manually cleared to prevent bounce.

-Changed "really built <item>" to "<item> constructed"

-Changed item 'tech' to 'circuits/circuit boards' to reflect that they are commodities in the game.

-Added an NTSC fix for NTSC vic 20 for the 'BAD SFX' subroutine. Before it would jump the screen off the side of the TV and stay there so you were pretty much done playing at that point lol...

- Added comments where changes were made, and kept the organized structure of the program. Might I add how much i like that you did it this way instead of releasing the post-crunched version only. Comments and all that made it so easy to go in and noodle around. Great coding job here. Proves that VIC basic can be readable & well documented under development.

-[Edit]: Update! Added a load and save feature to the game so now if you manage not to die in the first 3 minutes, you can actually get somewhere and come back to your game another time! This will help with the overall gameplay in a massive way I think...You can really get your colony to a massive size now. Instructions are built in and very intuitive. On the start screen you'll see the changes. As usual, the subroutine is commented.

-[Edit]: Another update!-I added an alien space attack minigame inside the game as a random event! I haven't finished it, but it is event number 3. The game itself fully works, and it is fully incorporated into the main game so it works flawlessly now. The part that doesn't work so well is that I haven't finished the part where the destruction in that game reflects your own equipment in the colony. Currently, you can just blow them all up or let them blow up your base. Still fun though.


Code is formatted in CBMPRG just like the original:

Code: Select all

10 rem colony: a realtime roguelike game for the vic 20 8k+
20 rem by eoghan kidney
30 rem (c)2019
100 gosub 10000:goto 810
105 rem returning from exploration
106 rem change these lines back when testing is done.
107 rem 2518   ifrnd(1)<.01 then gosub 9000: rem check for random event
108 rem 9010 x = int(rnd(1)*10)


110 if xp=1 or xc=1 then return
120 on sc goto 1140,2005,2105,2215,2225
810 ?"{clear}":poke 36878,10: poke 36879,10: rem start game with a sound
820 for t=210 to 254
830 poke 36874,t
850 for d=1 to 2
860 next d:next t
870 poke 36878,0
880 poke 36874,0
900   rem (d)ay tp:temp (c)olonists (h)ab (l)food (lc)launch count (ox)ygen (fu)el
905   rem (w)ater (w)water ice (p)ower (s)ci-labs (r)overs (m)aterials (te)ch(micros) dr(o)nes
910   rem sol(a)r (b)atteries (g)ardens (f)orge sabat(i)er or(e) (mm)ars mapped (sm) screen memory
920   rem ed(enemy dead) ex(enemy x) ey(enemy y coord) 
930   rem (f)firing from player active bx & by player projectile(bullet/torpedo) coord 
1000   d=234: tp=-20: c=1132: lc=0: x = rnd(-ti)   :ox=50: fu=50   : fl=0
1002   h=40+int(rnd(1)*60): l=40+int(rnd(1)*60): w=40+int(rnd(1)*60): p=40+int(rnd(1)*60): s=3: r=1
1005   m=34: te=12: o=3: a=23: b=32: g=10: f=4: i=5: e=0: mm=1: sm=4096
1006   hr=1:lr=1:wr=1:pt=-2:cr=25: rem hab rate, food rate, water, powerloss rate, colonist
1008   rem pl = hab power ps = food power pu = water power q=daytime mt=maxtime la=launchbool?
1010   pl=25:ps=25:pu=50:sc=1:uc=200:q=0:mt=100:la=0:pw=1:dn$="day": rem pw=power state dn=day/night mt=time rate(increase 4 difficulty)
1015   n$ = "welcome commander":pz=p: tp% = 16: : rem n$ = newsfeed tp% = update speed delay temp variable set high for init update. 
1021   dim ex(11): dim ey(11):sm=4096:cm=37888: rem alien vessels ex & ey coord. sm-scr & cm-col memory 

1025 gosub 1138

1050 rem update loop
1060 kb=peek(197): tp%=tp%+1: : rem buffer input state, increment update delay timer.
1065 gosub 1125: gosub 1090: rem buffer vitals = power/water/food/habitat
1070 gosub 2500 : rem process changes
1080 gosub 2600 : if tp%>15 then gosub 1090: gosub 1090: rem check for input, bg tasks, input check
1081 if tp%>15 then gosub 1110: tp%= 0 : rem update vital graph if changed
1083 gosub 1090
1085 goto 1050


1090 if kb<>64 then poke36878,15: poke36876,230: poke36876,0: gosub 2260: rem key was pressed, gosub input
1100 return
1110 if int(p)<>qp or int(h)<>qh or int(w)<>qw or int(l)<>ql then gosub 2130
1120 return
1125 qp=int(p):qh=int(h):qw=int(w):ql=int(l): return

1138 sc=1: rem 1. monitor
1140   print"{clear}{white}{141}  m a r s gov.81{141}  systems online{141}{141} "c*10"colonists "
1150   print"{141}  i:inventory{141}{141}  a:activities{141}{141}  s:save{141}"
1155   print"  l:load"
1160   gosub 2130
1180 return

1999 rem /2.activities menu
2000 sc=2
2005   print"{clear}{white}{141}activities{141}{141}{reverse on}1{reverse off} mine for ore & ice{141}{reverse on}2{reverse off} repair habitat{141}{reverse on}3{reverse off} process ore{141}{reverse on}4{reverse off} harvest food{141}"
2010   print"{reverse on}5{reverse off} launch{141}{reverse on}6{reverse off} build{141}{reverse on}7{reverse off} divert power{141}{reverse on}8{reverse off} monitor{141}{reverse on}{blue}9{reverse off} explore{white}{141}"
2020   gosub 2130: return



2100 sc=3: rem /3. build menu
2105 print"{clear} resin";tab(15);"{cm +}";m;"{141} circuit";tab(15);"x";te;"{141}"
2106 print"    {purple}cost";tab(15);"{cm +}   x"
2107 for zx=0 to 8: print"{white}{141}{reverse on}"zx+1"{reverse off}"b$(zx+10);tab(14);"{purple}"b%(zx*2);tab(18);b%((zx*2)+1)"{white}";
2110 next zx
2115 print"{141}"

2120 rem display newsfeed
2130 print"{home}{down*15}{yellow}habi ";:na=qh:gosub2150:?"{141}{green}food ";:na=ql:gosub2150:?"{141}{blue}water";:na=qw:gosub2150:?"{141}{cyan}power";:na=qp:gosub2150
2132 if kb=64 then kb=peek(197)
2135 print"{141}{white}"dn$;d"{141}                    {left*20}{red}"n$"{white}"
2138 if sc=4 then ?"{home}{down*3}{right*7}fff";fl
2140 return
2150 t=int(na/8):tb=int(((na/8)-t)*8):?"               {left*15}";
2160 for xq=1 to t:?"{reverse on}{space}{reverse off}";:next xq:?ba$(tb);:return

2210 rem /4. power menu
2215   sc=4
2216   print"{clear}{141}sabatier plant{141}{141}";"fuel:";fl;"{141}produce:{141}1.rocket fuel:"fu"%{141}2.oxygen:"ox"%"
2217   print"{141}hit 1 to change{141}power state"pw
2218 gosub 2130
2219 return

2220 rem /5. inventory
2225  ?"{clear}{141} materials";tab(15);"{cm +}";m;"{141} circuits";tab(16);"x";t;"{141}"
2230 for jj=0 to 8:?b$(10+jj);tab(16);ws(jj*4): next jj
2240 gosub 2130: return

2260 rem /intepret input
2275   a$=str$(sc)+str$(kb):rem combine sc number and input
2280   if a$=" 1 0" then gosub 2000
2282   if a$=" 2 0" then gosub 3000
2285   if a$=" 2 56" then gosub 3300
2288   if a$=" 2 1" then gosub 3600
2290   if a$=" 2 57" then gosub 3700
2300   if a$=" 2 2" then gosub 4000
2310   if a$=" 2 58" then gosub 2100
2320   if a$=" 2 3" then gosub 2210
2325   if a$=" 2 59" then gosub 1138
2328   if a$=" 2 4" then gosub 4200
2338   if a$=" 3 0" then bm = 0: gosub 5000
2348   if a$=" 3 56" then bm = 1: gosub 5000
2358   if a$=" 3 1" then bm = 2: gosub 5000
2364   if a$=" 3 57" then bm = 3: gosub 5000
2367   if a$=" 3 2" then bm = 4: gosub 5000
2368   if a$=" 3 58" then bm = 5: gosub 5000
2370   if a$=" 3 3" then bm = 6: gosub 5000
2380   if a$=" 3 59" then bm = 7: gosub 5000
2390   if a$=" 3 4" then bm = 8: gosub 5000
2395   if a$=" 4 0" then gosub 5500
2400   if kb=17 then gosub 2000
2410   if kb=12 then gosub 2220
2411   if kb=41 then gosub 11400
2412   if kb=21 then gosub 11500
2415   kb=64: rem clear keyboard buffer storage
2490 return

2500 rem process changes
2510  q=q+1: if q>mt then gosub 2530
2511  rem ?"{home}{right*16}"q:rem daytimer
2512   if dn$="day" and q>(mt/2) then dn$="night": poke 36879,8: gosub 2120
2514   if dn$="night" and q<(mt/2) then dn$="day" : poke 36879,10: gosub 2120
2515   if h<1 or l<1 or w<1 or p<1 then gosub 11000: rem death by zero  
2518   ifrnd(1)<.01 then gosub 9000: rem check for random event
2520   if p>120 then p=120: gosub 2120
2521   if h>120 then h=120: gosub 2120
2522   if l>120 then l=120: gosub 2120
2523   if w>120 then w=120: gosub 2120
2526 pz=(pz+(pt/50)):h=h-abs(hr*(pl/(250-ox))):w=w-abs(wr*(pu/250)):l=l-abs(lr*(ps/250)): rem update monitors int(pt/500): check int logic!!!!
2527 fl=fl+(1*(fu/25))
2529 return

2530 rem add a day
2540   tp=tp+int(rnd(1)*6)-3: rem change temp
2544   c=(c-cr)+int(rnd(1)*50): rem kill and birth colonists
2545   d=d+1: q=0 :p=p+int((a+b)*0.2)
2552    if h<10 or l<10 or w<10 or p<10 then n$="vitals low!":gosub 2120 
2560 return

2600 rem process background activity i.e building things
2610 for x=0 to 7:xq=x*4: rem cycle through all items to check
2620 if ws(xq+3)=1 then ws(xq+2)=(ws(xq+2))-1:gosub2700: rem if item is building, remove time ledt
2630 nextx
2640 return
2700 if ws(xq+2)=0 and ws(xq+3)=1 then ws(xq)=ws(xq)+1:ws(xq+3)=0: gosub 2800
2710 return
2800 n$=b$(10+x)+" constructed." :gosub 7000
2810 gosub 120:return
 
3000 rem mine
3005 if r<2 then n$="2 rovers needed": goto 3018
3010   q=q+10:w=w-2:p=p-5:x=int(rnd(1)*6)
3012   if rnd(1)<0.5 then e=e+x:n$=str$(x)+"t ore mined":goto 3018
3015   n$=str$(x)+"t ice mined":w=w+(x*10)
3018   gosub 2120
3020 return

3300 rem repair
3310    q=q+20:w=w-2:p=p-5:x=int(rnd(1)*5)+5:h=h+x:ifh>100thenh=100
3320    n$="hab now"+str$(int(h))+"%"
3325 gosub 2120
3330 return

3600 rem process
3605    if e<1 then goto 3645
3610    q=q+10:w=w-3:p=p-5:m=m+int(e/2):e=0
3620    n$=str$(m)+"x new resin"
3625 gosub 2120
3635 return
3645 n$="no ore to process":goto 3625

3700 rem harvest
3710   q=q+10:w=w-5:x=int((rnd(1)*5)+5):l=l+x
3715   n$="food now "+str$(int(l))+"%"
3718   gosub 2120
3720 return

4000 rem launch
4010 if la=0 then goto 4180
4015 if p>50 then n$="need more power"
4020 n$="launching..."
4030 gosub 7000: gosub 120
4170 return
4180 n$="no ship!":gosub 2120
4190 return

4200 rem explore
4201 tt=mt: mt=20: xp=0:xc=1: fx=1:sx=15
4202 poke 36878,10:poke36877,180
4205 ex$="setting out"
4210 ?"{clear}exploring...{141}{141}"mm"% mars mapped{141}{141}";ex$;"!{return}{return}press any key to{return}return to base"
4225 b=peek(197)
4228 gosub 1125
4230 gosub 2500
4235 gosub 2120
4236 gosub 4500: rem do sfx
4238 if xp=1 then xp=0: goto 4202
4240 if rnd(1)<0.05 then mm=mm+0.2: on int(rnd(1)*10) goto 4310, 4320, 4330, 4340, 4350, 4360, 4370, 4380, 4390, 4400
4250 a=peek(197)
4255 if a<>b then mt=tt:gosub 2000:poke 36877,0: xp=0: xc=0: return 
4265 gosub 1110
4300 goto 4225
4310 ex$="found water": w=w+10: goto 4210
4320 ex$="colony established": c=c+100: goto 4210
4330 ex$="beautiful caves": goto 4210
4340 ex$="ancient structure": goto 4210
4350 ex$="invasive species": c=c-20: goto 4210
4360 ex$="curious dust": goto 4210
4370 ex$="more rocks": goto 4210
4380 ex$="mountain": goto 4210
4390 ex$="endless plain": goto 4210
4400 ex$="unpassable ridge": goto 4210
4500 if fx=0 then sx=sx+1
4510 if fx=1 then sx=sx-1
4520 if sx = 13 and fx=0 then fx=1
4530 if sx = 4 and fx=1 then fx=0
4540 poke 36878, sx
4550 return

5000 rem building (bm= item to build)
5015 mc=b%(bm*2):tc=b%((bm*2)+1)
5018 if ws((bm*4)+3)=1 then n$="in progress":goto 5034
5020 if mc>m and tc>t then n$="under resourced"
5025 if mc>m then n$="need more mat."
5028 if tc>te then n$="need more circuits"
5029 if mc<=m and tc<=te then gosub 5040: rem if enough resources, then build
5034 gosub 2120: return
5040 n$="building "+b$(10+bm)+str$(bm)
5050 m=m-mc: te=te-tc
5051 gosub 5200: rem go to experimental building
5052 on bm+1 gosub 5070,5080,5090,5100,5110,5120,5130,5140,5150: rem build the thing
5055 gosub 2520: gosub 2100
5060 return
5070 o=o+1: return
5080 r=r+1: return
5090 a=a+1: return
5100 b=b+1: return
5110 g=g+1: return
5120 f=f+1: return
5130 i=i+1: return
5140 te=te+1: return
5150 h=h+20: return
5200 ws((bm*4)+1)=ws((bm*4)+1)+1
5205 ws((bm*4)+3)=1
5210 ws((bm*4)+2)=20: rem timetaken 20 for all objects (temp)
5220 return

5500 rem sabatier (unfinished)
5510 pw=pw+1
5520 if pw>5 then pw=1
5530 if pw=1 then fu=100:ox=0: hr=hr+2
5540 if pw=2 then fu=75:ox=25: hr=hr+1
5550 if pw=3 then fu=25:ox=75
5560 if pw=4 then fu=0:ox=100: hr=hr-1 
5562 if pw=5 then fu=0:ox=0: hr=hr-2
5565 gosub 2210
5570 return 

6000 rem sfx for bad
6010 ?"{clear}":zb=peek(36864):za=peek(36865)
6060 for xx=15 to 0 step -1
6070 gosub 6130: ? "{red}"n$
6080 next
6090 poke 36865,38: poke 36864,12: poke 36878,0
6100 poke 36874,0: poke 36875,0: poke 36877,0
6105 poke 36879,10:  for mx=0 to 1000: next
6106 poke 36864, zb:poke 36865,za :rem restore original scr loc (ntsc fix)
6107 if n$="alien attack" then gosub 12000
6110 gosub 120: return 
6130 poke 36878,xx: poke 36877,200+xx*rnd(1)
6140 poke 36874,129: poke 36875,190+xx
6150 poke36865,38+4*(4*rnd(l)-2)
6160 poke36864,12+2*(2*rnd(l)-2)
6170 if xx=15 then poke 36879,112: for mx=0 to 100: next
6180 poke 36879,27
6190 return

7000 rem poke 36879,10:rem sfx for good
7005 ?"{clear}"
7015 ? "{white}"n$
7020 poke36878,15
7030 forfx=4to0step-1:poke36878,fx
7040 forfy=1to100:next
7050 forfz=220to240:poke36876,fz:next:next
7060 poke 36876,0
7070 poke 36878,0
7100 return

9000 rem random events
9010 x = int(rnd(1)*10)
9015 if x=0 then hr=hr+3: h=h-1: c=c-20: a=a-2: b=b-2
9025 if x=1 then wr=wr+3: g=g-1: cr=cr+20
9035 if x=2 then pt=pt+3
9045 if x=3 then gosub 12000:x=3 
9055 if x=4 then wr=wr-3: c=c+100: cr=cr-20
9065 if x=5 then hr=hr-3: cr=cr-10
9075 if x=6 then c=c-20
9085 if x=7 then c=c-5: p=p-2: r=r-1
9095 if x=8 then c=c-20
9098 if x=9 and la>1 then return
9102 if x=9 then m=m+20:w=w+20:t=t+20:c=c+100:la=la+1
9110 n$=b$(x)
9115 if x>5 then gosub 7000:goto 9120
9118 gosub 6000
9120 gosub110:q=q+1000:xp=1:return 

9999 end
10000 data "meteor hit!","disease!","dust storm!","aliens attacked!","disappearances","rover crash!"
10010 data "med. discovery!","tech discovery!","celebration!","supply ship!"
10020 data "drone","rover","solar panel","batteries"
10030 data "growspace","forge","sab plant","circuit","habitat"
10035 dim b$(19)
10036 rem first 10 are random events, rest are buildable objects
10037 for x=0 to 18: read b$(x): next x
10038 rem below for each buildable item [(begin amount, material cost, tech cost),(),.]
10040 data 2,1,1,5,5,1,1,1,1,2,0,0,0,2,1,0,30,3,0,2,1,0,1,1
10045 dim b%(23)
10050 for x=0 to 23: read b%(x): next x
10052 rem below for each buildable item [(number of, time remaining ,isbuilding?),(),.]
10055 data 3,0,0,0,0,0,0,0,23,0,0,0,32,0,0,0,10,0,0,0,4,0,0,0,5,0,0,0,12,0,0,0,2,0,0,0
10060 dim ws(35)
10070 for x=0 to 35: read ws(x): next x
10080 dim ba$(7)
10085 rem below are characters for guages
10090 data " ","{cm g}","{cm h}","{cm j}","{cm k}","{reverse on}{cm l}{reverse off}","{reverse on}{cm n}{reverse off}","{reverse on}{cm m}{reverse off}"
10110 return

10500 rem end state
11000 poke 36877,0:?"{clear}the colony survived{141}"d-234"days of your{141}leadership."
11002 ?"yet without ";
11005 if p<1 then ? "power";
11006 if w<1 then ? "water";
11007 if l<1 then ? "food";
11008 if h<1 then ? "habitat"
11010 ?:?c*10;"perished"
11015 ?:?"{141}hit a key to try again"
11020 a=peek(197)
11025 if peek(197)<>a then clr: goto 100
11030 goto 11025

11399 rem ** save game feature aka key 41
11400 ?"{clear} saving game.":?:?
11410 open1,1,1,"save"
11415 r$=chr$(13)
11420 print# 1,d;r$;c;r$;h;r$;l;r$;lc;r$
11422 print# 1,ox;r$;fu;r$;w;r$;p;r$;e;r$
11425 print# 1,s;r$;r;r$;m;r$;te;r$;o;r$
11426 print# 1,a;r$;b;r$;g;r$;f;r$;i;r$;mm;r$

11427 close 1
11430 n$ = "game saved.":pz=p: tp% = 16: : rem n$ = newsfeed tp% = update speed delay
11440 gosub 1138
11450 return

11499 rem ** load game feature aka key 21
11500 ?"{clear} loading game.":?:?
11510 open1,1,0,"save"
11520 input# 1,d,c,h,l,lc
11522 input# 1,ox,fu,w,p,e
11525 input# 1,s,r,m,te,o
11526 input# 1,a,b,g,f,i,mm
11527 close 1
11530 n$ = "welcome back":pz=p: tp% = 16: rem n$ = newsfeed tp% = update speed delay 
11540 gosub 1138
11550 return

11999 rem ** minigame Alien Attack
12000 poke36879,8:?chr$(31);chr$(147)
12001 print chr$(5);chr$(147)"aliens are attacking!":gosub13000
12010 print "use a and d to move 
12015 print "left and right"
12020 print "press space bar
12025 print "  to fire."
12030 print "** press any key **"
12040 if peek(197)=64 then 12040

12049 rem init minigame
12070 rem **make buildings
12100 vv%=x: rem back up x and y for use
12110 vu%=y: rem outside the minigame
12120 x=20: rem set player x&y coord.
12130 y=12:?chr$(147)
12140 rem set all enemy locations to random spots at the top of the screen
12150 en = 10: rem total number of bad guys
12160 for i = 1 to en
12170  ex(i) = int(rnd(1)*3)
12180  ey(i) = int(rnd(1)*22)
12190 next i 

12199 rem **minigame main loop
12200 kb=peek(197)
12210 cu=cu+1: rem update counter
12220 if cu>10 then gosub 12400: cu=0: rem on counter, move enemies
12230 if kb<>64 then gosub 12300 : rem PLAYER KEYPRESS
12240 if f = 1 then gosub 12350
12250 if f=1 then pokesm+bx*22+by,30
12260 if en = 0 then return
12270 goto 12200

12299 rem player keypress sub
12300 ifkb=17 then if y >0 then poke sm + x * 22+ y, 32:y=y-1:zm=1
12310 ifkb=18 then if y <23 then poke sm + x * 22+ y, 32: y=y+1:zm=1
12320 ifkb=32 then gosub 12500: 
12330 rem player is char poke 65, on move only move flag is zm(avoid flicker)
12340 ifzm=1thenpoke sm + x * 22+ y, 65:zm=0
12345 return

12349 rem ** process fire object path
12350 r=r+1:ifr=20then f=0:r=0:return
12351 if peek(sm+(bx*22)+by-22)<>81thenpoke(sm+(bx*22)+by),32:bx=bx-1:return
12360 for i=1 to en
12370 if ex(i)+1=bx and ey(i)=by then gosub 13200
12380 next
12385 rem if ed=0 then gosub 13400
12386 f=0:return

12399 rem **move enemy
12400 jj = jj +1: if jj > en then jj=1 
12430 poke sm+(ex(jj)*22)+ey(jj),32:zm=1:ex(jj)=ex(jj)+int(rnd(1)*3+.5):rem moves rnd # down
12440 if zm=1 then poke sm+(ex(jj)*22)+ey(jj),81: zm=0
12450 rem  if enemy ex(jj) > screen memory + 512 (past the bottom of screen)
12460 rem  explosion and flag player facility or object destruction at random
12470 if ex(jj)*22+ey >= 446 then gosub 13200: fl=fl+1
12495 return

12499 rem sub set fire / create projectile object  
12500 by=y
12510 bx=18
12520 f=1:r=0
12530 gosub 12600: rem fire sound!!
12540 return

12598 rem sub fire sound
12599 rem #15: ufo shooting from vic 20 manual
12600 poke 36878,15
12610 for zt=1 to 7
12620 for zp = 210 to 220 + zt*2
12630 poke36876,zp
12640 nextzp
12650 nextzt
12660 poke 36878,0
12670 poke 36876,0
12680 return
  
12698 rem sub explosion
12699 rem ** #3: explosion from vic 20 manual
12700 poke 36877,220
12800 for zt = 15 to 0 step -1
12900 poke36878,zt
12910 for zp = 1 to 100
12920 nextzp
12930 nextzt
12940 poke 36877,0
12950 poke 36878,0  
12960 return

12998 rem **Alien attack sound from vic 20 manual
12999 rem #14: ufo landing
13000 poke 36878,15
13010 for zt=1 to 20
13020 for zp= 220-zt to 160-zt step -4
13030 poke 36876,zp
13040 next
13050 for zp=160-zt to 220-zt step 4
13060 poke 36876,zp
13070 next zp
13080 next zt
13090 poke 36878,0
13100 poke 36876,0
13120 return

13199 rem **Visual explosion
13200 for ji=ex(i)-1 to ex(i) + 1
13210 for jo=ey(i)-1 to ey(i) + 1
13220 poke cm+ji*22+jo,2
13230 poke sm+ji*22+jo,42
13240 next
13250 next
13260 gosub 12700
13270 for ji=ex(i)-1 to ex(i) + 1
13280 for jo=ey(i)-1 to ey(i) + 1
13290 poke cm+ji*22+jo,1
13300 poke sm+ji*22+jo,32
13310 next
13320 next
13330 ex(i)=ex(en)
13340 ey(i)=ey(en)
13350 en=en-1
13360 return

13399 rem correct-o-kill module
13400 ed=0
13410 for i=1 to en
13420 if bx-1=ex(i) then gosub 13200
13430 next
13440 f=0:return
Post Reply