home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows CE - The Ultimate Companion
/
ROMMAN_CE.iso
/
Files
/
Programming
/
Basice
/
Sabotage
/
SABOTAGE.BAS
next >
Wrap
BASIC Source File
|
1997-11-14
|
17KB
|
833 lines
! Sabotage!
! A BasiCE version of an AppleII clasic by
! Ricardo A. Barijan
! Version 1.1
! Last update: November 13, 1997
call clrscr ! To be ensure that the screen is blank
wait 0.2
call clrscr
wait 0.2
call clrscr
print "Q"+chr$(35); ! Set color to 3
! Variables for each man (up to 6)
dim mx%[6] ! x
dim my%[6] ! y
dim ms%[6] ! status
dim gr%[46] ! Men at ground (landed)
dim jump%[8] ! Jump tables (values of y)
call set_table
hiscore%=0
call read_hi
if hiscore%<250 then
hiscore%=250 ! Initial Hiscore
endif
!********** Possible values of ms%[n] **********!
! 0 dead (or landed)
! 1 death anim at ground
! 2 death anim at ground
! 3 faling
! 4 erasing death anim at ground
! 5 gliding
! 6 erasing death
! 7 death anim
call start ! Title screen !
call init
quit%=0
demo%=1
tx%=74
ty%=44
call draw_base
call score
call hiscore
!MAIN LOOP
loop
k$=key$
k%=asc%(k$,1)
!if(k%<>0) then ! Test !
!call curpos(15,5)
!print " ";k$;" ";k%;" ";shot%;" "
!endif
!*********
!call test1 ! Development routines
!call test2
!if((k%=32) and (cur_man%>1)) then
!ms%[cur_man%-1]=3
!endif
!*********
if(k%=8) then
if(demo%) then quit%=1 endif
call init
call clrscr
call hiscore
demo%=1
k%=0
endif
if(demo%) then
call demo
endif
if((k%<56) and (k%>48) and (shot%=0)) then
shot%=k%-48
call shot
else
if(shot%>0) then
print "Q"+chr$(32);
call shot
print "Q"+chr$(35);
shot%=0
endif
endif
if k%=112 then
loop
call curpos(34,7)
print" P A U S E ";
wait 0.1
k$=key$
while len%(k$)=0
endloop
call curpos(34,7)
print" ";
endif
call men
call move1
call draw_base
wait 0.01
while quit%=0
endloop
!END OF MAIN LOOP
call clrscr
call curpos(0,2)
print"Thanks for playing Sabotage."
print"Check for new games at:"
print"http://www.geocities.com/SiliconValley/Park/7794"
print"email: barijan@usa.net
print""
!END OF THE PROGRAM
!----- PROCEDURES -------
procedure shot
if(shot%=1) then
call line(1,148,240,148)
return
endif
if(shot%=2) then
call line(1,30,240,148)
return
endif
if(shot%=3) then
call line(130,1,240,148)
return
endif
if(shot%=4) then
call line(240,1,240,148)
return
endif
if(shot%=5) then
call line(350,1,240,148)
return
endif
if(shot%=6) then
call line(479,30,240,148)
return
endif
if(shot%=7) then
call line(479,148,240,148)
return
endif
endproc
procedure draw_base
! Draw men in the ground !
loop for i%=1 to 46
if(gr%[i%]) then
x%=i%*10-6
call fillrect(x%+5,155,x%+8,158)
call fillrect(x%+5,160,x%+8,165)
call line(x%+3,159,x%+10,159)
endif
endloop
! Draw cannon base and ground !
call line(5,165,475,165)
call fillrect(230,155,250,165)
call fillrect(235,150,245,155)
call line(239,149,241,149)
endproc
procedure move1 ! Airplane !
p1x%=p1x%-10
if(p1x%<0) then
p1x%=600
print "Q"+chr$(32);
call fillrect(0,8,23,17)
print "Q"+chr$(35);
if(explode%) then
call destruct
endproc
endif
if(drop%=0) then
c%=0
loop for i%=1 to 6
c%=c%+ms%[i%]
endloop
if c%=0 then explode%=1
endif
endif
wave%=wave%+1
if(mod%(wave%,10)=0) then level%=level%+1 endif
call score
endif
if(p1x%>455) then
call explo
wait 0.08
return
endif
call init_man
print "Q"+chr$(32);
call fillrect(p1x%+10,8,p1x%+33,17)
print "Q"+chr$(35);
call fillrect(p1x%,11,p1x%+20,14)
call line(p1x%+4,10,p1x%+20,10)
call fillrect(p1x%+21,8,p1x%+23,15)
call line(p1x%+20,9,p1x%+20,14)
call line(p1x%+10,9,p1x%+13,9)
call line(p1x%+10,14,p1x%+14,14)
call line(p1x%+11,15,p1x%+15,15)
call line(p1x%+12,16,p1x%+16,16)
if(shot%) then
if((shot%=5) and (p1x%<350) and (p1x%>310)) then
score%=score%+20
ex%=p1x%/6-2
p1x%=650
endif
if((shot%=3) and (p1x%<150) and (p1x%>110)) then
score%=score%+10
ex%=p1x%/6-2
p1x%=650
endif
if((shot%=4) and (p1x%<240) and (p1x%>210)) then
score%=score%+15
ex%=p1x%/6-2
p1x%=650
endif
!call score
endif
endproc
procedure init_man
if((ms%[cur_man%]) or ((p1x%>200) and (p1x%<260)) or (timer%>0) or (drop%=0)) then
timer%=timer%-1
return
endif
! Pseudo random timer based on game level and wave !
timer%=(22-level%)-p1x%/30+10/wave%
!call curpos(5,0)
!print timer%;
mx%[cur_man%]=p1x%+4
my%[cur_man%]=16
ms%[cur_man%]=5
cur_man%=cur_man%+1
if(cur_man%=7) then cur_man%=1 endif
endproc
procedure hit
ms%[man%]=7
print "Q"+chr$(32);
call fillrect(x%,y%,x%+13,y%+17)
print "Q"+chr$(35);
call line(x%,y%+2,x%+4,y%+6)
call line(x%+6,y%+2,x%+6,y%+6)
call line(x%+12,y%+2,x%+8,y%+6)
call line(x%,y%+8,x%+4,y%+8)
call line(x%+9,y%+8,x%+13,y%+8)
call line(x%,y%+14,x%+4,y%+10)
call line(x%+6,y%+11,x%+6,y%+15)
call line(x%+9,y%+11,x%+13,y%+15)
endproc
procedure men
loop for man%=1 to 6
if(ms%[man%]) then
x%=mx%[man%]
y%=my%[man%]
s%=ms%[man%]
print "Q"+chr$(32);
call fillrect(x%,y%,x%+13,y%+17)
print "Q"+chr$(35);
if(s%=7) then
ms%[man%]=0
score%=score%+5
call score
endif
if(s%=5) then
y%=y%+4
my%[man%]=y%
call fillrect(x%+5,y%+7,x%+8,y%+10)
call fillrect(x%+5,y%+12,x%+8,y%+17)
call line(x%+3,y%+11,x%+10,y%+11)
call line(x%+3,y%,x%+10,y%)
call line(x%,y%+3,x%+3,y%)
call line(x%+10,y%+1,x%+13,y%+4)
call line(x%+1,y%+4,x%+4,y%+7)
call line(x%+9,y%+6,x%+12,y%+3)
call line(x%+6,y%+1,x%+6,y%+6)
if(shot%) then
if((y%=136) or (y%=140)) then
if((shot%=1) and (x%<230)) then call hit
endif
if((shot%=7) and (x%>230)) then call hit
endif
endif
if(shot%=2) then
if (abs(y%-(x%/2+29))<4) then ms%[man%]=3 endif
if (abs(y%-(x%/2+21))<6) then call hit endif
endif
if(shot%=6) then
if (abs(y%+(x%/2-263))<4) then ms%[man%]=3 endif
if (abs(y%+(x%/2-255))<6) then call hit endif
endif
if(shot%=3) then
if (abs(y%-(x%*4/3-170))<12) then ms%[man%]=3 endif
if (abs(y%-(x%*4/3-176))<6) then call hit endif
endif
if(shot%=5) then
if (abs(y%+(x%*4/3-452))<12) then ms%[man%]=3 endif
if (abs(y%+(x%*4/3-446))<6) then call hit endif
endif
endif
if y%=148 then
ms%[man%]=0
print "Q"+chr$(32);
call fillrect(x%,y%,x%+13,y%+7)
print "Q"+chr$(35);
if(gr%[(x%+6)/10]=0) then
gr%[(x%+6)/10]=1
if(x%<220) then landl%=landl%+1
else landr%=landr%+1
endif
if((landr%>2) or (landl%>2)) then
drop%=0
c%=0
loop for i%=1 to 6
c%=c%+ms%[i%]
endloop
if c%=0 then explode%=1
endif
endif
endif
endif
endif
if(s%=4) then
print "Q"+chr$(32);
call fillrect(x%+1,y%+7,x%+11,y%+11)
print "Q"+chr$(35);
call plot(x%+4,y%+20)
call plot(x%+9,y%+19)
ms%[man%]=0
endif
if(s%=1) then
print "Q"+chr$(32);
call fillrect(x%+3,y%+9,x%+11,y%+16)
print "Q"+chr$(35);
call plot(x%+1,y%+9)
call plot(x%+6,y%+7)
call plot(x%+10,y%+10)
call line(x%+3,y%+19,x%+7,y%+19)
score%=score%+15
call score
ms%[man%]=4
endif
if(s%=2) then
print "Q"+chr$(32);
call fillrect(x%+3,y%+7,x%+10,y%+17)
print "Q"+chr$(35);
call line(x%+3,y%+12,x%+6,y%+15)
call line(x%+6,y%+10,x%+6,y%+13)
call line(x%+8,y%+14,x%+10,y%+11)
call line(x%+1,y%+18,x%+11,y%+18)
if(gr%[(x%+6)/10]) then
gr%[(x%+6)/10]=0
score%=score%+20
if(x%<220) then landl%=landl%-1
else landr%=landr%-1
endif
if((landr%<3) and (landl%<3)) then
drop%=1
endif
endif
ms%[man%]=1
endif
if(s%=3) then
y%=y%+8
my%[man%]=y%
call fillrect(x%+5,y%+7,x%+8,y%+10)
call fillrect(x%+5,y%+12,x%+8,y%+17)
call line(x%+3,y%+11,x%+10,y%+11)
if ((y%=144) or (y%=148)) then
call line(x%+3,157,x%+6,160)
call line(x%+6,160,x%+10,156)
ms%[man%]=2
my%[man%]=148
endif
endif
else
print""; ! Delay lines !
print"";
print"";
endif
endloop
endproc
procedure score
call curpos(2,17)
print"SCORE:"score%;
call curpos (36,17)
print"LEVEL:"1+level%;
call curpos(69,17)
print"WAVE:"wave%;
endproc
procedure hiscore
call curpos(30,0)
print"HI-SCORE: "hiscore%;
endproc
procedure explo
if (p1x%<610) then return endif
call curpos(ex%,1)
if (p1x%=640) then
print "Q"+chr$(32);
call fillrect(120,8,370,10)
print "Q"+chr$(35);
print" *****";
return
endif
if (p1x%=630) then print" ' ,' ,'";
return
endif
if (p1x%=620) then print". ' . '";
return
endif
if (p1x%=610) then print" ";
wave%=wave%+1
if(mod%(wave%,10)=0) then level%=level%+1 endif
call score
if(explode%) then
call destruct
endproc
endif
if(drop%=0) then
c%=0
loop for i%=1 to 6
c%=c%+ms%[i%]
endloop
if c%=0 then explode%=1
endif
endif
endif
endproc
procedure demo
if (k%<>0) then
demo%=0
call init
call clrscr
call draw_base
call score
call curpos(34,7)
print"GET READY !";
wait 2
call curpos(34,7)
print" ";
return
endif
!GAME OVER MOVEMENT (DEMO)
call curpos(gnx%,gny%)
print"GAME OVER";
call curpos(gox%,goy%)
print" ";
gox%=gnx%
goy%=gny%
gnx%=gnx%+gdx%
if(gnx%>68) then
gdx%=-1
call hiscore
endif
if(gnx%<2) then
gdx%=1
call hiscore
endif
gny%=gny%+gdy%
if(gny%>12) then
gdy%=-1
call hiscore
endif
if(gny%<2) then
gdy%=1
call hiscore
endif
!SHOT MOVEMENT (DEMO)
if(shot%=0) then
k%=step%+48
step%=step%+1
if(step%>7) then
step%=0
endif
endif
endproc
procedure init
score%=0
wave%=1
level%=0
timer%=15
shot%=0
step%=0
gox%=30
goy%=4
gnx%=gox%
gny%=goy%
gdx%=1
gdy%=1
p1x%=500
p1y%=8
man%=1
loop for i%=1 to 6
ms%[i%]=0
endloop
loop for i%=1 to 46
gr%[i%]=0
endloop
cur_man%=1
landr%=0
landl%=0
drop%=1
explode%=0
endproc
procedure plot(px%,py%) ! Clone of POINT !
print "P"+chr$(shift%(px%,-6)+1)+chr$((px% and 63)+1)+\
chr$(shift%(py%,-6)+1)+chr$((py% and 63)+1);
endproc
procedure halt ! It's better than PAUSE cause doesn't slow down.
loop
wait 0.1
k$=key$
while len%(k$)=0
endloop
endproc
procedure start
call title
print""
print" An Apple][ classic for BasiCE by Ricardo Barijan"
print""
print" Press any key to start a new game"
print" Use keys 1 2 3 4 5 6 and 7 to fire and P to pause"
print" Press BackSpace to end game and return to demo mode"
print" During demo press BackSpace to quit"
print" Check for new games at http://www.geocities.com/SiliconValley/Park/7794"
print""
print" PRESS ANY KEY TO CONTINUE";
call halt
call clrscr
endproc
procedure title
print" **** **** ***** **** ****** **** **** ******"
print" ** ** ** ** ** ** ** ** ** ** ** ** ** **"
print" ** ** ** ** ** ** ** ** ** ** ** **"
print" ***** ****** ***** ** ** ** ****** ** *** *****"
print" ***** ****** ***** ** ** ** ****** ** *** *****"
print" ** ** ** ** ** ** ** ** ** ** ** ** **"
print" ** ** ** ** ** ** ** ** ** ** ** ** ** **"
print" **** ** ** ***** **** ** ** ** **** ****** V:1.1"
endproc
procedure test1 ! Not used in normal game !
print "Q"+chr$(32);
call fillrect(tx%,ty%,tx%+13,ty%+17)
print "Q"+chr$(35);
if k$="h" then tx%=tx%-10 endif
if k$="j" then tx%=tx%+10 endif
if k$="u" then ty%=ty%-4 endif
if k$="n" then ty%=ty%+4 endif
x%=tx%
y%=ty%
call curpos(15,0)
print "x:"x%" y:"y%" ";
call fillrect(x%+5,y%+7,x%+8,y%+10)
call fillrect(x%+5,y%+12,x%+8,y%+17)
call line(x%+3,y%+11,x%+10,y%+11)
call line(x%+3,y%,x%+10,y%)
call line(x%,y%+3,x%+3,y%)
call line(x%+10,y%+1,x%+13,y%+4)
call line(x%+1,y%+4,x%+4,y%+7)
call line(x%+9,y%+6,x%+12,y%+3)
call line(x%+6,y%+1,x%+6,y%+6)
!*********
endproc
procedure test2 ! Not used in normal game !
loop for i%=1 to 46
if(gr%[i%]) then
call fillrect(i%*10-4,130,i%*10,134)
endif
endloop
call curpos(40,0)
print"L:"landl%" R:"landr%" ";
endproc
procedure destruct
call score
if(shot%>0) then
print "Q"+chr$(32);
call shot
print "Q"+chr$(35);
shot%=0
endif
if(landl%>2) then
seek%=-1
come%=1
meet%=22
else
seek%=1
come%=-1
meet%=26
endif
man%=meet%
n%=3
loop
loop
man%=man%+seek%
while gr%[man%]=0
endloop
loop
x%=man%*10-6
print "Q"+chr$(32);
call fillrect(x%+3,155,x%+10,165)
print "Q"+chr$(35);
gr%[man%]=0
man%=man%+come%
gr%[man%]=1
call draw_base
wait 0.25
while man%<>meet%
endloop
meet%=meet%+seek%
n%=n%-1
while n%<>0
endloop
x%=(meet%+come%)*10-6
wait 0.05
call line(x%+5+20*come%,159,x%+5+20*come%+10*seek%,159)
wait 0.05
gr%[man%]=0
h%=0
print "Q"+chr$(32);
x%=man%*10-6
call fillrect(x%+5,155,x%+8,158)
call fillrect(x%+5,160,x%+8,165)
call line(x%+3,159,x%+10,159)
print "Q"+chr$(35);
x%=x%+5*seek%
loop
print "Q"+chr$(32);
call fillrect(x%+3,155-h%,x%+10,165-h%)
print "Q"+chr$(35);
x%=x%+come%*5
y%=jump%[1+n%]
h%=148-y%
call fillrect(x%+5,155-h%,x%+8,158-h%)
call fillrect(x%+5,160-h%,x%+8,165-h%)
call line(x%+3,159-h%,x%+10,159-h%)
wait 0.1
n%=n%+1
while n%<>7
endloop
call score
call draw_base
wait 0.1
x%=234
y%=145
call line(x%,y%,x%-5,y%-3)
call line(x%-5,y%-3,x%+4,y%-2)
call line(x%+4,y%-2,x%+1,y%-8)
call line(x%+1,y%-8,x%+7,y%-4)
call line(x%+7,y%-4,x%+10,y%-10)
call line(x%+10,y%-10,x%+10,y%-2)
call line(x%+10,y%-2,x%+16,y%-5)
call line(x%+16,y%-5,x%+12,y%+1)
wait 0.04
print "Q"+chr$(32);
call fillrect(237,149,243,152)
call line(x%,y%,x%-5,y%-3)
call line(x%-5,y%-3,x%+4,y%-2)
call line(x%+4,y%-2,x%+1,y%-8)
call line(x%+1,y%-8,x%+7,y%-4)
call line(x%+7,y%-4,x%+10,y%-10)
call line(x%+10,y%-10,x%+10,y%-2)
call line(x%+10,y%-2,x%+16,y%-5)
call line(x%+16,y%-5,x%+12,y%+1)
print "Q"+chr$(35);
x%=228
y%=144
call line(x%,y%,x%-11,y%-6)
call line(x%-11,y%-6,x%+6,y%-4)
call line(x%+6,y%-4,x%,y%-14)
call line(x%,y%-14,x%+11,y%-9)
call line(x%+11,y%-9,x%+14,y%-20)
call line(x%+14,y%-20,x%+17,y%-9)
call line(x%+17,y%-9,x%+26,y%-13)
call line(x%+26,y%-13,x%+20,y%-5)
call line(x%+20,y%-5,x%+34,y%-6)
call line(x%+34,y%-6,x%+19,y%)
print "Q"+chr$(32);
call fillrect(238,151,242,153)
call line(238,152,242,156)
wait 0.3
call line(x%,y%,x%-11,y%-6)
call line(x%-11,y%-6,x%+6,y%-4)
call line(x%+6,y%-4,x%,y%-14)
call line(x%,y%-14,x%+11,y%-9)
call line(x%+11,y%-9,x%+14,y%-20)
call line(x%+14,y%-20,x%+17,y%-9)
call line(x%+17,y%-9,x%+26,y%-13)
call line(x%+26,y%-13,x%+20,y%-5)
call line(x%+20,y%-5,x%+34,y%-6)
call line(x%+34,y%-6,x%+19,y%)
call line(242,156,240,158)
call line(240,158,242,160)
print "Q"+chr$(35);
if(demo%) then
wait 1
else
loop for i%=1 to 16
wait 0.02
k$=key$
endloop
if (score%>hiscore%) then
hiscore%=score%
call curpos(23,5)
print" CONGRATULATIONS! NEW HI-SCORE! "
call save_hi
endif
loop
call curpos(34,7)
print" GAME OVER ";
call curpos(32,8)
print" PRESS ANY KEY "
wait 0.1
k$=key$
while len%(k$)=0
endloop
endif
call init
call clrscr
call hiscore
demo%=1
k%=0
endproc
procedure read_hi
done%=0
ON "ERROR" CALL ERR_HANDLER
OPEN "sabotage.hsc",1
if(done%) then return endif
INPUT #1,dt#
hiscore%=dt#
close 1
endproc
procedure save_hi
done%=0
ON "ERROR" CALL ERR_HANDLER
CREATE "sabotage.hsc",1
if(done%) then return endif
dt#=hiscore%
print #1,dt#
print #1,"Sabotage hi-score file"
close 1
endproc
PROCEDURE ERR_HANDLER
! Do nothing, just ignore i/o error if it happens !
done%=1
ENDPROC
procedure set_table
jump%[1]=144
jump%[2]=140
jump%[3]=136
jump%[4]=141
jump%[5]=136
jump%[6]=134
jump%[7]=138
endproc
! BasiCE library files already included here. Just in case !
procedure clrscr
print "C";
endproc
procedure line( x1%,y1%,x2%,y2%)
print "L";chr$(shift%(x1%,-6)+1);chr$((x1% and 63)+1);\
chr$(shift%(y1%,-6)+1);chr$((y1% and 63)+1);
print chr$(shift%(x2%,-6)+1);chr$((x2% and 63)+1);\
chr$(shift%(y2%,-6)+1);chr$((y2% and 63)+1);
endproc
procedure fillrect( x1%,y1%,x2%,y2%)
print "R";chr$(shift%(x1%,-6)+1);chr$((x1% and 63)+1);\
chr$(shift%(y1%,-6)+1);chr$((y1% and 63)+1);
print chr$(shift%(x2%,-6)+1);chr$((x2% and 63)+1);\
chr$(shift%(y2%,-6)+1);chr$((y2% and 63)+1);
endproc
procedure curpos(c%,r%)
print "G";chr$(c%+1);chr$(r%+1);
endproc