===MaxiTrek=== {{ :migratedattachments:mmbasic_original:maxitrek.zip?linkonly}} //This module is part of the original MMBasic library. It is reproduced here with kind permission of Hugh Buckle and Geoff Graham. Be aware it may reference functionality which has changed or is deprecated in the latest versions of MMBasic.// **MAXITREK.BAS**: '**************************** '* MaxiTrek v1.0 - Title * '* a game by Juri Fossaroli * '* mpt@cbmzone.com * '**************************** Mode 4:Dim t$(2):Option error continue Open "A:title.mod" For input As #1 If MM.Errno=0 Then Close 1:GoTo loadall Copy "spchase.mod" To "a:title.mod" loadall: Sprite Load "title.spr" PlayMOD "a:title.mod" LoadBMP "title" Line (0,12)-(181,12),1 t$(1)=" "+CLR$(2)+"< Welcome to the incredible"+CLR$(4)+" MaxiTrek V1.0 @ " t$(1)=t$(1)+CLR$(2)+"created by "+CLR$(6)+"Juri Fossaroli @ "+CLR$(2) t$(1)=t$(1)+">The Arduitrons attacked your planet, it's time to counter " t$(1)=t$(1)+"attack!!! Destroy the entire Arduitrons force and free the " t$(1)=t$(1)+"galaxy!"+String$(29,32) t$(2)=CLR$(2)+" press "+CLR$(3)+"I"+CLR$(2)+" to toggle the command list used " t$(2)=t$(2)+"in game, press "+CLR$(3)+"SPACE"+CLR$(2)+" key to start the " t$(2)=t$(2)+"game..."+String$(6,32)+CLR$(6)+" GOOD LUCK! @" t$(2)=t$(2)+" >"+String$(11,32) SetTick 50,irq l=0:c=1:w=0:wd=0:s=1:wdd=5:cnt=0:i=0 Do cnt=cnt+1 If cnt=1 Then x=30+Int(Rnd(1)*180):y=(50-(x/9))+(Int(Rnd(1)*60))-(x/12):sc=Int(Rnd(1)*3) EndIf If cnt=20 And sc=2 Then Sprite on 7,x,y If cnt=40 And sc=2 Then Sprite off 7:Sprite on 8,x,y If cnt=60 And sc=2 Then Sprite off 8:Sprite on 9,x,y If cnt=80 And sc=2 Then Sprite off 9:Sprite on 8,x,y If cnt=100 And sc=2 Then Sprite off 8:Sprite on 7,x,y If cnt=120 And sc=2 Then Sprite off 7 If cnt=20 And sc=1 Then Sprite on 1,x,y If cnt=40 And sc=1 Then Sprite off 1:Sprite on 2,x,y If cnt=60 And sc=1 Then Sprite off 2:Sprite on 3,x,y If cnt=80 And sc=1 Then Sprite off 3:Sprite on 2,x,y If cnt=100 And sc=1 Then Sprite off 2:Sprite on 1,x,y If cnt=120 And sc=1 Then Sprite off 1 If cnt=20 And sc=0 Then Sprite on 4,x,y If cnt=40 And sc=0 Then Sprite off 4:Sprite on 5,x,y If cnt=60 And sc=0 Then Sprite off 5:Sprite on 6,x,y If cnt=80 And sc=0 Then Sprite off 6:Sprite on 5,x,y If cnt=100 And sc=0 Then Sprite off 5:Sprite on 4,x,y If cnt=120 And sc=0 Then Sprite off 4 If cnt=140 Then cnt=0 a$=Inkey$ If a$="i" Then GoSub shwkys If a$=" " Then GoSub rungame Loop shwkys: If i=0 Then LoadBMP "ti",100,120:i=1:Return If i=1 Then LoadBMP "tr",100,120:i=0:Return rungame: PlayMOD stop Sprite off all SetTick 0,0 Cls:Clear Run "Game" End irq: If c=500 Then c=1:l=0 If c=246 Then l=1:c=256 If s=0 And w=>0 Then w=w-1:IReturn If w=-1 Then w=0:s=1 If wd=0 And l=0 And w=0 Then txt$=Mid$(t$(1),c,1):GoTo stampa If wd=0 And l=1 And w=0 Then txt$=Mid$(t$(2),c-255,1):GoTo stampa wd=wd-1:GoTo stampa2 stampa: c=c+1:wd=wdd If Asc(txt$)>127 And Asc(txt$)<136 Then cl=Asc(txt$)-128 If txt$="@" Then s=0:w=30:txt$="":IReturn If txt$="<" Then s=1:wdd=5:txt$="" If txt$=">" Then s=2:wdd=2:txt$="" stampa2: BLIT 0,0,-1*s,0,181,12:Print @(174+(wd*s),0)Chr$(128+cl)txt$ Line (179,0)-(186,11),0,bf:Line (181,0)-(181,11),1 IReturn ---- **GAME.BAS**: Option base 1:Mode 4:md=1:fr=1:enemy=20 LoadBMP "game":Sprite Load "maxitrek.spr":SetTick 10,engine Dim starx(10),stary(10),starz(10),ox(10),oy(10),map(8,8),cndt$(3),maph(8,8) cndt$(2)=CLR$(4,6)+" RED ":cndt$(1)=CLR$(6,2)+" GREEN " cndt$(3)=CLR$(1,3)+" DOCKED ":Sprite on 7,240,85 Sprite on 1,1,220,0:Sprite on 2,1,220,0:Sprite on 3,1,220,0 Sprite on 4,1,220,0:Sprite on 5,1,220,0:Sprite on 6,1,220,0 energy=100:shields=0:damage=0:dock=0:enpr=0:endam=0:enty=0:lr=1:sh=1:nv=1:mp=1 For t=1 To 8:For e=1 To 8 maph(t,e)=0 Next e,t For e=1 To enemy rifai: ex=Cint(Rnd(1)*7)+1:ey=Cint(Rnd(1)*7)+1 If map(ex,ey)>0 Or ex+ey=2 Then GoTo rifai map(ex,ey)=1 Next e rifai2: px=Cint(Rnd(1)*7)+1:py=Cint(Rnd(1)*7)+1 If map(px,py)>0 Or px+py=2 Then GoTo rifai2 map(px,py)=2 map(1,1)=0:px=1:py=1 Print @(20,8)CLR$(7)"ENERGY: "CLR$(2)" "energy"%"CLR$(7)@(160,8)"CONDITION" Print @(20,21)CLR$(7)"SHIELDS:"CLR$(2)" "shields"%"@(160,20)cndt$(1) std=0 Do a$=Inkey$:If a$="" Then GoTo ggiu If a$="m" Then GoSub showmap:If dock=1 Then GoSub showdock If a$="l" Then GoSub longrange If a$="d" Then GoSub damage 'If a$="c" Then energy=999:damage=0:lr=1:mp=1:sh=1:nv=1:shields=999 If a$="j" Then GoSub hyperjump:If dock=1 Then GoSub showdock If a$="b" Then GoSub battlepc:If dock=1 Then GoSub showdock If enpr=1 Then Sprite move 7,cx,cy,0 If Asc(a$)=128 Then cy=cy-1:If cy<45 Then cy=45 If Asc(a$)=129 Then cy=cy+1:If cy>125 Then cy=125 If Asc(a$)=130 Then cx=cx-1:If cx<10 Then cx=10 If Asc(a$)=131 Then cx=cx+1:If cx>215 Then cx=215 If Asc(a$)=139 And fr=1 Then GoSub fire EndIf ggiu: t=t+1:fr=fr-1:If fr<1Then fr=1 If t=10 And dock=0 Then t=0:GoSub starfield:If enpr=1 Then GoSub updenemy If dock=1 Then damage=0:energy=100:sh=1:nv=1:lr=1:mp=1:Print @(74,8)CLR$(2)energy"% " EndIf If std=>9999 Or energy<=0 Or damage=>100 Then GoTo badend Loop fire: Line(2,144)-(cx+8,cy+8),3:Line(237,144)-(cx+8,cy+8),3 dur=100:dt=50:energy=energy-1:SetTick 5,laser:Pause 250 Line(2,144)-(cx+8,cy+8),0:Line(237,144)-(cx+8,cy+8),0 If cx-ex<=3 And cx-ex=>-3 Then If cy-ey<=3 And cy-ey=>-3 Then dur=100:SetTick 5,boom:GoSub enemyhit EndIf fr=150 Return enemyhit: endam=Int(endam+(20-(enty*2.5))):If endam>100 Then endam=100 Print@(203,190)CLR$(5)endam"%"@(74,8)CLR$(2)energy"% " If endam=100 Then enpr=0:map(px,py)=0:enemy=enemy-1:dur=100:SetTick 10,boom Sprite move 7,1,220,0 Sprite move enty,1,220,0:Sprite on 8,ex,ey,0:Pause 300 Sprite off 8:Sprite on 9,ex,ey,0:Pause 300 Sprite off 9:Sprite on 10,ex,ey,0:Pause 300:Sprite off 10 Line(203,190)-(232,202),0,bf Print @(160,20)cndt$(enpr+1) If enemy=0 Then Line(100,100)-(100,100),0,bf:Print @(80,180)"Return to base" EndIf Return updenemy: mm=Int(Rnd(1)*20)+1:If mm>4 Then Return If mm=1 Then ey=ey-2:If ey<45 Then ey=45 If mm=2 Then ey=ey+2:If ey>125 Then ey=125 If mm=3 Then ex=ex-2:If ex<10 Then ex=10 If mm=4 Then ex=ex+2:If ex>215 Then ex=215 Sprite move enty,ex,ey,0:Pause 100 mm=Int(Rnd(1)*40)+1:If mm>39 Then GoSub enfire Return enfire: Line(ex+8,ey+8)-(112,144),4 dur=100:dt=50:SetTick 1,enemy:Pause 250 Line(ex+8,ey+8)-(112,144),0 If shields=>5 Then shields=shields-5:dur=100:SetTick 5,shield If shields<5 Then damage=damage+5:dur=100:SetTick 5,boom:GoSub damage If damage=>20 Then lr=0 If damage=>40 Then mp=0 If damage=>60 Then nv=0 If damage=>80 Then sh=0 Print @(74,8)CLR$(2)energy"% ":Print @(74,21)CLR$(2)shields"% " Return initenemy: enty=Int(Rnd(1)*5)+1:If enemy=1 Then enty=6 ex=30+Int(Rnd(1)*130):ey=60+Int(Rnd(1)*70):endam=0 Sprite move enty,ex,ey,0:Print@(203,190)CLR$(5)endam"%" Return battlepc: Line(60,167)-(179,204),0,bf:Line(2,40)-(237,144),0,bf Print @(40,42)CLR$(2,1)" BATTLE COMPUTER - ONLINE " Print @(40,60)CLR$(2)" Systems energy: "energy"% " Print @(40,75)CLR$(3)" Hull integrity: "100-damage"% " Print @(40,90)CLR$(5)" Shields power: "shields"% " Print @(40,105)CLR$(6)" Enemys left:"CLR$(4)" "enemy Print @(30,120)CLR$(2,1)" Press"CLR$(3,1)" S "CLR$(2,1)"to set shields power" GoSub waitkey If a$="s" Then oe=energy+(Cint(shields/1.2)) If sh=0 Then Print @(60,168)CLR$(4)"Shield system damage" Print @(60,180)CLR$(4)"shields level to 20%" Print @(62,192)CLR$(4)"if energy available" shields=20 EndIf If sh=1 Then Print @(62,168)CLR$(3)"press 1 to 9 to set" Print @(62,180)CLR$(3)" shields level or " Print @(60,192)CLR$(3)"press X to max power" pupu: GoSub waitkey a1=Val(a$):If a1<1 Or a1>9 And a$<>"x" Then GoTo pupu If a1>0 And a1<10 Then shields=a1*10 If a$="x" Then shields=100 EndIf energy=oe-(Cint(shields/1.2)) If energy<0 Then shields=shields-(Cint((Abs(energy)-5)/1.2)):energy=5 EndIf Print @(74,8)CLR$(2)energy"% ":Print @(74,21)CLR$(2)shields"% " Line(60,167)-(179,204),0,bf:Line(2,40)-(237,144),0,bf Return goodend: t=KeyDown:If t<>0 Then GoTo goodend SetTick 0,0 Line(60,167)-(179,204),0,bf Print @(66,46,1)CLR$(0)"CONGRATULATIONS!!!" Print @(65,45,1)CLR$(5)"CONGRATULATIONS!!!" Print @(36,61,1)CLR$(0)"You destroyed all Arduitrons" Print @(35,60,1)CLR$(5)"You destroyed all Arduitrons" Print @(16,76,1)CLR$(0)"and bring back peace in the galaxy!" Print @(15,75,1)CLR$(5)"and bring back peace in the galaxy!" Pause 1000 Print @(55,120)CLR$(3,1)" PRESS A KEY TO END " GoSub waitkey:Cls Run "maxitrek" End badend: t=KeyDown:If t<>0 Then GoTo badend SetTick 0,0 Line(60,167)-(179,204),0,bf:Line(2,40)-(237,144),0,bf Print @(55,45)CLR$(3)"You failed your mission" Print @(35,60)CLR$(3)"to defeat the Arduitrons force" Print @(65,75)CLR$(3)"and free the galaxy.." Pause 1000 If std=>9999 Then Print @(50,90)CLR$(6)"You didn't make it in time" If energy<=0 Then Print @(65,90)CLR$(6)"You run out of energy" If damage=>100 Then Print @(68,90)CLR$(6)"You was destroyed !!" Pause 1000 Print @(55,120)CLR$(3,1)" PRESS A KEY TO END " GoSub waitkey:Cls Run "maxitrek" End showdock: LoadBMP "dock",2,40:Line(238,40)-(238,144),1 Print @(160,20)cndt$(3):If enemy=0 Then GoTo goodend Return hyperjump: If enpr=1 Then Sprite move enty,1,220,0 Line(60,167)-(179,204),0,bf:Line(2,40)-(237,144),0,bf Print @(25,40)CLR$(3,1)" Navigation system - JUMP DRIVE " Print @(57,60)CLR$(2)"Current ship position" Print @(87,74)CLR$(3)"sector "Str$(px)","Str$(py) Print @(33,94)CLR$(5)"Alien presence in this sector" If map(px,py)=0 Then Print @(87,108)CLR$(2)"sector free" If map(px,py)=1 Then Print @(77,108)CLR$(4)"sector occupied" If map(px,py)=2 Then Print @(100,108)CLR$(2)"docked" Print @(55,130)CLR$(6,2)" Jump drive: "CLR$(7,2)"*READY* " If nv=0 Then Print @(127,130)CLR$(6,4)"*DAMAGED*" Print @(67,170)CLR$(7)"Insert destination" Line(90,183)-(150,198),7,b:tx=0:ty=0 gtcoord: a$=Inkey$ tz=Val(a$):If tz=9 Or tz=0 Then a$="" If tz>0 And tz<9 And tx=0 Then tx=Val(a$):a$="" If tz>0 And tz<9 And ty=0 Then ty=Val(a$) If tx<>0 Then Print @(105,186,1)CLR$(5)Str$(tx)" ,":Pause 100 If ty<>0 Then Print @(127,186,1)CLR$(5)Str$(ty):Pause 100 If a$="" Then GoTo gtcoord If px=tx And py=ty Then Pause 200:Line(60,167)-(179,204),0,bf Print @(75,180)CLR$(2)"Jump not needed" Pause 1000:Line(60,167)-(179,204),0,bf Line(2,40)-(237,144),0,bf:Return EndIf px=tx:py=ty jumpseq: Print @(160,20)cndt$(1) If nv=0 Then px=px+Cint(Rnd(1)*2)-1:py=py+Cint(Rnd(1)*2)+1 If px=tx And py=ty Then GoTo jumpseq If px=0 Then px=1 If px=9 Then px=8 If py=0 Then py=1 If py=9 Then py=8 EndIf Pause 500:Line(60,167)-(179,204),0,bf:Line(2,40)-(237,144),0,bf Print @(90,168)CLR$(2)"Destination" Print @(93,180)CLR$(2)" acquired" Print @(87,192)CLR$(2)"successfully":tx=0:dock=0 Do tx=tx+1 For ty=1 To 10:GoSub starfield:Next ty:Pause 50 Loop Until tx=15 Line(60,167)-(179,204),0,bf:dur=100:ph=0:SetTick 2,jump Print @(63,180)CLR$(6)"Charging Hyperdrive" Pause 1900:Line(60,167)-(179,204),0,bf Print @(70,180)CLR$(5)" - JUMPING -" Pause 650:Line(60,167)-(179,204),0,bf If nv=1 Then Print @(70,180)CLR$(2)"Jump Successfull!" If nv=0 Then Print @(70,170)CLR$(4)" Jump failed!"@(70,185)" Wrong position!" Pause 1000:Line(60,167)-(179,204),0,bf enpr=map(px,py):energy=energy-15 If enpr=2 Then dock=1:enpr=0:SetTick 0,0 If enpr=1 Then dur=100:rp=3:cx=112:cy=85:SetTick 4,alarm:GoSub initenemy If enpr=0 Then Sprite move 7,240,85:Line(203,190)-(227,202),0,bf Print @(160,20)cndt$(enpr+1)@(74,8)CLR$(2)energy"% " Return damage: Line(60,167)-(179,204),0,bf Print @(60,168)CLR$(4)"DAMAGES:":cl=2 If damage=>50 Then cl=6 If damage=>80 Then cl=4 Print @(110,168)CLR$(cl)" Hull "Str$(100-damage)"%" If lr=1 And mp=1 And nv=1 And sh=1 Then Print @(90,185)CLR$(2)"NO DAMAGES" If lr=0 Then Print @(60,180)CLR$(4)"Long Range" If mp=0 Then Print @(138,180)CLR$(4)"Map" If nv=0 Then Print @(60,192)CLR$(4)"Navigation" If sh=0 Then Print @(138,192)CLR$(4)"Shields" Return longrange: If enpr=1 Then Return If lr=0 Then Line(60,167)-(179,204),0,bf Print @(63,172,1)CLR$(4)"Long range scanners" Print @(63,188,1)CLR$(4)" damaged" Return EndIf Line(60,167)-(179,204),0,bf sgx=px-1:egx=px+1:sgy=py-1:egy=py+1 If sgx=0 Then sgx=1 If egx=9 Then egx=8 If sgy=0 Then sgy=1 If egy=9 Then egy=8 For t=sgx To egx:For t1=sgy To egy maph(t,t1)=1 Next t1,t For x=-1 To 1:For y=-1 To 1 sgx=px+x:sgy=py+y:a$="" If sgx=0 Then a$=CLR$(7)+"X" If sgx=9 Then a$=CLR$(7)+"X" If sgy=0 Then a$=CLR$(7)+"X" If sgy=9 Then a$=CLR$(7)+"X" If a$="" Then t=map(sgx,sgy) If t=0 Then a$=CLR$(7)+"." If t=1 Then a$=CLR$(4)+"*" If t=2 Then a$=CLR$(2)+"o" EndIf Print @(75+(x*10),181+(y*10),1)a$ Next y,x Line(72,170)-(72,200),7:Line(82,170)-(82,200),7 Line(62,180)-(92,180),7:Line(62,190)-(92,190),7 Print @(75,181,1)CLR$(3)"+"@(100,168)CLR$(6,1)" Long range " Print @(97,182)CLR$(4)"*"CLR$(7)"Enemy "CLR$(3)"+"CLR$(7)"Ship" Print @(97,194,1)CLR$(7)".Space "CLR$(2)"o"CLR$(7)"Planet" Return showmap: If mp=0 Then Line(60,167)-(179,204),0,bf Print @(61,180,1)CLR$(4)"Map computer damaged" Return EndIf Line(2,40)-(237,144),0,bf Print @(80,40)CLR$(6,1)" STARMAP " For t=0 To 8 Line(20,64+(10*t))-(100,64+(10*t)),7 Line(20+(10*t),64)-(20+(10*t),144),7 If t>0 Then Print @(7+(10*t),54,1)t:Print @(7,54+(10*t),1)t Next t For mx=1 To 8:For my=1 To 8 t=map(mx,my):h=maph(mx,my) If t=1 And h=1 Then Print @(13+(10*mx),55+(10*my),1)CLR$(4)"*" If t=2 And h=1 Then Print @(13+(10*mx),54+(10*my),1)CLR$(2)"o" If t=0 And h=1 Then Print @(13+(10*mx),52+(10*my),1)CLR$(7)"." Next my,mx Print @(13+(10*px),55+(10*py),1)CLR$(3)"+" Print @(110,64)CLR$(3)"+"CLR$(6)" - your ship" Print @(110,76)CLR$(4)"*"CLR$(6)" - enemy force" Print @(110,88)CLR$(2)"o"CLR$(6)" - planet" Print @(110,98,1)CLR$(7)"."@(116,100)CLR$(6)" - free space" Print @(110,125)CLR$(6)"your position:"CLR$(3)px","py GoSub waitkey Line(2,40)-(237,144),0,bf Return waitkey: a$=Inkey$ If a$="" Then GoTo waitkey Return boom: r=Int(Rnd(1)*dur):dur=dur-.6 PWM 20000,r,r If dur<1 Then PWM stop:SetTick 10,engine IReturn laser: r=Int(Rnd(1)*dur):dur=dur-3:dt=dt-1 PWM 21+(dur*100),dt,dt If dur<3 Then PWM stop:SetTick 10,engine IReturn enemy: dur=dur-3:fq=Int(Rnd(1)*5000)+1000 If dur<5 Then PWM stop:SetTick 10,engine:IReturn If dt=50 Then dt=0:PWM fq,dt,dt:IReturn If dt=0 Then dt=50:PWM fq,dt,dt:IReturn jump: If ph=0 Or ph=2 Then dur=dur-.1 If ph=1 Then dur=dur-1:r=Int(Rnd(1)*100) If ph=0 Then Tone 2101-(dur*20),2101-(dur*20) If ph=1 Then PWM 20000,r,r:PWM 40000,r,r:GoSub starfield If ph=2 And dur>99 Then Line(90,85)-(150,95),0,bf:IReturn If ph=2 Then Tone 101+(dur*20),101+(dur*20):dur=dur-.2 Line(1+dur,40+(dur/2))-(238-dur,144-(dur/2)),0,b EndIf If dur<1 And ph=0 Then ph=1:dur=1500:md=0 If dur<1 And ph=1 Then ph=2:dur=100 If dur<1 And ph=2 Then Tone 40,40,10:PWM stop:SetTick 10,engine:md=1:IReturn IReturn shield: dur=dur-1 Tone 100+dur,100+dur If dur<1 Then Tone 1,1,0:PWM stop:SetTick 10,engine:IReturn IReturn alarm: dur=dur-.5 If dur<1 Then rp=rp-1:dur=100 Tone 400-(dur*2),400-(dur*2) If rp=0 Then Tone 20,20,10:SetTick 10,engine:IReturn IReturn engine: std=std+.1 r=Int(Rnd(1)*10):PWM 20000,r,r:Print @(10,192)Format$(std/10,"%05.1f") IReturn starfield: star=star-1:If star<1 Then star=10 If starx(star)=0 Or stary(star)=0 Then starx(star)=Int(Rnd(1)*40)-20:stary(star)=Int(Rnd(1)*40)-20 starz(star)=(Int(Rnd(1)*50)/100)+0.50 EndIf If md=1 Then Pixel(ox(star),oy(star))=0 x=(starx(star)/starz(star))+120 y=(stary(star)/starz(star))+92 If starz(star)>.3 Then cl=3 Else cl=7 If starz(star)>.6 Then cl=1 starz(star)=starz(star)-0.025 If x>2 And x<237 And y>40 And y<144 Then Pixel(x,y)=cl:ox(star)=x:oy(star)=y If x<2 Or x>237 Or y<40 Or y>144 Then starx(star)=0:stary(star)=0 Return