rem Leonard rem by rem Static Gerbil rem www.rbm.com.au/staticgerbil rem set variable values i might need msfirerate=10 : mshealth=100 : msspeed=5: msrange=180 msdamage=7 m1x=100 : m1y=80 : m1frame=0 : m1height=50 : m1fire=0 m1weapon=0 : m1firerate=10 : m1firedelay=0 : m1health=100 m1face=0 : m1range=180 : m1dr=0 : m1yold=0 : m1speed=5 m1damage=7 : m1cash=1000 : m1bonus=0 m2x=600 : m2y=80 : m2frame=0 : m2height=50 : m2health=100 m2range=180 : m2speed=5 : m2firerate=10 : m2damage=7 m2cash=1000 : m2bonus=0 gravity=10 draw=0 m1frameskip=0 platno=10 dim platx(platno):dim platy(platno):dim platlen(platno) screenoff=0 players=2 levlen=1800 difficulty=3 rem make a function that will draw the men sub setframe() if walk=1 then m1frameskip=m1frameskip+1 if m1frameskip>4 then m1frameskip=0 fi if m1frameskip=1 then m1frame=m1frame+1 fi if m1frame>1 then m1frame=0 fi fi if walk2=1 then m2frameskip=m2frameskip+1 if m2frameskip>4 then m2frameskip=0 fi if m2frameskip=1 then m2frame=m2frame+1 fi if m2frame>1 then m2frame=0 fi fi end sub sub drawmen() rem man1 setrgb 1,20,20,150 fill circle m1x,m1y,10 line m1x,m1y+10,m1x,m1y+30 if m1g=1 then if m1frame=0 then if m1face=0 then line m1x+10,m1y+20,m1x,m1y+20 else line m1x-10,m1y+20,m1x,m1y+20 fi line m1x,m1y+30,m1x-10,m1y+50 line m1x,m1y+30,m1x+10,m1y+50 fi if m1frame=1 then if m1face=0 then line m1x+10,m1y+20,m1x,m1y+20 else line m1x-10,m1y+20,m1x,m1y+20 fi line m1x,m1y+30,m1x-2,m1y+50 line m1x,m1y+30,m1x+2,m1y+50 fi fi if m1g=0 then if m1face=0 then line m1x+10,m1y+20,m1x,m1y+20 line m1x,m1y+30,m1x+5,m1y+20 line m1x+5,m1y+20,m1x+15,m1y+40 else line m1x-10,m1y+20,m1x,m1y+20 line m1x,m1y+30,m1x-5,m1y+20 line m1x-5,m1y+20,m1x-15,m1y+40 fi fi setrgb 1,0,0,0 if m1face=0 then line m1x+10,m1y+23,m1x+10,m1y+16 line m1x+7,m1y+16,m1x+17,m1y+16 else line m1x-10,m1y+23,m1x-10,m1y+16 line m1x-7,m1y+16,m1x-17,m1y+16 fi if m1fire=1 then setrgb 1,176,189,52 if m1firedelay>m1firerate-3 then if m1face=0 then fill triangle m1x+20,m1y+15 to m1x+30,m1y+10 to m1x+30,m1y+20 else fill triangle m1x-20,m1y+15 to m1x-30,m1y+10 to m1x-30,m1y+20 fi fi m1firedelay=m1firedelay+1 if m1firedelay>m1firerate then m1firedelay=0 fi fi if m1dr=1 then setrgb 1,0,0,0 line m1x+m1range,m1y,m1x+m1range,m1y+40 line m1x-m1range,m1y,m1x-m1range,m1y+40 fi rem man2 setrgb 1,150,20,20 fill rectangle m2x-10-screenoff,m2y-10,m2x+10-screenoff,m2y+10 line m2x-screenoff,m2y+10,m2x-screenoff,m2y+30 if m2g=1 then if m2frame=0 then if m2face=0 then line m2x+10-screenoff,m2y+20,m2x-screenoff,m2y+20 else line m2x-10-screenoff,m2y+20,m2x-screenoff,m2y+20 fi line m2x-screenoff,m2y+30,m2x-10-screenoff,m2y+50 line m2x-screenoff,m2y+30,m2x+10-screenoff,m2y+50 fi if m2frame=1 then if m2face=0 then line m2x+10-screenoff,m2y+20,m2x-screenoff,m2y+20 else line m2x-10-screenoff,m2y+20,m2x-screenoff,m2y+20 fi line m2x-screenoff,m2y+30,m2x-2-screenoff,m2y+50 line m2x-screenoff,m2y+30,m2x+2-screenoff,m2y+50 fi fi setrgb 1,0,0,0 if m2face=0 then line m2x+10-screenoff,m2y+23,m2x+10-screenoff,m2y+16 line m2x+7-screenoff,m2y+16,m2x+17-screenoff,m2y+16 else line m2x-10-screenoff,m2y+23,m2x-10-screenoff,m2y+16 line m2x-7-screenoff,m2y+16,m2x-17-screenoff,m2y+16 fi if m2g=0 then if m2face=0 then line m2x+10-screenoff,m2y+20,m2x-screenoff,m2y+20 line m2x-screenoff,m2y+30,m2x+5-screenoff,m2y+20 line m2x+5-screenoff,m2y+20,m2x+15-screenoff,m2y+40 else line m2x-10-screenoff,m2y+20,m2x-screenoff,m2y+20 line m2x-screenoff,m2y+30,m2x-5-screenoff,m2y+20 line m2x-5-screenoff,m2y+20,m2x-15-screenoff,m2y+40 fi fi if m2fire=1 then setrgb 1,176,189,52 if m2firedelay>m2firerate-3 then if m2face=0 then fill triangle m2x+20-screenoff,m2y+15 to m2x+30-screenoff,m2y+10 to m2x+30-screenoff,m2y+20 else fill triangle m2x-20-screenoff,m2y+15 to m2x-30-screenoff,m2y+10 to m2x-30-screenoff,m2y+20 fi fi m2firedelay=m2firedelay+1 if m2firedelay>m2firerate then m2firedelay=0 fi fi if m2dr=1 then setrgb 1,0,0,0 line m2x+m2range-screenoff,m2y,m2x+m2range-screenoff,m2y+40 line m2x-m2range-screenoff,m2y,m2x-m2range-screenoff,m2y+40 fi end sub sub drawhealth() setrgb 1,50,50,200 text 40,40,"Leonard" fill rectangle 40,50,40+m1health,60 setrgb 1,200,50,50 text 500,40,"Frank" fill rectangle 600,50,600-m2health,60 end sub rem make a function that will get joypad movement sub getjoy() rem get info from joy 1 joy=peek("port1") m1fire=0 m1dr=0 walk=0 walk2=0 if and(joy,2048)=0 then m1firedelay=0 fi if joy<>0 then if and(joy,128)<>0 then m1x=m1x-m1speed m1face=1 if m1g=1 then walk=1 fi if and(joy,1024)<>0 then m1face=0 fi fi if and(joy,32)<>0 then m1x=m1x+m1speed m1face=0 if m1g=1 then walk=1 fi if and(joy,1024)<>0 then m1face=1 fi fi if and(joy,16384)<>0 then if and(joy,64)<>0 then if m1g=1 then m1upf=3 m1g=0 fi fi if and(joy,64)=0 then if m1g=1 then m1upf=7 m1g=0 fi fi fi if and(joy,2048)<>0 then m1fire=1 fi if and(joy,512)<>0 then m1dr=1 fi fi if players=2 then joy=peek("port2") m2fire=0 m2dr=0 if and(joy,2048)=0 then m2firedelay=0 fi if joy<>0 then if and(joy,128)<>0 then m2x=m2x-m2speed m2face=1 walk2=1 if and(joy,1024)<>0 then m2face=0 fi fi if and(joy,32)<>0 then m2x=m2x+m2speed m2face=0 walk2=1 if and(joy,1024)<>0 then m2face=1 fi fi if and(joy,16384)<>0 then if and(joy,64)<>0 then if m2g=1 then m2upf=3 m2g=0 fi fi if and(joy,64)=0 then if m2g=1 then m2upf=7 m2g=0 fi fi fi if and(joy,2048)<>0 then m2fire=1 fi if and(joy,512)<>0 then m2dr=1 fi else walk2=0 fi fi end sub rem make a function for gravity sub gravity() m1yold=m1y m2yold=m2y if m1g=0 then m1y=m1y-(gravity+m1upf) m1upf=m1upf-1 fi if m2g=0 then m2y=m2y-(gravity+m2upf) m2upf=m2upf-1 fi end sub sub collidewall() m1g=0 m2g=0 for i=1 to platno if m1y+m1height>=platy(i) then if m1yold+m1height-5<=platy(i) then if m1x>platx(i)-screenoff then if m1x=platy(i) then if m2yold+m2height-5<=platy(i) then if m2x-screenoff>platx(i)-screenoff then if m2x-screenoff499 then m1g=1 m1y=500-m1height fi if m2y+m1height>499 then m2g=1 m2y=500-m2height fi if m1x<190 then m1x=190 if screenoff>0 then screenoff=screenoff-m1speed fi fi if m1x>450 then m1x=450 if screenofflevlen+450-screenoff then m2x=levlen+450 cd=0 fi end sub sub collidebulet() if m1firedelay=m1firerate then if m2ym2x-screenoff then if m2y+m2height>m1y+16 then m2health=m2health-m1damage m2x=m2x+(m2speed*2) m1bonus=m1bonus+50 if players=1 then if m2g=1 then m2g=0 m2upf=7 fi fi fi fi fi fi if m1face=1 then if m1x>m2x-screenoff then if m2y+m2height>m1y+16 then if m1x-m1rangem1x then if m1y+m1height>m2y+16 then m1health=m1health-m2damage m1x=m1x+(m1speed*2) m2bonus=m2bonus+50 fi fi fi fi if m2face=1 then if m2x-screenoff>m1x then if m1y+m1height>m2y+16 then if m2x-m2range-screenoff1 then draw=0 fi end sub sub begin() setrgb 1,0,0,0 players=0 txtx=200 txty=350 tym=3 txm=3 while (players=0) if difficulty>7 then difficulty=0 fi if difficulty<0 then difficulty=7 fi dif$=str$(difficulty) setbuf() clear window setrgb 1,0,0,0 text 170,100, " Controlls..." text 170,140, " left......move left" text 170,160, " right.....move right" text 170,180, " down......dampen jump" text 170,200, " x.........jump" text 170,220, " r1........shoot" text 170,240, " r2........show weapon range" text 170,260, " l1........face backwards" text 170,320, " Enemy Upgrade Speed "+dif$ text 90,440, " Press start on controller 1 for 1 player" text 90,460, " Start on controller 2 for 2 player" text 90,480, " Select to go shopping" text txtx,txty,"LEONARD" if txtx>550 then txm=-3 fi if txtx<15 then txm=3 fi if txty>500 then tym=-3 fi if txty<15 then tym=3 fi txtx=txtx+txm txty=txty+tym joy=peek("port1") if and(joy,8)<>0 then players=1 fi if and(joy,1)<>0 then buy() fi if and(joy,128)<>0 then difficulty=difficulty-1 wait 0.1 fi if and(joy,32)<>0 then difficulty=difficulty+1 wait 0.1 fi joy=peek("port2") if and(joy,8)<>0 then players=2 fi if and(joy,1)<>0 then buy() fi wend looper=0 if players=1 then while (looper3 then if m2cash>200 then m2firerate=m2firerate-1 m2cash=m2cash-200 fi fi if m2health<260 then if m2cash>50 then m2health=m2health+10 m2cash=m2cash-50 fi fi if m2speed<12 then if m2cash> 100 then m2speed=m2speed+1 m2cash=m2cash-100 fi fi if m2range<440 then if m2cash>70 then m2range=m2range+10 m2cash=m2cash-70 fi fi if m2damage<65 then if m2cash>320 then m2damage=m2damage+2 m2cash=m2cash-320 fi fi wend fi end sub sub buy() setdispbuf 0 setdrawbuf 0 clear window setrgb 1,0,0,0 text 280,50,"The Shop" text 80,130,"Leonard" text 510,130,"Frank" m1cash$=str$(m1cash) m2cash$=str$(m2cash) text 90,160,"$"+m1cash$ text 510,160,"$"+m2cash$ text 70,220,"Fire Rate $200" text 70,250,"Health $50" text 70,280,"Speed $100" text 70,310,"Range $70" text 70,340,"Fire Power $320" text 470,220,"Fire Rate $200" text 470,250,"Health $50" text 470,280,"Speed $100" text 470,310,"Range $70" text 470,340,"Fire Power $320" text 170,480, " Press Triangle to go back" popi=0 while (popi=0) joy=peek("port1") if and(joy,4096)<>0 then popi=1 fi if and(joy,16)<>0 then buychose=buychose-1 fi if and(joy,64)<>0 then buychose=buychose+1 fi if buychose>4 then buychose=0 fi if buychose<0 then buychose=4 fi if buychose=0 then setrgb 1,255,255,255 fill rectangle 0,200,69,380 setrgb 1,14,166,78 fill triangle 20,205 to 20,225 to 60,215 if and(joy,16384)<>0 then if m1cash>199 then if m1firerate>3 then m1cash=m1cash-200 setrgb 1,255,255,255 fill rectangle 80,140,150,170 m1cash$=str$(m1cash) setrgb 1,0,0,0 text 90,160,"$"+m1cash$ m1firerate=m1firerate-1 else beep fi else beep fi fi fi if buychose=1 then setrgb 1,255,255,255 fill rectangle 0,200,69,380 setrgb 1,14,166,78 fill triangle 20,235 to 20,255 to 60,245 if and(joy,16384)<>0 then if m1cash>49 then if m1health<260 then m1cash=m1cash-50 setrgb 1,255,255,255 fill rectangle 80,140,150,170 m1cash$=str$(m1cash) setrgb 1,0,0,0 text 90,160,"$"+m1cash$ m1health=m1health+10 else beep fi else beep fi fi fi if buychose=2 then setrgb 1,255,255,255 fill rectangle 0,200,69,380 setrgb 1,14,166,78 fill triangle 20,265 to 20,285 to 60,275 if and(joy,16384)<>0 then if m1cash>99 then if m1speed<12 then m1cash=m1cash-100 setrgb 1,255,255,255 fill rectangle 80,140,150,170 m1cash$=str$(m1cash) setrgb 1,0,0,0 text 90,160,"$"+m1cash$ m1speed=m1speed+1 else beep fi else beep fi fi fi if buychose=3 then setrgb 1,255,255,255 fill rectangle 0,200,69,380 setrgb 1,14,166,78 fill triangle 20,295 to 20,315 to 60,305 if and(joy,16384)<>0 then if m1cash>69 then if m1range<440 then m1cash=m1cash-70 setrgb 1,255,255,255 fill rectangle 80,140,150,170 m1cash$=str$(m1cash) setrgb 1,0,0,0 text 90,160,"$"+m1cash$ m1range=m1range+10 else beep fi else beep fi fi fi if buychose=4 then setrgb 1,255,255,255 fill rectangle 0,200,69,380 setrgb 1,14,166,78 fill triangle 20,325 to 20,345 to 60,335 if and(joy,16384)<>0 then if m1cash>319 then if m1damage<65 then m1cash=m1cash-320 setrgb 1,255,255,255 fill rectangle 80,140,150,170 m1cash$=str$(m1cash) setrgb 1,0,0,0 text 90,160,"$"+m1cash$ m1damage=m1damage+2 else beep fi else beep fi fi fi wait 0.1 joy2=peek("port2") if and(joy2,4096)<>0 then popi=1 fi if and(joy2,16)<>0 then buychose2=buychose2-1 fi if and(joy2,64)<>0 then buychose2=buychose2+1 fi if buychose2>4 then buychose2=0 fi if buychose2<0 then buychose2=4 fi if buychose2=0 then setrgb 1,255,255,255 fill rectangle 400,200,469,380 setrgb 1,14,166,78 fill triangle 420,205 to 420,225 to 460,215 if and(joy2,16384)<>0 then if m2cash>199 then if m2firerate>3 then m2cash=m2cash-200 setrgb 1,255,255,255 fill rectangle 500,140,580,170 m2cash$=str$(m2cash) setrgb 1,0,0,0 text 510,160,"$"+m2cash$ m2firerate=m2firerate-1 else beep fi else beep fi fi fi if buychose2=1 then setrgb 1,255,255,255 fill rectangle 400,200,469,380 setrgb 1,14,166,78 fill triangle 420,235 to 420,255 to 460,245 if and(joy2,16384)<>0 then if m2cash>49 then if m2health<260 then m2cash=m2cash-50 setrgb 1,255,255,255 fill rectangle 500,140,580,170 m2cash$=str$(m2cash) setrgb 1,0,0,0 text 510,160,"$"+m2cash$ m2health=m2health+10 else beep fi else beep fi fi fi if buychose2=2 then setrgb 1,255,255,255 fill rectangle 400,200,469,380 setrgb 1,14,166,78 fill triangle 420,265 to 420,285 to 460,275 if and(joy2,16384)<>0 then if m2cash>99 then if m2speed<12 then m2cash=m2cash-100 setrgb 1,255,255,255 fill rectangle 500,140,580,170 m2cash$=str$(m2cash) setrgb 1,0,0,0 text 510,160,"$"+m2cash$ m2speed=m2speed+1 else beep fi else beep fi fi fi if buychose2=3 then setrgb 1,255,255,255 fill rectangle 400,200,469,380 setrgb 1,14,166,78 fill triangle 420,295 to 420,315 to 460,305 if and(joy2,16384)<>0 then if m2cash>69 then if m2range<440 then m2cash=m2cash-70 setrgb 1,255,255,255 fill rectangle 500,140,580,170 m2cash$=str$(m2cash) setrgb 1,0,0,0 text 510,160,"$"+m2cash$ m2range=m2range+10 else beep fi else beep fi fi fi if buychose2=4 then setrgb 1,255,255,255 fill rectangle 400,200,469,380 setrgb 1,14,166,78 fill triangle 420,325 to 420,345 to 460,335 if and(joy2,16384)<>0 then if m2cash>319 then if m2damage<65 then m2cash=m2cash-320 setrgb 1,255,255,255 fill rectangle 500,140,580,170 m2cash$=str$(m2cash) setrgb 1,0,0,0 text 510,160,"$"+m2cash$ m2damage=m2damage+2 else beep fi else beep fi fi fi wait 0.1 wend end sub sub checkhealth() m1dead=0 m2dead=0 if m1health<1 then fini=1 m2kill=500 m2loser=0 m1dead=1 m1firerate=msfirerate : m1health=mshealth m1speed=msspeed : m1range=msrange m1damage=msdamage else m2kill=0 m2loser=100 fi if m2health<1 then fini=1 m1kill=500 m1loser=0 m2dead=1 m2firerate=msfirerate : m2health=mshealth m2speed=msspeed : m2range=msrange m2damage=msdamage else m1kill=0 m1loser=100 fi end sub sub m2ai() m2fire=0 m2close=0 walk2=0 if m1x>m2x-screenoff-m2range then if m1xm2y then if m1y-100m2x-screenoff then if m2face=0 then m2fire=1 fi fi fi if m1x>m2x-screenoff-m2range then if m1xm1x-m1range then if m2x-screenoffm1x then m2x=m2x+m2speed m2face=0 walk2=1 fi fi elseif m1x-m2range>m2x-screenoff then m2x=m2x+m2speed m2face=0 walk2=1 fi if m2x-screenoffm1x then m2face=1 fi fi fi fi fi dirskip=dirskip+1 if dirskip>35 then dirskip=0 fi if m2close=0 then cdold=cd if dirskip=10 then cd=int(ran(4)) fi if cd=1 then m2x=m2x+m2speed m2face=0 walk2=1 fi if cd=0 then m2x=m2x-m2speed walk2=1 m2face=1 fi if cd>1 then cd=cdold fi fi jumpskip=jumpskip+1 if jumpskip>70 then jumpskip=0 fi if m1y1 then text 250,100,"Leonard Wins" fi fi if m1dead=1 then if m2dead<>1 then text 250,100,"Frank Wins" fi fi if m1dead=1 then if m2dead=1 then text 250,100," DRAW" fi fi m1cash=m1cash+m1bonus+m1kill+m1loser m2cash=m2cash+m2bonus+m2kill+m2loser m1cash$=str$(m1cash) m2cash$=str$(m2cash) m1bonus$=str$(m1bonus) m2bonus$=str$(m2bonus) m1loser$=str$(m1loser) m2loser$=str$(m2loser) m1kill$=str$(m1kill) m2kill$=str$(m2kill) wait 2 text 60,180,"Shot bonus for Leonard" text 60,230,"Kill bonus" text 60,320,"Total cash" text 60,280,"Loser Bonus" text 400,180,"Shot bonus for Frank" text 400,230,"Kill bonus" text 400,320,"Total cash" text 400,280,"Loser Bonus" wait 1 text 60,200,"$"+m1bonus$ text 400,200,"$"+m2bonus$ wait 1 text 60,250,"$"+m1kill$ text 400,250,"$"+m2kill$ wait 1 text 60,300,"$"+m1loser$ text 400,300,"$"+m2loser$ wait 1 text 60,350,"$"+m1cash$ text 400,350,"$"+m2cash$ wait 1 text 170,440," Press Start to Continue" m1bonus=0 m2bonus=0 screenoff=0 m1x=200 m2x=600 m1y=80 m2y=80 dog=0 while (dog=0) joy=peek("port1") if and(joy,8)<>0 then dog=1 fi joy=peek("port2") if and(joy,8)<>0 then dog=2 fi wend wait 0.5 end sub setrgb 0,255,255,255 open window 640,512 setrgb 1,0,0,0 beep wait 0.1 beep wait 0.1 text 170,480,"www.rbm.com.au/staticgerbil" text 250,200,"Static" wait 1 text 310,200,"Gerbil" wait 1 text 260,250,"Presents..." wait 1 text 270,300,"LEONARD" wait 2 while (play=0) begin() game() win() wend