
-----------------------------------
ajones88
Wed Dec 16, 2009 4:35 pm

Battleship Help
-----------------------------------
What is it you are trying to achieve?
Determine a hit or a miss in battleship.

What is the problem you are having?
When trying to determine hit/miss by coordinate, problem drawign grid, if you minimize then maximize the window, grid will finish drawing, and it gets stuckk in my "guesscheck" procedure.





Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)


setscreen ("graphics: 660;660;offscreenonly;nocursor")
var shiplocx:array 1..17 of int
var shiplocy:array 1..17 of int
var gridcheckx:=335
var gridchecky:=305
var a:=0
var x := 30
var y := 570
var subx := 30
var suby := 540
var desx := 30
var desy := 540
var pboatmov, submov, desmov,batmov,acmov : array char of boolean
var map : array 1 .. 2 of int
var sbcheck := 0
var subcount, descount,batcount,account := 1
var compx, compy, compx1, compy1, compx2, compy2, compx3, compy3,compx4,compy4, dir, dir1, dir2, dir3,dir4 : int
var compcount := 0
var gridx, gridy, gridx1, gridy1 : int
var patrol, sub, des,bat,ac : int
var next := 0
var batx := 30
var acx := 30
var baty := 510
var acy := 480
var guesscheck:=0
patrol := Pic.FileNew ("pboat.gif")
sub := Pic.FileNew ("submarine.gif")
des := Pic.FileNew ("destroyer.gif")
var pboatcheck, subcheck, descheck,batcheck,accheck := 0
var subrotatecheck : int
var subrtate, pboatrotate, desrotatecheck,batrotatecheck,acrotatecheck : int
var target:int
var guessx,guessy:int
guessx:=330
guessy:=300
var guess:array char of boolean
subrtate := 0
pboatrotate := 0
subrotatecheck := 0
desrotatecheck := 0
batrotatecheck:=0
acrotatecheck:=0
var compcheck:=0
proc Guess
if guesscheck=1 then    
target := Pic.FileNew ("target.gif")
    Pic.Draw (target, guessx, guessy, picMerge)
    Pic.Free (target)
    Input.KeyDown (guess)
    if guess (KEY_UP_ARROW) and guessy30 then
        guessy -= 30
    elsif guess (KEY_LEFT_ARROW) and guessx>330 then
        guessx -= 30
    elsif guess (KEY_RIGHT_ARROW) and guessx=600 and gridchecky  90 and compx < 630 then
        drawfillbox (compx, compy, compx + 30, compy - 60, darkgrey)
        drawbox (compx, compy, compx + 30, compy - 60, black)
        compcount := 1
    elsif dir = 3 and compx > 390 and compy < 300 then
        drawfillbox (compx, compy, compx - 60, compy + 30, darkgrey)
        drawbox (compx, compy, compx - 60, compy + 30, black)
        compcount := 1
    elsif dir = 4 and compx < 600 and compy < 300 then
        drawfillbox (compx, compy, compx + 60, compy + 30, darkgrey)
        drawbox (compx, compy, compx + 60, compy + 30, black)
        compcount := 1
    else
        randint (compx, 1, 10)
        randint (compy, 1, 10)
        compx := 330 + compx * 30
        compy := compy * 30
        randint (dir, 1, 4)
    end if
    exit when compcount = 1
end loop

loop
    randint (compx1, 1, 10)
    randint (compy1, 1, 10)
    compx1 := 330 + compx1 * 30
    compy1 := compy1 * 30
    randint (dir1, 1, 4)
    if dir1 = 1 and compy1 < 240 and compx1 < 630 and whatdotcolor (compx1 + 5, compy1 + 5) not= darkgrey and whatdotcolor (compx1 + 5, compy1 + 35) not= darkgrey and whatdotcolor (compx1 + 5, compy1 + 65) not= darkgrey then %UP
        drawfillbox (compx1, compy1, compx1 + 30, compy1 + 90, darkgrey)
        drawbox (compx1, compy1, compx1 + 30, compy1 + 90, black)
        compcount := 2
    elsif dir1 = 2 and compy1 > 120 and compx1 < 630 and whatdotcolor (compx1 + 5, compy1 - 5) not= darkgrey and whatdotcolor (compx1 + 5, compy1 - 35) not= darkgrey and whatdotcolor (compx1 + 5, compy1 - 65) not= darkgrey then
        %DOWN
        drawfillbox (compx1, compy1, compx1 + 30, compy1 - 90, darkgrey)
        drawbox (compx1, compy1, compx1 + 30, compy1 - 90, 7)
        compcount := 2
    elsif dir1 = 3 and compx1 > 420 and compy1 < 300 and whatdotcolor (compx1 - 5, compy1 + 5) not= darkgrey and whatdotcolor (compx1 - 35, compy1 + 5) not= darkgrey and whatdotcolor (compx1 - 65, compy1 + 5) not= darkgrey then
        %LEFT
        drawfillbox (compx1, compy1, compx1 - 90, compy1 + 30, darkgrey)
        drawbox (compx1, compy1, compx1 - 90, compy1 + 30, 7)
        compcount := 2
    elsif dir1 = 4 and compx1 < 570 and compy1 < 300 and whatdotcolor (compx1 + 5, compy1 + 5) not= darkgrey and whatdotcolor (compx1 + 35, compy1 + 5) not= darkgrey and whatdotcolor (compx1 + 65, compy1 + 5) not= darkgrey then
        %RIGHT
        drawfillbox (compx1, compy1, compx1 + 90, compy1 + 30, darkgrey)
        drawbox (compx1, compy1, compx1 + 90, compy1 + 30, 7)
        compcount := 2
    else
        randint (compx1, 1, 10)
        randint (compy1, 1, 10)
        compx1 := 330 + compx1 * 30
        compy1 := compy1 * 30
        randint (dir1, 1, 4)
    end if
    exit when compcount = 2
end loop

loop
    randint (compx2, 1, 10)
    randint (compy2, 1, 10)
    compx2 := 330 + compx2 * 30
    compy2 := compy2 * 30
    randint (dir2, 1, 4)
    if dir2 = 1 and compy2 < 240 and compx2 < 630 and whatdotcolor (compx2 + 5, compy2 + 5) not= darkgrey and whatdotcolor (compx2 + 5, compy2 + 35) not= darkgrey and whatdotcolor (compx2 + 5, compy2 + 65) not= darkgrey then %UP
        drawfillbox (compx2, compy2, compx2 + 30, compy2 + 90, darkgrey)
        drawbox (compx2, compy2, compx2 + 30, compy2 + 90, 7)
        compcount := 3
    elsif dir2 = 2 and compy2 > 120 and compx2 < 630 and whatdotcolor (compx2 + 5, compy2 - 5) not= darkgrey and whatdotcolor (compx2 + 5, compy2 - 35) not= darkgrey and whatdotcolor (compx2 + 5, compy2 - 65) not= darkgrey then
        %DOWN
        drawfillbox (compx2, compy2, compx2 + 30, compy2 - 90, darkgrey)
        drawbox (compx2, compy2, compx2 + 30, compy2 - 90, 7)
        compcount := 3
    elsif dir2 = 3 and compx2 > 420 and compy2 < 300 and whatdotcolor (compx2 - 5, compy2 + 5) not= darkgrey and whatdotcolor (compx2 - 35, compy2 + 5) not= darkgrey and whatdotcolor (compx2 - 65, compy2 + 5) not= darkgrey then
        %LEFT
        drawfillbox (compx2, compy2, compx2 - 90, compy2 + 30, darkgrey)
        drawbox (compx2, compy2, compx2 - 90, compy2 + 30, 7)
        compcount := 3
    elsif dir2 = 4 and compx2 < 570 and compy2 < 300 and whatdotcolor (compx2 + 5, compy2 + 5) not= darkgrey and whatdotcolor (compx2 + 35, compy2 + 5) not= darkgrey and whatdotcolor (compx2 + 65, compy2 + 5) not= darkgrey then
        %RIGHT
        drawfillbox (compx2, compy2, compx2 + 90, compy2 + 30, darkgrey)
        drawbox (compx2, compy2, compx2 + 90, compy2 + 30, 7)
        compcount := 3
    else
        randint (compx2, 1, 10)
        randint (compy2, 1, 10)
        compx2 := 330 + compx2 * 30
        compy2 := compy2 * 30
        randint (dir2, 1, 4)
    end if
    exit when compcount = 3
end loop
loop
    randint (compx3, 1, 10)
    randint (compy3, 1, 10)
    compx3 := 330 + compx3 * 30
    compy3 := compy3 * 30
    randint (dir3, 1, 4)
    if dir3 = 1 and compy3 < 210 and compx3 < 630 and whatdotcolor (compx3 + 5, compy3 + 5) not= darkgrey and whatdotcolor (compx3 + 5, compy3 + 35) not= darkgrey and whatdotcolor (compx3 + 5, compy3 + 65) not= darkgrey and whatdotcolor (compx3 + 5, compy3 + 95) not= darkgrey then %UP
        drawfillbox (compx3, compy3, compx3 + 30, compy3 + 120, darkgrey)
        drawbox (compx3, compy3, compx3 + 30, compy3 + 120, 7)
        compcount := 4
    elsif dir3 = 2 and compy3 > 150 and compx3 < 630 and whatdotcolor (compx3 + 5, compy3 - 5) not= darkgrey and whatdotcolor (compx3 + 5, compy3 - 35) not= darkgrey and whatdotcolor (compx3 + 5, compy3 - 65) not= darkgrey and whatdotcolor (compx3 + 5, compy3 - 95) not= darkgrey then
        %DOWN
        drawfillbox (compx3, compy3, compx3 + 30, compy3 - 120, darkgrey)
        drawbox (compx3, compy3, compx3 + 30, compy3 - 120, 7)
        compcount := 4
    elsif dir3 = 3 and compx3 > 450 and compy3 < 300 and whatdotcolor (compx3 - 5, compy3 + 5) not= darkgrey and whatdotcolor (compx3 - 35, compy3 + 5) not= darkgrey and whatdotcolor (compx3 - 65, compy3 + 5) not= darkgrey  and whatdotcolor (compx3 -95, compy3 +5) not= darkgrey then
        %LEFT
        drawfillbox (compx3, compy3, compx3 - 120, compy3 + 30, darkgrey)
        drawbox (compx3, compy3, compx3 - 120, compy3 + 30, 7)
        compcount := 4
    elsif dir3 = 4 and compx3 < 540 and compy3 < 300 and whatdotcolor (compx3 + 5, compy3 + 5) not= darkgrey and whatdotcolor (compx3 + 35, compy3 + 5) not= darkgrey and whatdotcolor (compx3 + 65, compy3 + 5) not= darkgrey  and whatdotcolor (compx3 + 95, compy3 + 5) not= darkgrey then
        %RIGHT
        drawfillbox (compx3, compy3, compx3 + 120, compy3 + 30, darkgrey)
        drawbox (compx3, compy3, compx3 + 120, compy3 + 30, 7)
        compcount := 4
    else
        randint (compx3, 1, 10)
        randint (compy3, 1, 10)
        compx3 := 330 + compx3 * 30
        compy3 := compy3 * 30
        randint (dir3, 1, 4)
    end if
    exit when compcount = 4
end loop

loop
    randint (compx4, 1, 10)
    randint (compy4, 1, 10)
    compx4 := 330 + compx4 * 30
    compy4 := compy4 * 30
    randint (dir4, 1, 4)
    if dir4 = 1 and compy4 < 180 and compx4 < 630 and whatdotcolor (compx4 + 5, compy4 + 5) not= darkgrey and whatdotcolor (compx4 + 5, compy4 + 35) not= darkgrey and whatdotcolor (compx4 + 5, compy4 + 65) not= darkgrey and whatdotcolor (compx4 + 5, compy4 + 95) not= darkgrey and whatdotcolor (compx4 + 5, compy4 + 125) not= darkgrey then %UP
        drawfillbox (compx4, compy4, compx4 + 30, compy4 + 150, darkgrey)
        drawbox (compx4, compy4, compx4 + 30, compy4 + 150, 7)
        compcount := 5
    elsif dir4 = 2 and compy4 > 180 and compx4 < 630 and whatdotcolor (compx4 + 5, compy4 - 5) not= darkgrey and whatdotcolor (compx4 + 5, compy4 - 35) not= darkgrey and whatdotcolor (compx4 + 5, compy4 - 65) not= darkgrey and whatdotcolor (compx4 + 5, compy4 - 95) not= darkgrey and whatdotcolor (compx4 + 5, compy4 - 125) not= darkgrey then
        %DOWN
        drawfillbox (compx4, compy4, compx4 + 30, compy4 - 150, darkgrey)
        drawbox (compx4, compy4, compx4 + 30, compy4 - 150, 7)
        compcount := 5
    elsif dir4 = 3 and compx4 > 480 and compy4 < 300 and whatdotcolor (compx4 - 5, compy4 + 5) not= darkgrey and whatdotcolor (compx4 - 35, compy4 + 5) not= darkgrey and whatdotcolor (compx4 - 65, compy4 + 5) not= darkgrey  and whatdotcolor (compx4 -95, compy4 +5) not= darkgrey and whatdotcolor (compx4 -125, compy4 +5) not= darkgrey then
        %LEFT
        drawfillbox (compx4, compy4, compx4 - 150, compy4 + 30, darkgrey)
        drawbox (compx4, compy4, compx4 - 150, compy4 + 30, 7)
        compcount := 5
    elsif dir4 = 4 and compx4 < 510 and compy4 < 300 and whatdotcolor (compx4 + 5, compy4 + 5) not= darkgrey and whatdotcolor (compx4 + 35, compy4 + 5) not= darkgrey and whatdotcolor (compx4 + 65, compy4 + 5) not= darkgrey  and whatdotcolor (compx4 + 95, compy4 + 5) not= darkgrey and whatdotcolor (compx4 + 125, compy4 + 5) not= darkgrey then
        %RIGHT
        drawfillbox (compx4, compy4, compx4 + 150, compy4 + 30, darkgrey)
        drawbox (compx4, compy4, compx4 + 150, compy4 + 30, 7)
        compcount := 5
    else
        randint (compx4, 1, 10)
        randint (compy4, 1, 10)
        compx4 := 330 + compx4 * 30
        compy4 := compy4 * 30
        randint (dir4, 1, 4)
    end if
    exit when compcount =5
end loop
compcheck:=1
elsif compcheck=1 then
if dir = 1 and compy < 270 and compx < 630 then
        drawfillbox (compx, compy, compx + 30, compy + 60, darkgrey)
        drawbox (compx, compy, compx + 30, compy + 60, black)
        compcount := 1
    elsif dir = 2 and compy > 90 and compx < 630 then
        drawfillbox (compx, compy, compx + 30, compy - 60, darkgrey)
        drawbox (compx, compy, compx + 30, compy - 60, black)
        compcount := 1
    elsif dir = 3 and compx > 390 and compy < 300 then
        drawfillbox (compx, compy, compx - 60, compy + 30, darkgrey)
        drawbox (compx, compy, compx - 60, compy + 30, black)
        compcount := 1
    elsif dir = 4 and compx < 600 and compy < 300 then
        drawfillbox (compx, compy, compx + 60, compy + 30, darkgrey)
        drawbox (compx, compy, compx + 60, compy + 30, black)
        compcount := 1
end if
if dir1 = 1 and compy1 < 240 and compx1 < 630 and whatdotcolor (compx1 + 5, compy1 + 5) not= darkgrey and whatdotcolor (compx1 + 5, compy1 + 35) not= darkgrey and whatdotcolor (compx1 + 5, compy1 + 65) not= darkgrey then %UP
        drawfillbox (compx1, compy1, compx1 + 30, compy1 + 90, darkgrey)
        drawbox (compx1, compy1, compx1 + 30, compy1 + 90, black)
        compcount := 2
    elsif dir1 = 2 and compy1 > 120 and compx1 < 630 and whatdotcolor (compx1 + 5, compy1 - 5) not= darkgrey and whatdotcolor (compx1 + 5, compy1 - 35) not= darkgrey and whatdotcolor (compx1 + 5, compy1 - 65) not= darkgrey then
        %DOWN
        drawfillbox (compx1, compy1, compx1 + 30, compy1 - 90, darkgrey)
        drawbox (compx1, compy1, compx1 + 30, compy1 - 90, 7)
        compcount := 2
    elsif dir1 = 3 and compx1 > 420 and compy1 < 300 and whatdotcolor (compx1 - 5, compy1 + 5) not= darkgrey and whatdotcolor (compx1 - 35, compy1 + 5) not= darkgrey and whatdotcolor (compx1 - 65, compy1 + 5) not= darkgrey then
        %LEFT
        drawfillbox (compx1, compy1, compx1 - 90, compy1 + 30, darkgrey)
        drawbox (compx1, compy1, compx1 - 90, compy1 + 30, 7)
        compcount := 2
    elsif dir1 = 4 and compx1 < 570 and compy1 < 300 and whatdotcolor (compx1 + 5, compy1 + 5) not= darkgrey and whatdotcolor (compx1 + 35, compy1 + 5) not= darkgrey and whatdotcolor (compx1 + 65, compy1 + 5) not= darkgrey then
        %RIGHT
        drawfillbox (compx1, compy1, compx1 + 90, compy1 + 30, darkgrey)
        drawbox (compx1, compy1, compx1 + 90, compy1 + 30, 7)
        compcount := 2
end if
if dir2 = 1 and compy2 < 240 and compx2 < 630 and whatdotcolor (compx2 + 5, compy2 + 5) not= darkgrey and whatdotcolor (compx2 + 5, compy2 + 35) not= darkgrey and whatdotcolor (compx2 + 5, compy2 + 65) not= darkgrey then %UP
        drawfillbox (compx2, compy2, compx2 + 30, compy2 + 90, darkgrey)
        drawbox (compx2, compy2, compx2 + 30, compy2 + 90, 7)
        compcount := 3
    elsif dir2 = 2 and compy2 > 120 and compx2 < 630 and whatdotcolor (compx2 + 5, compy2 - 5) not= darkgrey and whatdotcolor (compx2 + 5, compy2 - 35) not= darkgrey and whatdotcolor (compx2 + 5, compy2 - 65) not= darkgrey then
        %DOWN
        drawfillbox (compx2, compy2, compx2 + 30, compy2 - 90, darkgrey)
        drawbox (compx2, compy2, compx2 + 30, compy2 - 90, 7)
        compcount := 3
    elsif dir2 = 3 and compx2 > 420 and compy2 < 300 and whatdotcolor (compx2 - 5, compy2 + 5) not= darkgrey and whatdotcolor (compx2 - 35, compy2 + 5) not= darkgrey and whatdotcolor (compx2 - 65, compy2 + 5) not= darkgrey then
        %LEFT
        drawfillbox (compx2, compy2, compx2 - 90, compy2 + 30, darkgrey)
        drawbox (compx2, compy2, compx2 - 90, compy2 + 30, 7)
        compcount := 3
    elsif dir2 = 4 and compx2 < 570 and compy2 < 300 and whatdotcolor (compx2 + 5, compy2 + 5) not= darkgrey and whatdotcolor (compx2 + 35, compy2 + 5) not= darkgrey and whatdotcolor (compx2 + 65, compy2 + 5) not= darkgrey then
        %RIGHT
        drawfillbox (compx2, compy2, compx2 + 90, compy2 + 30, darkgrey)
        drawbox (compx2, compy2, compx2 + 90, compy2 + 30, 7)
        compcount := 3
end if
if dir3 = 1 and compy3 < 210 and compx3 < 630 and whatdotcolor (compx3 + 5, compy3 + 5) not= darkgrey and whatdotcolor (compx3 + 5, compy3 + 35) not= darkgrey and whatdotcolor (compx3 + 5, compy3 + 65) not= darkgrey and whatdotcolor (compx3 + 5, compy3 + 95) not= darkgrey then %UP
        drawfillbox (compx3, compy3, compx3 + 30, compy3 + 120, darkgrey)
        drawbox (compx3, compy3, compx3 + 30, compy3 + 120, 7)
        compcount := 4
    elsif dir3 = 2 and compy3 > 150 and compx3 < 630 and whatdotcolor (compx3 + 5, compy3 - 5) not= darkgrey and whatdotcolor (compx3 + 5, compy3 - 35) not= darkgrey and whatdotcolor (compx3 + 5, compy3 - 65) not= darkgrey and whatdotcolor (compx3 + 5, compy3 - 95) not= darkgrey then
        %DOWN
        drawfillbox (compx3, compy3, compx3 + 30, compy3 - 120, darkgrey)
        drawbox (compx3, compy3, compx3 + 30, compy3 - 120, 7)
        compcount := 4
    elsif dir3 = 3 and compx3 > 450 and compy3 < 300 and whatdotcolor (compx3 - 5, compy3 + 5) not= darkgrey and whatdotcolor (compx3 - 35, compy3 + 5) not= darkgrey and whatdotcolor (compx3 - 65, compy3 + 5) not= darkgrey  and whatdotcolor (compx3 -95, compy3 +5) not= darkgrey then
        %LEFT
        drawfillbox (compx3, compy3, compx3 - 120, compy3 + 30, darkgrey)
        drawbox (compx3, compy3, compx3 - 120, compy3 + 30, 7)
        compcount := 4
    elsif dir3 = 4 and compx3 < 540 and compy3 < 300 and whatdotcolor (compx3 + 5, compy3 + 5) not= darkgrey and whatdotcolor (compx3 + 35, compy3 + 5) not= darkgrey and whatdotcolor (compx3 + 65, compy3 + 5) not= darkgrey  and whatdotcolor (compx3 + 95, compy3 + 5) not= darkgrey then
        %RIGHT
        drawfillbox (compx3, compy3, compx3 + 120, compy3 + 30, darkgrey)
        drawbox (compx3, compy3, compx3 + 120, compy3 + 30, 7)
        compcount := 4
end if
if dir4 = 1 and compy4 < 180 and compx4 < 630 and whatdotcolor (compx4 + 5, compy4 + 5) not= darkgrey and whatdotcolor (compx4 + 5, compy4 + 35) not= darkgrey and whatdotcolor (compx4 + 5, compy4 + 65) not= darkgrey and whatdotcolor (compx4 + 5, compy4 + 95) not= darkgrey and whatdotcolor (compx4 + 5, compy4 + 125) not= darkgrey then %UP
        drawfillbox (compx4, compy4, compx4 + 30, compy4 + 150, darkgrey)
        drawbox (compx4, compy4, compx4 + 30, compy4 + 150, 7)
        compcount := 5
    elsif dir4 = 2 and compy4 > 180 and compx4 < 630 and whatdotcolor (compx4 + 5, compy4 - 5) not= darkgrey and whatdotcolor (compx4 + 5, compy4 - 35) not= darkgrey and whatdotcolor (compx4 + 5, compy4 - 65) not= darkgrey and whatdotcolor (compx4 + 5, compy4 - 95) not= darkgrey and whatdotcolor (compx4 + 5, compy4 - 125) not= darkgrey then
        %DOWN
        drawfillbox (compx4, compy4, compx4 + 30, compy4 - 150, darkgrey)
        drawbox (compx4, compy4, compx4 + 30, compy4 - 150, 7)
        compcount := 5
    elsif dir4 = 3 and compx4 > 480 and compy4 < 300 and whatdotcolor (compx4 - 5, compy4 + 5) not= darkgrey and whatdotcolor (compx4 - 35, compy4 + 5) not= darkgrey and whatdotcolor (compx4 - 65, compy4 + 5) not= darkgrey  and whatdotcolor (compx4 -95, compy4 +5) not= darkgrey and whatdotcolor (compx4 -125, compy4 +5) not= darkgrey then
        %LEFT
        drawfillbox (compx4, compy4, compx4 - 150, compy4 + 30, darkgrey)
        drawbox (compx4, compy4, compx4 - 150, compy4 + 30, 7)
        compcount := 5
    elsif dir4 = 4 and compx4 < 510 and compy4 < 300 and whatdotcolor (compx4 + 5, compy4 + 5) not= darkgrey and whatdotcolor (compx4 + 35, compy4 + 5) not= darkgrey and whatdotcolor (compx4 + 65, compy4 + 5) not= darkgrey  and whatdotcolor (compx4 + 95, compy4 + 5) not= darkgrey and whatdotcolor (compx4 + 125, compy4 + 5) not= darkgrey then
        %RIGHT
        drawfillbox (compx4, compy4, compx4 + 150, compy4 + 30, darkgrey)
        drawbox (compx4, compy4, compx4 + 150, compy4 + 30, 7)
        compcount := 5
end if

end if
end comp


proc place
    Pic.Free (patrol)
    patrol := Pic.FileNew ("pboat.gif")
    if pboatrotate = 1 then
        patrol := Pic.Rotate (patrol, 90, -1, -1)
    end if
    Pic.Draw (patrol, x, y, picCopy)
    if pboatcheck = 0 then
        Input.KeyDown (pboatmov)
        if pboatmov (KEY_UP_ARROW) and y < 570 and pboatrotate = 0 then
            y += 30
        elsif pboatmov (KEY_UP_ARROW) and y < 600 and pboatrotate = 1 then
            y += 30
        end if

        if pboatmov (KEY_DOWN_ARROW) and y > 350 and pboatrotate = 0 then
            y -= 30
        elsif pboatmov (KEY_DOWN_ARROW) and y > 350 and pboatrotate = 1 then
            y -= 30
        end if

        if pboatmov (KEY_LEFT_ARROW) and x > 30 and pboatrotate = 0 then
            x -= 30
        elsif pboatmov (KEY_LEFT_ARROW) and x > 30 and pboatrotate = 1 then
            x -= 30
        end if

        if pboatmov (KEY_RIGHT_ARROW) and x < 300 and pboatrotate = 0 then
            x += 30
        elsif pboatmov (KEY_RIGHT_ARROW) and x < 270 and pboatrotate = 1 then
            x += 30
        end if

        if pboatmov (' ') then
            if pboatrotate = 0 and x + 35 < 300 then

                pboatrotate := 1
            elsif pboatrotate = 1 and y + 35 < 570 then

                pboatrotate := 0
            end if
        end if
        if pboatmov (KEY_ENTER) then
           pboatcheck := 1
           subcheck := 1
        end if


    end if

    if pboatcheck = 1 then
        
        sub := Pic.FileNew ("submarine.gif")
        if subrotatecheck = 1 then
            sub := Pic.Rotate (sub, 90, -1, -1)
        end if
        Pic.Draw (sub, subx, suby, picCopy)
        Pic.Free (sub)

    end if
    if subcheck = 1 then

        Input.KeyDown (submov)
        if submov (KEY_UP_ARROW) then
            if subrotatecheck = 0 and whatdotcolor (subx + 5, suby + 95) not= 15 and suby < 540 then
                suby += 30
            elsif subrotatecheck = 1 and whatdotcolor (subx + 5, suby + 35) not= 15 and whatdotcolor (subx + 35, suby + 35) not= 15 and whatdotcolor (subx + 65, suby + 35) not= 15 and suby < 600
                    then
                suby += 30
            end if

        elsif submov (KEY_DOWN_ARROW) and suby > 350 then
            if subrotatecheck = 0 and whatdotcolor (subx + 5, suby - 5) not= 15 then
                suby -= 30
            elsif subrotatecheck = 1 and whatdotcolor (subx + 5, suby - 5) not= 15 and whatdotcolor (subx + 35, suby - 5) not= 15 and whatdotcolor (subx + 65, suby - 5) not= 15 then
                suby -= 30
            end if


        elsif submov (KEY_LEFT_ARROW) and subx > 30 then
            if subrotatecheck = 0 and whatdotcolor (subx - 5, suby + 5) not= 15 and whatdotcolor (subx - 5, suby + 35) not= 15 and whatdotcolor (subx - 5, suby + 65) not= 15 then
                subx -= 30
            elsif subrotatecheck = 1 and whatdotcolor (subx - 5, suby + 5) not= 15 then
                subx -= 30
            end if


        elsif submov (KEY_RIGHT_ARROW) then
            if subrotatecheck = 0 and whatdotcolor (subx + 35, suby + 5) not= 15 and whatdotcolor (subx + 35, suby + 35) not= 15 and whatdotcolor (subx + 35, suby + 65) not= 15 and subx < 300 then
                subx += 30
            elsif subrotatecheck = 1 and whatdotcolor (subx + 95, suby + 5) not= 15 and subx < 240 then
                subx += 30
            end if



        elsif submov (' ') then
            if subrotatecheck = 0 and whatdotcolor (subx + 38, suby + 3) not= 15 and whatdotcolor (subx + 64, suby + 3) not= 15 and subx+89  350 then
            if desrotatecheck = 0 and whatdotcolor (desx + 5, desy - 5) not= 15 then
                desy -= 30
            elsif desrotatecheck = 1 and whatdotcolor (desx + 5, desy - 5) not= 15 and whatdotcolor (desx + 35, desy - 5) not= 15 and whatdotcolor (desx + 65, desy - 5) not= 15 then
                desy -= 30
            end if


        elsif desmov (KEY_LEFT_ARROW) and desx > 30 then
            if desrotatecheck = 0 and whatdotcolor (desx - 5, desy + 5) not= 15 and whatdotcolor (desx - 5, desy + 35) not= 15 and whatdotcolor (desx - 5, desy + 65) not= 15 then
                desx -= 30
            elsif desrotatecheck = 1 and whatdotcolor (desx - 5, desy + 5) not= 15 then
                desx -= 30
            end if


        elsif desmov (KEY_RIGHT_ARROW) then
            if desrotatecheck = 0 and whatdotcolor (desx + 35, desy + 5) not= 15 and whatdotcolor (desx + 35, desy + 35) not= 15 and whatdotcolor (desx + 35, desy + 65) not= 15 and desx < 300 then
                desx += 30
            elsif desrotatecheck = 1 and whatdotcolor (desx + 95, desy + 5) not= 15 and desx < 240 then
                desx += 30
            end if
        elsif desmov (' ') then
            if desrotatecheck = 0 and whatdotcolor (desx + 38, desy + 3) not= 15 and whatdotcolor (desx + 64, desy + 3) not= 15 and desx+89  350 then
            if batrotatecheck = 0 and whatdotcolor (batx + 5, baty - 5) not= 15 then
                baty -= 30
            elsif batrotatecheck = 1 and whatdotcolor (batx + 5, baty - 5) not= 15 and whatdotcolor (batx + 35, baty - 5) not= 15 and whatdotcolor (batx + 65, baty - 5) not= 15 then
                baty -= 30
            end if


        elsif batmov (KEY_LEFT_ARROW) and batx > 30 then
            if batrotatecheck = 0 and whatdotcolor (batx - 5, baty + 5) not= 15 and whatdotcolor (batx - 5, baty + 35) not= 15 and whatdotcolor (batx - 5, baty + 65) not= 15 and whatdotcolor (batx - 5, baty + 95) not= 15 then
                batx -= 30
            elsif batrotatecheck = 1 and whatdotcolor (batx - 5, baty + 5) not= 15 then
                batx -= 30
            end if


        elsif batmov (KEY_RIGHT_ARROW) then
            if batrotatecheck = 0 and whatdotcolor (batx + 35, baty + 5) not= 15 and whatdotcolor (batx + 35, baty +35) not= 15 and whatdotcolor (batx + 35, baty + 65) not= 15 and whatdotcolor (batx + 35, baty + 95) not= 15 and batx < 300 then
                batx += 30
            elsif batrotatecheck = 1 and whatdotcolor (batx + 125, baty + 5) not= 15 and batx < 210 then
                batx += 30
            end if



        elsif batmov (' ') then
            if batrotatecheck = 0 and whatdotcolor (batx + 38, baty + 3) not= 15 and whatdotcolor (batx + 64, baty + 3) not= 15 and batx+119  350 then
            if acrotatecheck = 0 and whatdotcolor (acx + 5, acy - 5) not= 15 then
                acy -= 30
            elsif acrotatecheck = 1 and whatdotcolor (acx + 5, acy - 5) not= 15 and whatdotcolor (acx + 35, acy - 5) not= 15 and whatdotcolor (acx + 65, acy - 5) not= 15 then
                acy -= 30
            end if


        elsif acmov (KEY_LEFT_ARROW) and acx > 30 then
            if acrotatecheck = 0 and whatdotcolor (acx - 5, acy + 5) not= 15 and whatdotcolor (acx - 5, acy + 35) not= 15 and whatdotcolor (acx - 5, acy + 65) not= 15 then
                acx -= 30
            elsif acrotatecheck = 1 and whatdotcolor (acx - 5, acy + 5) not= 15 then
                acx -= 30
            end if


        elsif acmov (KEY_RIGHT_ARROW) then
            if acrotatecheck = 0 and whatdotcolor (acx + 35, acy + 5) not= 15 and whatdotcolor (acx + 35, acy + 35) not= 15 and whatdotcolor (acx + 35, acy + 65) not= 15 and acx < 300 then
                acx += 30
            elsif acrotatecheck = 1 and whatdotcolor (acx + 95, acy + 5) not= 15 and acx < 240 then
                acx += 30
            end if



        elsif acmov (' ') then
            if acrotatecheck = 0 and whatdotcolor (acx + 38, acy + 3) not= 15 and whatdotcolor (acx + 64, acy + 3) not= 15 and acx+149 