rem set tv pal set tv ntsc set smartbranching on set kernel_options pfcolors init player1x = 40 : player1y = 40 player0x = 50 : player0y = 88 COLUPF = 90:missile0height=4:missile0y=255 score=0 missile1height=2 rem ballheight=4 rem ballx=50 : bally=50 rem ---- $31 = ball 8 pixels wide rem CTRLPF = $31 dim castle_height=b castle_height=0 dim enemy_speed=e enemy_speed=7 dim enemy_firing=f dim level=g dim got_block=h dim enemy_colour=i rem --- sound duration counters dim thr_cnt=j thr_cnt=0 dim gblk_cnt=k gblk_cnt=0 dim dblk_cnt=l dblk_cnt=0 dim ehit_cnt=m ehit_cnt=0 dim hhit_cnt=n hhit_cnt=0 dim lifes=o lifes=3 dim enemy_step=p enemy_step=1 enemy_colour=78 got_block=0 enemy_firing=0 level=1 pfcolors: $50 $47 $45 $43 $41 $40 $39 $38 $37 $36 $f5 end player0: %00010000 %01010100 %00111000 %00010000 %00111000 %01111100 %11010110 %10111010 end changebg rem --- set sound duration on block drop dblk_cnt = 10 rem --- keep the castle at max height till the alien is rem --- killed. don't play sound on full castle block drop if castle_height > 9 then castle_height = 9: dblk_cnt=0 rem ---- changes the background based on the rem ---- value of castle_height (b) on castle_height goto pf1 pf2 pf3 pf4 pf5 pf6 pf7 pf8 pf9 pf10 pf10 playfield: ................................ .XX.XX.XX....................... .XXXXXXXX....................... .X..XX..X....................... .XXXXXXXX....................... ..XXXXXX........................ ..XX..XX........................ ..XXXXXX........................ ..XX..XX........................ ..XXXXXX........................ .XXXXXXXX......................X end level = level + 1 score = score + 100 goto mainloop pf9 playfield: ................................ ................................ .XXXXXXXX....................... .X..XX..X....................... .XXXXXXXX....................... ..XXXXXX........................ ..XX..XX........................ ..XXXXXX........................ ..XX..XX........................ ..XXXXXX........................ .XXXXXXXX.....................XX end goto mainloop pf8 playfield: ................................ ................................ ................................ .X..XX..X....................... .XXXXXXXX....................... ..XXXXXX........................ ..XX..XX........................ ..XXXXXX........................ ..XX..XX........................ ..XXXXXX........................ .XXXXXXXX...................XXXX end goto mainloop pf7 playfield: ................................ ................................ ................................ ................................ .XXXXXXXX....................... ..XXXXXX........................ ..XX..XX........................ ..XXXXXX........................ ..XX..XX........................ ..XXXXXX........................ .XXXXXXXX.................XXXXXX end goto mainloop pf6 playfield: ................................ ................................ ................................ ................................ ................................ ..XXXXXX........................ ..XX..XX........................ ..XXXXXX........................ ..XX..XX........................ ..XXXXXX......................XX .XXXXXXXX.................XXXXXX end goto mainloop pf5 playfield: ................................ ................................ ................................ ................................ ................................ ................................ ..XX..XX........................ ..XXXXXX........................ ..XX..XX........................ ..XXXXXX....................XXXX .XXXXXXXX.................XXXXXX end goto mainloop pf4 playfield: ................................ ................................ ................................ ................................ ................................ ................................ ................................ ..XXXXXX........................ ..XX..XX........................ ..XXXXXX..................XXXXXX .XXXXXXXX.................XXXXXX end goto mainloop pf3 playfield: ................................ ................................ ................................ ................................ ................................ ................................ ................................ ................................ ..XX..XX......................XX ..XXXXXX..................XXXXXX .XXXXXXXX.................XXXXXX end goto mainloop pf2 playfield: ................................ ................................ ................................ ................................ ................................ ................................ ................................ ................................ ............................XXXX ..XXXXXX..................XXXXXX .XXXXXXXX.................XXXXXX end goto mainloop pf1 playfield: ................................ ................................ ................................ ................................ ................................ ................................ ................................ ..............................XX ............................XXXX ..........................XXXXXX .XXXXXXXX.................XXXXXX end goto mainloop mainloop scorecolor = 10 NUSIZ0=16 rem -- $27=quad size, $25=double size enemy NUSIZ1=$25 COLUP1 = enemy_colour COLUP0 = 80+(lifes*16) player1: %00100100 %01111110 %11111111 %11010101 %01111110 %11111111 %00111100 %00011000 end rem pfclear %10101010 rem ---- a reduces the number of times the rem ---- wrapping checks are called .... if enemy_speed < 1 then enemy_speed = 1: enemy_step=2 a = a + 1 : if a < enemy_speed then 55 a = 0 rem ---- enemy following rules rem ---- player1x range = 0-159 rem ---- player1y range = 0-88 if player1x < player0x then player1x = player1x + enemy_step if player1x > player0x then player1x = player1x - enemy_step player1x = player1x : player1y = player1y rem -------------------------------------------- rem ---- increment thrown block only if it's still on screen 55 if missile0y>240 then goto 58 missile0y=missile0y-2:goto 59 rem ---- throw your block at the enemy ... 58 if joy0fire then if got_block=1 then missile0y=player0y-2:missile0x=player0x+4:got_block=0:gosub hero_noblock 59 drawscreen rem -------------------------------------------- rem --- increment enemy missile with rem --- the enemy movement rem --- in evil higher levels, make missile1x=player0x if enemy_firing = 1 then missile1y=missile1y+2:if level <= 3 then missile1x=player1x+(rand/64) else missile1x=player0x+(rand/16) if missile1y<2 then missile1y=255:enemy_firing=0:goto 61 if player1x = player0x && enemy_firing=0 then missile1y=player1y:enemy_firing=1:thr_cnt=10 rem ---- thrown block hits enemy, enemy cycle colour 61 if collision(missile0,player1) then score=score+1:player1x=rand/2:player1y=40:missile0y=255:enemy_colour=enemy_colour-2:ehit_cnt=15 rem ---- enemy colour change cycle and level completion if enemy_colour=64 then enemy_colour=78:score=score+10:if castle_height >= 9 then castle_height=0:enemy_speed=enemy_speed-1:goto changebg rem ---- missile hits hero if collision(missile1,player0) then missile1y=255:got_block=0:hhit_cnt=5:lifes=lifes-1:gosub hero_noblock:if lifes > 0 then player0x=5 if joy0left then player0x = player0x - 1 if joy0right then player0x = player0x + 1 rem --- give the hero a block if they go to the pile if player0x > 112 && got_block = 0 then got_block=1:gosub hero_gotblock rem --- build the castle if we get to the other side rem --- carrying a block if player0x < 55 && got_block=1 && castle_height < 9 then got_block=0:castle_height=castle_height+1:gosub hero_noblock:goto changebg rem --- sounds if thr_cnt > 1 then AUDV1 = 5 : AUDC1 = 3 : AUDF1 = 4 : thr_cnt = thr_cnt - 1 if ehit_cnt > 1 then AUDV1 = 10 : AUDC1 = 8 : AUDF1 = 20 : ehit_cnt = ehit_cnt - 1 if hhit_cnt > 1 then AUDV1 = 10 : AUDC1 = 1 : AUDF1 = 20 : hhit_cnt = hhit_cnt - 1 if gblk_cnt > 1 then AUDV0 = 10 : AUDC0 = 12 : AUDF0 = 31 : gblk_cnt = gblk_cnt - 1 if dblk_cnt > 1 then AUDV0 = 10 : AUDC0 = 12 : AUDF0 = 10+(dblk_cnt*2) : dblk_cnt = dblk_cnt - 1 if gblk_cnt <= 1 && dblk_cnt <= 1 then AUDV0 = 0 if thr_cnt <= 1 && ehit_cnt <= 1 && hhit_cnt <=1 then AUDV1 = 0 dead if lifes = 0 goto hero_dead if switchreset then reboot goto mainloop hero_gotblock player0: %00010011 %01010011 %00111111 %00010011 %00111000 %01111100 %11010110 %10111010 end rem --- for setting sound duration gblk_cnt=5 return hero_noblock player0: %00010000 %01010100 %00111000 %00010000 %00111000 %01111100 %11010110 %10111010 end return hero_dead player0: %00000000 %01000011 %00100110 %10101111 %01110111 %00101111 %01000110 %00000011 end drawscreen AUDV0 = 0 AUDV1 = 0 goto dead