***program start*** 10 '=========== SHOOTING ============= 20 GameTitle="SHOOTING" 30 ScWidth=128:ScHight=64 40 FontWidth=6:FontHight=8:BarWidth=3 50 ScoreStr="SCORE":HiScoreStr="HISCO":StageStr="STAGE" 60 BgWidth=ScWidth-strlen(ScoreStr)*FontWidth-BarWidth*2-1 70 BgHight=ScHight*2 80 fm1=createFM(BgWidth,BgHight) 90 fm2=createFM(BgWidth,BgHight):gosub 1000: 'draw background 100 Score=0:Stage=0 110 HighScoreNum=ScHight/FontHight-3 120 dim HighScore[HighScoreNum]:gosub 9060 130 if (keyA()<>1)||(keyB()<>1) then gosub 8100 : 'read HighScore 140 gosub 1200 : ' define My Char 350 gosub 5000 : ' temp stage 400 '=========== Main Routine ============= 410 'while -1 420 ' gosub 10000 :' Demo 430 ' while -1 440 ' gosub 1000 :' Stage 450 ' if gameOver=1 then gosub 11000:exit while 460 ' if gameClear=1 then gosub 12000 470 ' end while 480 'end while 500 end 1000 '--------- draw background ------------------ 1010 bm1=createBM(1,1) 1020 setBM bm1,0,"1" 1030 cls F,fm1:cls F,fm2 1040 for i=0 to 300 1050 if (i/3)*3=i then a=rand() else a=255-rand() 1060 if (i/2)*2=i then b=rand() else b=255-rand() 1070 put a*BgWidth/255,b*BgHight/255,bm1,set,F,fm1 1080 ' next 1090 ' for i=0 to 300 1100 if (i/2)*2=i then a=rand() else a=255-rand() 1110 if (i/3)*3=i then b=rand() else b=255-rand() 1120 put a*BgWidth/255,b*BgHight/255,bm1,set,F,fm2 1130 next 1150 return 1200 '--------- define My Char ------------------ 1210 MyChar=createBM(10,5) 1220 setBM MyChar,0,"0001111000" 1230 setBM MyChar,1,"0011001100" 1235 setBM MyChar,2,"0110000110" 1240 setBM MyChar,3,"1111111111" 1250 setBM MyChar,4,"1111001111" 1300 MyCharMask=createBM(12,7) 1310 setBM MyCharMask,0,"111100001111" 1320 setBM MyCharMask,1,"111000000111" 1330 setBM MyCharMask,2,"110000000011" 1335 setBM MyCharMask,3,"100000000001" 1340 setBM MyCharMask,4,"000000000000" 1350 setBM MyCharMask,5,"000000000000" 1360 setBM MyCharMask,6,"000000000000" 1370 MyWidth=10:MyHight=5:MyHGap=3 1380 return 2000 '--------- show background ------------------ 2010 if BgY1+ScHight-120 then lCount=10 2330 if R=1 then rCount=rCount+1 else rCount=0 2335 if rCount>20 then rCount=10 2340 if U=1 then uCount=uCount+1 else uCount=0 2345 if uCount>20 then uCount=10 2350 if D=1 then dCount=dCount+1 else dCount=0 2355 if dCount>20 then dCount=20 2360 if L=1 then MyX=MyX-(1+lCount/4) 2370 if R=1 then MyX=MyX+(1+rCount/4) 2380 if U=1 then MyY=MyY-(1+uCount/4) 2390 if D=1 then MyY=MyY+(1+dCount/4) 2400 if MyXScHight-MyHGap then MyY=ScHight-MyHight-MyHGap 2440 put MyX-1,MyY-1,MyCharMask,and,F 2450 put MyX,MyY,MyChar,or,F 2460 return 5000 '=============== STAGE =============== 5010 count=0:cls 5020 MyX=BarWidth+BgWidth/2-MyWidth/2 5030 MyY=ScHight-MyHight-MyHGap 5040 scAreaX=BarWidth*2+BgWidth 5130 y=0:gameClear=0:gameOver=0 5140 putStr scAreaX,y,StageStr,1 : y=y+FontHight : StageY=y 5150 gosub 6020 : y=y+FontHight : 'Disp Stage 5160 putStr scAreaX,y,HiScoreStr,1 : y=y+FontHight : HiScoreY=y 5170 gosub 6040 : y=y+FontHight : 'Disp HiScore 5180 putStr scAreaX,y,ScoreStr,1 : y=y+FontHight : ScoreY=y 5190 gosub 6080 : y=y+FontHight : 'Disp Score 5200 BgY1=0:BgY2=0:BgSpeed1=1:BgSpeed2=2 5210 while count<10 5230 gosub 2000 : ' show background 5235 '---------- move background --------------- 5240 BgY1=BgY1-BgSpeed1:BgY2=BgY2-BgSpeed2 5250 if BgY1<0 then BgY1=BgY1+BgHight:count=count+1 5260 if BgY2<0 then BgY2=BgY2+BgHight 5270 gosub 2300 : ' move My Char 5450 update BarWidth,0,BarWidth+BgWidth-1,ScHight-1 5500 end while 5510 return 6000 '----- STAGE Sub ----- 6010 'Disp Stage 6020 putStr scAreaX,StageY,format("%-5D",Stage),1 6030 return 6040 'Disp HighScore 6050 gosub 9000 6060 putStr scAreaX,HiScoreY,format("%-5D",HiScore),1 6070 return 6080 'Disp Score 6090 putStr scAreaX,ScoreY,format("%-5D",Score),1 6100 return 8000 '-------- saveHiscore ------------ 8010 addr=0 8020 write addr,GameTitle:addr=addr+16 8030 for i=0 to HighScoreNum-1 8040 write addr,format("%D",HighScore[i]):addr=addr+16 8050 next 8060 return 8100 '-------- readHiscore ------------ 8110 addr=0 8120 if GameTitle=read(addr,strlen(GameTitle)) then 8125 addr=addr+16 8130 for i=0 to HighScoreNum-1 8140 HighScore[i]=val(read(addr,5)):addr=addr+16 8150 next 8160 end if 8170 return 9000 '---------get HiScore------------- 9010 HiScore=0:MinHiScore=100000 9020 for i=0 to HighScoreNum-1 9030 if HighScore[i]>HiScore then HiScore=HighScore[i] 9035 if MinHiScore>HighScore[i] then MinHiScore=HighScore[i] 9040 next 9050 return 9060 '--------HiScore Initial---------- 9070 for i=0 to HighScoreNum-1 9080 HighScore[i]=0 9090 next 9095 return ***program end***