pouët.net

Go to bottom

StarBlitz by Relational Framework [web]

 rem ----------------------------------------- 
 rem -- Tiny BASIC program StarBlitz v5C    --
 rem ----------------------------------------- 
 
 rem -----------------------------------------
 rem ---init section, runs once: -------------
 rem -----------------------------------------
 
 rem --- Defined array variables:
 data mazecolors $64,$54,$b4,$a4,$32,$44,$24,$c4,$94,$f4,$54,$a4,$d4,$f4,$74,$16
 data randomizecities 1,4,2,5,3,2,3,1,4,1,1,1,5,2,2,3,1,4,1,4,3,1,4,4,1,1,2,2,3,1,3
 data randomize2 4,1,5,2,2,3,1,3,1,1,4,1,5,3,2,1,1,4,1,5,6,1,4,5,5,1,1,3,3,3,1
 data getnumbersprites 48,56,64,72,80,88,96,104,112,120,128,136,144,152,160,168,176,0,8,40,40,40
 rem data getnumbersprites 128,128,128,128,128,128,96,104,112,120,128,136,144,152,160,168,176,0,8,40,40,40
 data lives $54,$64,$74,$84,$c4,$a4,$b4,$78,$54 
 
 rem --- 29 predefined variables (e-z,var1,var2,px,py,bx,by,score)
 BYTErowoffset=120:start near bottom of virtual world
 rem BITIndex=20:rem start one TV screen in
 
 rem add ability to turn back and forth DONE
 rem add laser beams (4x missile extra wide)
 rem add slowly falling commets to avoid/shoot b4 they destroy city, use random table
 rem wierd bug - if meteor is not on screen it freezes! - fixed

 rem --- variable map:  -------------------------
 rem f - framecounter (0-9)  
 rem r - randomizecities index (0-59) response seeded
 rem n - init new cityscape (1) and game (2)  
 rem i,j,k,l - loop vars,temp vars
 rem t - toggle var (0/1)
 rem g - direction, 0 right, 1 left
 rem o,p and u,v - x/y for tilemapped NPC's (u/v freed - comet2 is turned off)
 rem z,m NPC sprite lookup and color index
 rem h - smooth animation increment for NPC
 rem score,var2,w,var1 - score/lives/level,cityhealth
 rem player0x,player0y,player1y,missile0x, etc - sprite variables
 rem q - Defender lander hit points
 rem u - enemy torpedo active flag
 loadplayer0(0): rem flyer - face right	
  
 COLUPF=$64:rem 3A
 COLUP0=$54
 rem var2=9: rem 9 lives
 player0x=80:player0y=80
 NUSIZ0=%00110000:rem normal player1, wide missile
 rem ------------------------------------------------
 rem end init section (implicit return)--------------
 rem ------------------------------------------------

 rem ------------------------------------------------
 rem ---:the next comment line is used by the compiler
 rem ---gameloop subroutine, runs every frame:    ---
 rem ------------------------------------------------
 rem Tiny BASIC program StarBlitz 
 rem ------------------------------------------------
 f=f+1:t=1-t:rem this expression toggles var t between 0 and 1 
 if f=10 then f=0: rem 10 frames 
 if r>59 then r=0: rem upper boundry of random variable array

 rem Draw random city or seed random number generator
 if n=0 and f=9 and joy0fire=1 then n=1 else r=r+1 

 rem --- player missile: 
 if joy0fire=1 and missile0x=0 then missile0x=player0x:AUDC0=6:AUDF0=missile0x:SUSTAINFORFRAMES=20
 if missile0x=0 then goto donemissile
 if g=0 then missile0x=missile0x+3 else missile0x=missile0x-3
 missile0y=player0y-5
 if missile0x>158 or missile0x<7 then missile0x=0:missile0y=0:rem COLUBK=10
 rem -- fix hard to hit pod
 if missile1y<missile0y+4 and missile1y>=missile0y then missile0y=missile1y
 
 rem good AUDC0=7:AUDF0=missile0x:SUSTAINFORFRAMES=4
 rem AUDC0=8:AUDF0=missile0x:SUSTAINFORFRAMES=4
 rem UFO: AUDC0=5:AUDF0=missile0x:SUSTAINFORFRAMES=4
 rem 8 17 12
donemissile

 rem --- move player vertically
 if joy0down=1 and player0y>8 then player0y=player0y-2
 if joy0up=1 and player0y<96 then player0y=player0y+2
 

 rem --- enemy torpedo --- Trixter's idea
 if u=1 and t=0 then NUSIZ1=%00110000:AUDC1=7:AUDF1=missile1x:SUSTAINFORFRAMES=4:gosub share_for_enemy_torpedo 
 
 rem ---------Defender_Lander -------------------------- TJ's idea
 if z<>8 then goto meteor
 if player1y=0 then goto meteor
 
 rem if t=1 then goto skipxx 
 if player1x<player0x then player1x=player1x+1
 if player1x>player0x then player1x=player1x-1
 
 if randomizecities(r)>3 then goto skipxx
 
 if player1y<player0y then player1y=player1y+1
 if player1y>player0y then player1y=player1y-1
 if player1y=0 then o=0
 rem : lander launches pod
 if missile1y=0 and f<>8 then goto skipxx: rem -- lander needs some time to recover
 if missile1y=0 then missile1y=player1y:missile1x=player1x
 gosub share_for_enemy_torpedo
skipxx
 goto donecomet1 
 
meteor  
 rem init new comet?
 rem incldue enemy torpedo for fragmented metor (24)
 rem --- pick random spot to fall
 if o=0 and g=0 then o=BITIndex+20:i=randomizecities(r)/2:o=o-i:gosub choosecomet
 
 if o=0 and g=1 then o=BITIndex:o=randomizecities(r)+o:gosub choosecomet
 loadplayer1(z): COLUP1=mazecolors(m)

 if o<21 then o=randomizecities(r)+20: rem COLUPF=10 else COLUPF=64
 if o>71 then o=randomizecities(r)+64:rem COLUPF=10 update 
 vwpixel(o,p,bindplayer1)
 if vwpixel(o,p,poll)>0 then vwpixel(o,p,flip):AUDC1=3:AUDF1=p/3:SUSTAINFORFRAMES=7:var1=var1+1

 if h=0 then  goto skipthirdsteps
 rem --- meteors freezing offscreen bug: if h>1 and player1y>h then player1y=player1y+h:h=h-3 
 rem --- no: if h>1 then player1y=player1y+h:h=h-3
 
 if player1y>h then player1y=player1y+h
 h=h-2:rem too fast withoutrandom delay h=h-3 

 goto donecomet1
skipthirdsteps
 
 rem ---- KaeruYojimbo's idea for unifom falling rate on meteors; remove rnd third step delay: 
 rem if randomizecities(r)>1 then p=p+1:h=9 else h=0: rem h= do third steps 

 p=p+1:h=10: rem h=9  
 if p = 20 then o=0
donecomet1
 rem -- comet2 removed from build


 rem --- seed horizontal drift and direction panning the city
 if joy0left=1 then g=1
 if joy0right=1 then g=0

 rem if t=1 then goto donego

 rem --- pan the city and handle horizontal drift
 if g=1 then goto goleft
goright 
 REFP0=0: rem face forwards
 BITIndex=BITIndex+1
 if BITIndex>71 then BITIndex=0
 if player0x>22 then player0x=player0x-2
 goto donego
goleft 
 REFP0=255: rem face backwards
 BITIndex=BITIndex-1:rem boundry fix, Flyer escaping into memory...
 if BITIndex=255 then BITIndex=71: rem wrap around
 if player0x <142 then player0x=player0x+2
donego

 rem   --- check if player missile hit something:-------------------
 if CXM0P<126 then goto skiphit
 COLUBK=10
 o=0:rem if t=1 then o=0 else u=0
 missile0x=0:missile0y=0:AUDC0=7:AUDF0=12:SUSTAINFORFRAMES=16:CXCLR=0
 score=score+1
 rem -- player missile hit defender lander?===============
 if z<>8 then goto skip_hitlander
 if q<3 then q=q+1 else q=0: q=0:player1y=0:o=0:missile1y=0:missile1x=0:z=0:AUDF0=21
 if q=2 then AUDF0=10
 goto skiphit3
skip_hitlander rem -- missile hit meteor:
 if score>8 then score=0:w=w+1:var1=0:COLUPF=mazecolors(m):n=1:MUSICINDEX=15
 goto skiphit3
skiphit
 COLUBK=0
 rem --- check player hit by comet:
 if CXPPMM <126 then goto skiphit2
 CXCLR=0:o=0:player1x=0:player1y=0
 rem debug next line 
 if z>48 then score=score+1:AUDC0=7:AUDF0=12:SUSTAINFORFRAMES=20:goto skiphit2
 if z=8 then missile1y=0:missile1x=0:z=16
 
 rem --- checking if $34 background for 2 frames rolls screen on Spice's monitor
 COLUBK=$34:AUDC0=3:AUDF0=7:SUSTAINFORFRAMES=17:var2=var2+1 
 rem COLUBK=$70:AUDC0=3:AUDF0=7:SUSTAINFORFRAMES=17:var2=var2+1 
 if var2>8 then gosub end_game else COLUP0=lives(var2)
 goto skiphit3
skiphit2
 rem ---check player hit by missile
 if CXM1P <126 then goto checkmm
 
 rem --- checking if $36 background for 2 frames  rolls screen too...
 COLUBK=$36:AUDC0=3:AUDF0=11:SUSTAINFORFRAMES=7:var2=var2+1 
 rem COLUBK=$70:AUDC0=3:AUDF0=11:SUSTAINFORFRAMES=7:var2=var2+1 
 
 u=0:CXCLR=0:missile1x=0:missile1y=0:COLUBK=$44:rem fix 
 if var2>8 then gosub end_game else COLUP0=lives(var2)
 goto skiphit3
checkmm
 if CXPPMM<63 then goto skiphit3: rem --- missile missile
 u=0:missile1x=0:missile1y=0:missile0x=0:missile0y=0:AUDC0=7:AUDF0=12:SUSTAINFORFRAMES=26:CXCLR=0
skiphit3

 if MUSICINDEX>=90 then COLUBK=$70:rem $34 blanking on one Plasma display...
 
 if var1>50 then COLUPF=7:City critical
 if var1>70 then COLUPF=4
 if var1>80 then gosub end_game

 scrollvirtualworldtoggle=1:rem raise event to pan the camera

 return

share_for_enemy_torpedo if g=0 then goto othersidefix
 if missile1x<player0x+3 then missile1x=missile1x+3:goto endothersidefix
 if missile1x>player0x then missile1x=missile1x-3
 goto endothersidefix
othersidefix rem left side
 if missile1x>player0x+3 then missile1x=missile1x-3
 if missile1x<player0x-3 and player0x>3 then missile1x=missile1x+3

endothersidefix
 if missile1y<player0y-4 and player0y>4 then missile1y=missile1y+2
 
 if missile1y>player0y-4 and player0y>4 then missile1y=missile1y-2
 rem if missile1y>player0y then missile1y=missile1y-2
 rem ! bug - if showing enemy torpedo, goto meteor too... 
 return


 rem -------------------------------------------------------------
 rem end game loop (implicit return)-----------------
 rem -------------------------------------------------------------

 rem -------------------------------------------------------------
 rem ---gameloop2 subroutine, runs every frame:    --
 rem ------------------------------------------------
 return: rem ---done with gameloop, functions below:---

choosecomet 
 p=9
 rem ------- cycle 20 sprites (sprite array) and 16 colors (mazecolors array)
 m=m+1: rem z=z+8
 rem if z>184 then z=16
 if z=16 then z=24 else z=16
 if randomizecities(r)=5 and score>0 then z=getnumbersprites(score)
 if m>15 then m=0
 rem --- set comet size
 rem NUSIZ1=%00110000:normal player2, wide missile
 NUSIZ1=%00010000:normal player2, medium missile
 
 i=randomizecities(r)
 if i=6 then NUSIZ1=%00111111:rem super wide player2, wide missile 
 if i=2 then NUSIZ1=%00111101:rem wide player2, wide missile
 if f<6 then return
 rem adjust if player is hiding
 rem if g=0 and player0y<50 then o=o+12:o=o+i
 rem if g=1 and player0y<50 then o=o-12:o=o-i
 if g=0 then o=o+14:o=o+i
 if g=1 then o=o-14:o=o-i
 rem --- 20160131 ---adding descending ship with dot missile
 if i=3 then z=8: rem --- load defender enemy ship looking like lunar lander!
 rem z=8: rem .... only do this some of the time or f>7 logic is lost
 if i=1 then u=1:missile1x=randomizecities(m)*20: rem --- launch enemy torpedo simultaneously with meteor
 return


end_game
 var1=0:var2=0:score=0:MUSICINDEX=90:n=5

 rem -------------------------------------------------------------
 rem end gameloop2 (implicit return)----------------- 
 rem ------------------------------------------------

 rem -------------------------------------------------------------
 rem ---KITCHENSINK subroutine, runs when scrollvirtualworldtoggle=1
 rem -------------------------------------------------------------
 
 if n<>1 then goto skip_Cityscape
 if MUSICINDEX>=90 then n=0:goto skip_Cityscape: rem -- wait if end tune is playing 
 rem for n=1 to 2
 rem ---clear the virtual world (1/2) 
 for j = 120 to 239:virtualworld(j)=0:next j 
 rem ---create a new City Scape
 for j = 20 to 71
 k=randomizecities(r)+14
 for i = 19 to k step -1
 vwpixel(j,i,on)
 rem --- 20160215 Mirroring city in the blank space for continuous cityscape 
 if j<41 then n=j-20: vwpixel(n,i,on):n=52+j:vwpixel(n,i,on)  : rem j+52
 next i
 r=r+1 :rem increment random index
 if r>59 then r=0: rem boundry check for psuedo random number generator table 
 next j:rem ,n
 v=0:COLUP0=$54:var1=w*4:var2=0:n=2 : rem done building cityscape, game in progress 
skip_Cityscape

 rem ---show title screen (copy from top 1/2 of virtual world)
 if n<> 5 then goto skip_titlescreen
 for j=120 to 239
 i=j-120
 virtualworld(j)=virtualworld(i)
 next j

 rem goto skipshowlevel
showlevel rem if MUSICINDEX<15 then goto skipshowlevel
 j=getnumbersprites(w):k=121
 for i=0 to 7
 if MUSICINDEX<15 then l=0 else l=j+i:l=sprites(l): rem get row of level number
 rem --Display level on virtual world only at beginning of each round and finale.
 virtualworld(k)=l: k=k+12
 next i
 for i=4 to 11
 for j = 10 to 17
 if vwpixel(i,j,poll)>0 then k=i+72: vwpixel(k,j,on)
 next j,i
skipshowlevel

 n=0: game not started yet
skip_titlescreen

 rem for x = 1 to 4
 rem for y = 1 to 4
 rem vwpixel(x,y,flip)
 rem next y,x


 if MUSICINDEX=115 then w=0: rem clear level indicator
 rem end kitchensink events----------------------------------------------
 
virtualworld
...................xxxxxx.xxxxxx..xxxxx.xxxxx..xxxxx...x....x.xxxxx.xxxxx...................
...................x....x...xx....x...x.x...x..xx..x...x....x...xx..x..xx...................
...................x........xx....x...x.x...x..xx..x...x....x...xx.....xx...................
...................xxxxxx...xx...xxxxxx.xxxxxx.xxxxxx..x...xx...xx.....x....................
........................x...xx...xx...x.xx..xx.xx...x.xx...xx...xx....x.....................
...................xx...x...xx...xx...x.xx..xx.xx...x.xx...xx...xx...x.xx...................
...................xxxxxx.x.xx.x.xx...x.xx..xx.xxxxxx.xxxx.xx...xx..xxxxx...................
...........................x....x....x......x..........................x....................
x....................x.xx..xx...xx...x.x..x.xxx..x.xx..x.....x.x..xx..xxx...................
x...................xx.xx.xxx.x.xx.x.x.x.xx.xxx.xx.xx.xx.xx.xx.xx.xxx.xxx...................
............................................................................................
............................................................................................
...................xxxxxx.xxxxxx..xxxxx.xxxxx..xxxxx...x....x.xxxxx.xxxxx...................
...................x....x...xx....x...x.x...x..xx..x...x....x...xx..x..xx...................
...................x........xx....x...x.x...x..xx..x...x....x...xx.....xx...................
...................xxxxxx...xx...xxxxxx.xxxxxx.xxxxxx..x...xx...xx.....x....................
........................x...xx...xx...x.xx..xx.xx...x.xx...xx...xx....x.....................
...................xx...x...xx...xx...x.xx..xx.xx...x.xx...xx...xx...x.xx...................
...................xxxxxx...xx...xx...x.xx..xx.xxxxxx.xxxx.xx...xx..xxxxx...................
............................................................................................

sprites
0
........
X.......
XX......
XXXXXX..
XXX..XXX
.XXXXXXX
XXX.....
........
8
.x....x.
..xxxx..
.x.xx.x.
..xxxx..
...xx...
..xxxx..
.x.xx.x.
x..x...x
16
..xxxx..
.xXXXXx.
XXX.xxXX
XxXxx.XX
xXXXXX.x
XXX..XXX
XxxxxxxX
..xxxx..
24
x...xx..
...XXXX.
X....XXX
XXX.....
..X..XX.
X.X.XXXX
Xx...XX.
...x....
32
..xxxx..
.xXXXXx.
XXX.xxXX
XxXxx.XX
xXXXXX.x
XXX..XXX
XxxxxxxX
..xxxx..
40
..xxxx..
.xXXXXx.
XX.xx.XX
XxxxxxXX
x.XXXX.x
XX....XX
.xxxxxx.
..xxxx..
48
xxxxxxxx
xx....XX
Xx....XX
XX....xx
xxxx..xx
Xxxx..XX
Xxxx..xx
xxxxxxxx
56x
..xxx...
.xxxx...
..xxx...
..xxx...
..xxx...
.xxxxx..
.xxxxx..
.xxxxx..
64
........
xxxxxxxx
......xx
......xx
xxxxxxxx
xxxx....
xxxx....
xxxxxxxx
72
xxxxxxx.
......x.
......x.
......x.
xxxxxxxx
......xx
......xx
xxxxxxxx
80
xx......
xx......
xx......
xx...xx.
xxxxxxx.
.....xx.
.....xx.
.....xx.
88
........
xxxxxxxx
xx......
xx......
xxxxxxxx
....xxxx
....xxxx
xxxxxxxx
96
........
xxxxxxxx
xx....xx
xx......
xxxxxxxx
xx....xx
xxxx..xx
xxxxxxxx
104
xxxxxxxx
xxxxxxxx
xx...xxx
....xxx.
...xxx..
...xxx..
...xxx..
...xxx..
112
.xxxxxx.
.x....X.
.x....X.
XXxxxxxx
xx....xx
Xxxx..XX
Xxxx..xx
xxxxxxxx
120
xxxxxxxx
x.....xx
x....xxx
xxxxxxxx
......xx
......xx
......xx
......xx
128
xx.xxxxx
xx.xx..x
xx.xx..x
xx.xx..x
xx.xx..x
xx.xxx.x
xxx.xx.x
xxx.xxxx
136
.xx..xx.
xxx.xxx.
.xx..xx.
.xx..xx.
.xx..xx.
.xx..xx.
.xxx.xxx
.xxx.xxx
144
xx.xxxxx
xx.x..xx
xx....xx
xx.xxxxx
xx.xxxxx
xx.xx...
xxx.x...
xxx.xxxx

152
xx.xxxx.
xx....x.
xx....x.
xx....x.
xx.xxxxx
xx.....x
xxx....x
xxx.xxxx

160
xx.xx..x
xx.xx..x
xx.xx..x
xx.xxxxx
xx....xx
xx....xx
xxx...xx
xxx...xx

168
xx.xxxxx
xx.xx...
xx.xx...
xx.xx...
xx.xxxxx
xx....xx
xxx...xx
xxx.xxxx

176
xx.xxxxx
xx.xx...
xx.xx...
xx.xx...
xx.xxxxx
xx.xx.xx
xxx.x.xx
xxx.xxxx

184
.xx.....
x....x..
xxx.x.x.
..x.x.x.
xx..x.x.
...x.x.x
...x....
...xxxx.

chiptunes
0,0,0,0,0
0,0,0,0,0

6, 5, 4, 12, 5
6, 5, 4, 12, 12
6, 5, 4, 12, 5
12, 9, 12, 7, 4
6, 5, 4, 12, 5
6, 5, 4, 12, 12
6, 5, 4, 12, 12
12, 9, 12, 7, 4

0,0,0,0,0

6, 5, 4, 12, 20
6, 17, 4, 19, 20
6, 5, 4, 12, 20
6, 17, 4, 15, 35
0, 0, 0, 0, 255
29,23,5,10,0

27, 0, 0, 8, 15
24, 8, 0, 8, 17

27, 0, 0, 8, 15
24, 8, 0, 8, 17

27, 0, 0, 8, 15
24, 8, 0, 8, 17
24,24,24,24,0
                                                               
Go to top