'===========================================================================
' Subject: AVOID THE MINES                    Date: 06-28-97 (22:12)       
'  Author: Aleksander Vojta                   Code: PB, QB, QBasic, PDS    
'  Origin: aleksander.vojta@jagor.srce.hr   Packet: GAMES.ABC
'===========================================================================
'compiler: PowerBASIC 3.00
'coded by MaD MaNIaC
'
'This is a clone of an old Atari ST game.
'Move the tank in the mine field. A beep
'will indicate that there is a landmine
'in front of you or on either side. Avoid
'mines, collect bonus and try to find a
'hidden "extra life".
'Exit a level by hitting the red line
'on top of the minefield. Then you start
'over, with more mines.
'
'

option base 0
dim mf(58,41)

dim plf(88)
dim plb(88)
dim pll(88)
dim plr(88)
dim icon1(88)
dim icon2(88)
dim icon3(88)

dim mes(580)

SCREEN 12
gosub initsprites

ss = 1
if command$ = "nosound" then ss = 0

start:
level = 1
lives = 3
dead = 0
ngame = 0
restart:
completed = 0
found = 0
gosub cleanup
cls
COLOR 6,0
LINE (30,50)-(600-1,450-1),,BF
COLOR 11,0
LINE (28,48)-(602-1,452-1),,B
LINE (28,11)-(602-1,35-1),,B
color 12
line (30+27*10-1,48)-(30+29*10,48)
COLOR 14
LOCATE 2,6:PRINT "Mines:                  ";
?"Score:                             Lives:";
gosub setmines
'gosub blowup

game:
x=28
y=39
gosub howmany
put (30+x*10,50+y*10),plf,pset
color 7 : line (30+(x-1)*10,50+y*10)-(30+(x+1-1)*10-1,50+(y+1)*10-1),,bf
sleep
a$=inkey$
a$=""
while dead = 0 and completed = 0
gosub keyloop
if asc(Mid$(a$,2)) = 72 then gosub up
if asc(Mid$(a$,2)) = 80 then gosub down
if asc(Mid$(a$,2)) = 75 then gosub l
if asc(Mid$(a$,2)) = 77 then gosub r
if asc(Mid$(a$,2)) = 59 then gosub squeek
gosub howmany
wend
gosub blowup
if completed = 1 then
 score = score + level * 100
 gosub howmany
 gosub blowup
 level = level + 1
 sleep
 goto restart
end if
COLOR 0,0
LINE (150,150)-(455,290),,BF
COLOR 1,0
LINE (150,150)-(455,290),,B
LINE (150+1,150+1)-(455-1,290-1),,B
color 11,0
LINE (150+2,150+2)-(455-2,290-2),,B
COLOR 1,0
LINE (150+3,150+3)-(455-3,290-3),,B
LINE (150+4,150+4)-(455-4,290-4),,B
locate 12,30
color 12
? "*** GAME OVER ***"
color 14
locate 14,30
? "Your score: ";score
color 11
locate 16,30
? "Play again? (Y/N)"
key1:
c$=inkey$
if c$="" then goto key1
if c$="N" or c$="n" or c$=chr$(27) then goto getout
if c$="Y" or c$="y" then goto start
goto key1
getout:
screen 0
cls
end

setmines:
rem mines
randomize timer
set = level * 15 + 50
for i=0 to set
again:
 a=int(rnd(2)*57)
 b=int(rnd(2)*40)
 if a=28 and b=39 then goto again
 if a=27 and b=39 then goto again
 if a=28 and b=0 then goto again
 if a=27 and b=0 then goto again
 if mf(a,b) = 0 then mf(a,b) = 1 else goto again
next i
rem goodies
randomize timer
set = level
for i=1 to set
again2:
 a=int(rnd(2)*57)
 b=int(rnd(2)*40)
 if a=28 and b=39 then goto again
 if a=27 and b=39 then goto again
 if a=28 and b=0 then goto again
 if a=27 and b=0 then goto again
 if mf(a,b) = 0 then
 mf(a,b) = 3
 put (30+a*10,50+b*10),icon3,pset
 else
 goto again2
 end if
next i
rem extra life
randomize timer
again3:
a=int(rnd(2)*57)
b=int(rnd(2)*40)
if a=28 and b=39 then goto again
if a=27 and b=39 then goto again
if a=28 and b=0 then goto again
if a=27 and b=0 then goto again
if mf(a,b) = 0 then mf(a,b) = 4 else goto again3
return

blowup:
color 14
for i=0 to 39
 for j=0 to 56
  if mf(j,i) = 1 then put (30+j*10,50+i*10),icon1,pset
  if mf(j,i) = 4 then
  x1=j
  y1=i
 end if
 next j
next i
if found = 0 then put (30+x1*10,50+y1*10),plf,pset
return

landmine:
lives = lives - 1
if lives <= 0 then
dead = 1
end if
mf(x,y) = 2
put (30+x*10,50+y*10),icon2,pset
x=28
y=39
put (30+x*10,50+y*10),plf,pset
return

squeek:
if ss=0 then ss=1 else ss=0
return

down:
if y+1 <= 39 then
color 7 : line (30+x*10,50+y*10)-(30+(x+1)*10-1,50+(y+1)*10-1),,bf
y = y+1
if mf(x,y) = 1 then
gosub landmine
elseif mf(x,y) = 2 then
put (30+x*10,50+y*10),plb,pset
gosub snatcher
elseif mf(x,y) = 3 then
put (30+x*10,50+y*10),plb,pset
gosub goodie
elseif mf(x,y) = 4 then
put (30+x*10,50+y*10),plb,pset
gosub oneup
else
put (30+x*10,50+y*10),plb,pset
end if
end if
return

up:
if y=0 and (x=27 or x=28) then
completed = 1
put (30+x*10,50+y*10),plf,pset
end if
if y-1 >= 0 then
color 7 : line (30+x*10,50+y*10)-(30+(x+1)*10-1,50+(y+1)*10-1),,bf
y = y-1
if mf(x,y) = 1 then
gosub landmine
elseif mf(x,y) = 2 then
put (30+x*10,50+y*10),plf,pset
gosub snatcher
elseif mf(x,y) = 3 then
put (30+x*10,50+y*10),plf,pset
gosub goodie
elseif mf(x,y) = 4 then
put (30+x*10,50+y*10),plf,pset
gosub oneup
else
put (30+x*10,50+y*10),plf,pset
end if
end if
return

r:
if x+1 <= 56 then
color 7 : line (30+x*10,50+y*10)-(30+(x+1)*10-1,50+(y+1)*10-1),,bf
x = x+1
if mf(x,y) = 1 then
gosub landmine
elseif mf(x,y) = 2 then
put (30+x*10,50+y*10),plr,pset
gosub snatcher
elseif mf(x,y) = 3 then
put (30+x*10,50+y*10),plr,pset
gosub goodie
elseif mf(x,y) = 4 then
put (30+x*10,50+y*10),plr,pset
gosub oneup
else
put (30+x*10,50+y*10),plr,pset
end if
end if
return

l:
if x-1 >= 0 then
color 7 : line (30+x*10,50+y*10)-(30+(x+1)*10-1,50+(y+1)*10-1),,bf
x = x-1
if mf(x,y) = 1 then
gosub landmine
elseif mf(x,y) = 2 then
put (30+x*10,50+y*10),pll,pset
gosub snatcher
elseif mf(x,y) = 3 then
put (30+x*10,50+y*10),pll,pset
gosub goodie
elseif mf(x,y) = 4 then
put (30+x*10,50+y*10),pll,pset
gosub oneup
else
put (30+x*10,50+y*10),pll,pset
end if
end if
return

snatcher:
score = score + -50
gosub howmany
mf(x,y)=0
return

goodie:
score = score + 100
gosub howmany
mf(x,y)=0
return

oneup:
lives = lives + 1
gosub howmany
found = 1
mf(x,y)=0
get (278,222)-(340,240),mes
color 10
LINE (278,222)-(340,240),,B
paint (280,225),0,10
color 14
locate 15,36
? "Extra"
put (326,226),plf,pset
waitkey:
b$ = inkey$
if b$="" then goto waitkey
put (278,222),mes,pset
return

keyloop:
do
a$ = inkey$
if a$=chr$(27) then
 screen 0
 cls
 end
end if
loop while len(a$) <> 2
return

howmany:
mines = 0
if x+1 <= 56 then if mf(x+1,y) = 1 then mines = mines +1   'left
if x-1 >= 0  then if mf(x-1,y) = 1 then mines = mines +1   'right
if y+1 <= 39 then if mf(x,y+1) = 1 then mines = mines +1   'up
if y-1 >= 0  then if mf(x,y-1) = 1 then mines = mines +1   'down
color 14
locate 2,12: print mines;" "
locate 2,36: print score;" "
locate 2,71: print lives;" "
if mines = 1 and ss = 1 then sound 200, 2
if mines = 2 and ss = 1 then sound 400, 2
if mines = 3 and ss = 1 then sound 600, 2
return

cleanup:
for i=0 to 57
for j=0 to 40
mf(i,j)=0
next j
next i
return

initsprites:
for i=0 to 9
 for j=0 to 9
  read c
  pset (j,i),c
 next j
next i
get(0,0)-(9,9),plf
restore

for i=0 to 9
 for j=0 to 9
  read c
  pset (j,9-i),c
 next j
next i
get(0,0)-(9,9),plb
restore

for i=0 to 9
 for j=0 to 9
  read c
  pset (i,9-j),c
 next j
next i
get(0,0)-(9,9),pll
restore

for i=0 to 9
 for j=0 to 9
  read c
  pset (9-i,j),c
 next j
next i
get(0,0)-(9,9),plr

for i=0 to 9
 for j=0 to 9
  read c
  pset (j,i),c
 next j
next i
get(0,0)-(9,9),icon1

for i=0 to 9
 for j=0 to 9
  read c
  pset (j,i),c
 next j
next i
get(0,0)-(9,9),icon2

for i=0 to 9
 for j=0 to 9
  read c
  pset (j,i),c
 next j
next i
get(0,0)-(9,9),icon3

return

rem tank
data 7,7,7,7,8,8,7,7,7,7
data 7,7,7,7,8,8,7,7,7,7
data 2,2,2,7,8,8,7,2,2,2
data 0,0,2,2,8,8,2,2,0,0
data 7,7,2,2,8,8,2,2,7,7
data 0,0,2,2,8,8,2,2,0,0
data 7,7,2,10,8,8,10,3,7,7
data 0,0,2,2,10,10,2,2,0,0
data 7,7,2,2,2,2,2,2,7,7
data 0,0,2,12,2,2,12,2,0,0

rem mine
data 6,6,6,6,6,6,6,6,6,6
data 6,6,6,6,6,6,6,6,6,6
data 6,6,6,6,6,6,6,6,6,6
data 6,6,6,6,6,6,6,6,6,6
data 6,6,6,6,6,6,6,6,6,6
data 6,6,6,6,6,6,6,6,6,6
data 6,6,6,12,12,6,6,6,6,6
data 6,2,2,2,2,2,2,2,6,6
data 6,2,2,2,2,2,2,2,2,6
data 6,2,2,2,2,2,2,2,2,6

rem grave
data 6,6,6,0,0,0,6,6,6,6
data 6,6,6,0,7,0,6,6,6,6
data 6,0,0,0,7,0,0,0,6,6
data 6,0,7,7,15,7,7,0,6,6
data 6,0,0,0,7,0,0,0,6,6
data 6,6,6,0,7,0,6,6,6,6
data 6,6,6,0,7,0,6,6,6,6
data 6,6,6,0,7,0,6,6,6,6
data 6,10,6,0,7,0,6,10,6,6
data 6,10,10,10,10,10,10,10,6,6

rem diamond
data 6,6,6,6,11,11,6,6,6,6
data 6,6,6,11,9,9,11,6,6,6
data 6,6,11,9,3,3,9,11,6,6
data 6,11,9,11,3,3,11,9,11,6
data 11,9,3,3,9,9,3,3,9,11
data 11,9,3,3,9,9,3,3,9,11
data 6,11,9,11,3,3,11,9,11,6
data 6,6,11,9,3,3,9,11,6,6
data 6,6,6,11,9,9,11,6,6,6
data 6,6,6,6,11,11,6,6,6,6
