Computer Science Canada

my attempt at shooting

Author:  goroyoshi [ Mon May 09, 2011 8:20 pm ]
Post subject:  my attempt at shooting

Here is what I have done to recreate shooting(not done this is just an image of shooting, I will make a game)

Turing:

setscreen ("offscreenonly")
var bullet : flexible array 1 .. 0 of int
var direction : string := "up"
var pastx, pasty : int
var recoil : boolean := false
var chars : array char of boolean
var x1, y1 : int := 100
process fire
    if recoil = false then
        pastx := x1
        pasty := y1
        recoil := true
        if direction = "up" then
            for i : y1 .. upper (bullet)
                drawfilloval (pastx, i, 1, 1, 2)
                delay (3)
            end for
        elsif direction = "right" then
            for i : x1 .. upper (bullet)
                drawfilloval (i, pasty, 1, 1, 2)
                delay (3)
            end for
        elsif direction = "left" then
            for decreasing i : x1 .. upper (bullet)
                drawfilloval (i, pasty, 1, 1, 2)
                delay (3)
            end for
        elsif direction = "down" then
            for decreasing i : y1 .. upper (bullet)
                drawfilloval (pastx, i, 1, 1, 2)
                delay (3)
            end for
        end if
        recoil := false
    end if
end fire
loop
    drawbox (0, 0, maxx, maxy, 1)
    Input.KeyDown (chars)
    if chars (KEY_UP_ARROW) then
        direction := "up"
        y1 += 1
    elsif chars (KEY_RIGHT_ARROW) then
        direction := "right"
        x1 += 1
    elsif chars (KEY_LEFT_ARROW) then
        direction := "left"
        x1 -= 1
    elsif chars (KEY_DOWN_ARROW) then
        direction := "down"
        y1 -= 1
    end if
    if y1 + 6 >= maxy then
        y1 -= 1
    end if
    if y1 - 6 <= 0 then
        y1 += 1
    end if
    if x1 + 6 >= maxx then
        x1 -= 1
    end if
    if x1 - 6 <= 0 then
        x1 += 1
    end if
    drawfilloval (x1, y1, 5, 5, 3)
    if chars (' ') then
        if direction = "up" then
            for i : y1 .. maxy
                if whatdotcolor (x1, i) = 1 then
                    new bullet, i
                    exit
                end if
                new bullet, 0
            end for
        elsif direction = "right" then
            for i : x1 .. maxx
                if whatdotcolor (i, y1) = 1 then
                    new bullet, i
                    exit
                end if
                new bullet, 0
            end for
        elsif direction = "left" then
            for decreasing i : x1 .. 0
                if whatdotcolor (i, y1) = 1 then
                    new bullet, i
                    exit
                end if
                new bullet, 0
            end for
        elsif direction = "down" then
            for decreasing i : y1 .. 0
                if whatdotcolor (x1, i) = 1 then
                    new bullet, i
                    exit
                end if
                new bullet, 0
            end for
        end if
        fork fire
    end if
    delay (3)
    View.Update
    cls
end loop

Author:  apython1992 [ Mon May 09, 2011 8:47 pm ]
Post subject:  RE:my attempt at shooting

Why the process and fork? It's unnecessary and hazardous. Can you think of another solution?

Author:  goroyoshi [ Mon May 09, 2011 9:21 pm ]
Post subject:  RE:my attempt at shooting

for some reason processes like me and they work in this case
except for the double delay but that makes sense when you slow down to aim

here is v2 (now a game with two people)

Turing:

setscreen ("offscreenonly,graphics:600;600,nobuttonbar")
var bullet, bullet2 : flexible array 1 .. 0 of int
var direction, direction2 : string := "up"
var pastx, pasty, pastx2, pasty2 : int
var recoil, recoil2 : boolean := false
var win : int := 0
var chars : array char of boolean
var x1, y1 : int := 100
var x2, y2 : int := 399
process recharge
    delay (600)
    recoil := false
end recharge
process recharge2
    delay (600)
    recoil2 := false
end recharge2
process fire
    if recoil = false then
        pastx := x1
        pasty := y1
        recoil := true
        fork recharge
        if direction = "up" then
            for i : y1 .. upper (bullet)
                drawfilloval (pastx, i, 1, 1, red)
                if whatdotcolour (pastx, i + 2) = 3 then
                    win := 1
                end if
                delay (1)
            end for
        elsif direction = "right" then
            for i : x1 .. upper (bullet)
                drawfilloval (i, pasty, 1, 1, red)
                if whatdotcolour (i + 2, pasty) = 3 then
                    win := 1
                end if
                delay (1)
            end for
        elsif direction = "left" then
            for decreasing i : x1 .. upper (bullet)
                drawfilloval (i - 2, pasty, 1, 1, red)
                if whatdotcolour (i, pasty) = 3 then
                    win := 1
                end if
                delay (1)
            end for
        elsif direction = "down" then
            for decreasing i : y1 .. upper (bullet)
                drawfilloval (pastx, i, 1, 1, red)
                if whatdotcolour (pastx, i - 2) = 3 then
                    win := 1
                end if
                delay (1)
            end for
        end if
    end if
end fire
process fire2
    if recoil2 = false then
        pastx2 := x2
        pasty2 := y2
        recoil2 := true
        fork recharge2
        if direction2 = "up" then
            for i : y2 .. upper (bullet2)
                drawfilloval (pastx2, i, 1, 1, red)
                if whatdotcolour (pastx2, i + 2) = 2 then
                    win := 2
                end if
                delay (1)
            end for
        elsif direction2 = "right" then
            for i : x2 .. upper (bullet2)
                drawfilloval (i, pasty2, 1, 1, red)
                if whatdotcolour (i + 2, pasty2) = 2 then
                    win := 2
                end if
                delay (1)
            end for
        elsif direction2 = "left" then
            for decreasing i : x2 .. upper (bullet2)
                drawfilloval (i, pasty2, 1, 1, red)
                if whatdotcolour (i - 2, pasty2) = 2 then
                    win := 2
                end if
                delay (1)
            end for
        elsif direction2 = "down" then
            for decreasing i : y2 .. upper (bullet2)
                drawfilloval (pastx2, i, 1, 1, red)
                if whatdotcolour (pastx2, i - 2) = 2 then
                    win := 2
                end if
                delay (1)
            end for
        end if
        recoil2 := false
    end if
end fire2
loop
    drawbox (0, 0, maxx, maxy, 1)
    Input.KeyDown (chars)
    if chars (KEY_UP_ARROW) then
        direction := "up"
        y1 += 1
    elsif chars (KEY_RIGHT_ARROW) then
        direction := "right"
        x1 += 1
    elsif chars (KEY_LEFT_ARROW) then
        direction := "left"
        x1 -= 1
    elsif chars (KEY_DOWN_ARROW) then
        direction := "down"
        y1 -= 1
    end if
    if chars ('w') then
        direction2 := "up"
        y2 += 1
    elsif chars ('d') then
        direction2 := "right"
        x2 += 1
    elsif chars ('a') then
        direction2 := "left"
        x2 -= 1
    elsif chars ('s') then
        direction2 := "down"
        y2 -= 1
    end if
    if y1 + 6 >= maxy then     %p1 boundaries
        y1 -= 1
    end if
    if y1 - 6 <= 0 then
        y1 += 1
    end if
    if x1 + 6 >= maxx then
        x1 -= 1
    end if
    if x1 - 6 <= 0 then
        x1 += 1
    end if
    if y2 + 6 >= maxy then     %p2 boundaries
        y2 -= 1
    end if
    if y2 - 6 <= 0 then
        y2 += 1
    end if
    if x2 + 6 >= maxx then
        x2 -= 1
    end if
    if x2 - 6 <= 0 then
        x2 += 1
    end if
    drawfilloval (x1, y1, 5, 5, 2)
    drawfilloval (x2, y2, 5, 5, 3)
    if chars ('/') then
        if direction = "up" then
            for i : y1 .. maxy
                if whatdotcolor (x1, i) = 1 then
                    new bullet, i
                    exit
                end if
                new bullet, 0
            end for
        elsif direction = "right" then
            for i : x1 .. maxx
                if whatdotcolor (i, y1) = 1 then
                    new bullet, i
                    exit
                end if
                new bullet, 0
            end for
        elsif direction = "left" then
            for decreasing i : x1 .. 0
                if whatdotcolor (i, y1) = 1 then
                    new bullet, i
                    exit
                end if
                new bullet, 0
            end for
        elsif direction = "down" then
            for decreasing i : y1 .. 0
                if whatdotcolor (x1, i) = 1 then
                    new bullet, i
                    exit
                end if
                new bullet, 0
            end for
        end if
        fork fire
    end if
    if chars (' ') then
        if direction2 = "up" then
            for i : y2 .. maxy
                if whatdotcolor (x2, i) = 1 then
                    new bullet2, i
                    exit
                end if
                new bullet2, 0
            end for
        elsif direction2 = "right" then
            for i : x2 .. maxx
                if whatdotcolor (i, y2) = 1 then
                    new bullet2, i
                    exit
                end if
                new bullet2, 0
            end for
        elsif direction2 = "left" then
            for decreasing i : x2 .. 0
                if whatdotcolor (i, y2) = 1 then
                    new bullet2, i
                    exit
                end if
                new bullet2, 0
            end for
        elsif direction2 = "down" then
            for decreasing i : y2 .. 0
                if whatdotcolor (x2, i) = 1 then
                    new bullet2, i
                    exit
                end if
                new bullet2, 0
            end for
        end if
        fork fire2
    end if
    delay (3)
    View.Update
    cls
    exit when win > 0
end loop
if win = 1 then
    put "Player one has won."
else
    put "Player two has won."
end if

Author:  goroyoshi [ Mon May 09, 2011 10:08 pm ]
Post subject:  Re: my attempt at shooting

v3 with no glitches and bullets are fired at same rate every time
Turing:

setscreen ("offscreenonly,graphics:600;600,nobuttonbar")
var bullet, bullet2 : flexible array 1 .. 0 of int
var direction, direction2 : string := "up"
var pastx, pasty, pastx2, pasty2 : int
var recoil, recoil2 : boolean := false
var win : int := 0
var chars : array char of boolean
var x1, y1 : int := 100
var x2, y2 : int := 399
process recharge
    delay (600)
    recoil := false
end recharge
process recharge2
    delay (600)
    recoil2 := false
end recharge2
process fire
    if recoil = false then
        pastx := x1
        pasty := y1
        recoil := true
        fork recharge
        if direction = "up" then
            for i : y1 .. upper (bullet)
                drawfilloval (pastx, i, 1, 1, red)
                if whatdotcolour (pastx, i + 2) = 3 then
                    win := 1
                end if
                delay (1)
            end for
        elsif direction = "right" then
            for i : x1 .. upper (bullet)
                drawfilloval (i, pasty, 1, 1, red)
                if whatdotcolour (i + 2, pasty) = 3 then
                    win := 1
                end if
                delay (1)
            end for
        elsif direction = "left" then
            for decreasing i : x1 .. upper (bullet)
                drawfilloval (i - 2, pasty, 1, 1, red)
                if whatdotcolour (i, pasty) = 3 then
                    win := 1
                end if
                delay (1)
            end for
        elsif direction = "down" then
            for decreasing i : y1 .. upper (bullet)
                drawfilloval (pastx, i, 1, 1, red)
                if whatdotcolour (pastx, i - 2) = 3 then
                    win := 1
                end if
                delay (1)
            end for
        end if
    end if
end fire
process fire2
    if recoil2 = false then
        pastx2 := x2
        pasty2 := y2
        recoil2 := true
        fork recharge2
        if direction2 = "up" then
            for i : y2 .. upper (bullet2)
                drawfilloval (pastx2, i, 1, 1, red)
                if whatdotcolour (pastx2, i + 2) = 2 then
                    win := 2
                end if
                delay (1)
            end for
        elsif direction2 = "right" then
            for i : x2 .. upper (bullet2)
                drawfilloval (i, pasty2, 1, 1, red)
                if whatdotcolour (i + 2, pasty2) = 2 then
                    win := 2
                end if
                delay (1)
            end for
        elsif direction2 = "left" then
            for decreasing i : x2 .. upper (bullet2)
                drawfilloval (i, pasty2, 1, 1, red)
                if whatdotcolour (i - 2, pasty2) = 2 then
                    win := 2
                end if
                delay (1)
            end for
        elsif direction2 = "down" then
            for decreasing i : y2 .. upper (bullet2)
                drawfilloval (pastx2, i, 1, 1, red)
                if whatdotcolour (pastx2, i - 2) = 2 then
                    win := 2
                end if
                delay (1)
            end for
        end if
    end if
end fire2
loop
    drawbox (0, 0, maxx, maxy, 1)
    Input.KeyDown (chars)
    if chars (KEY_UP_ARROW) then
        direction := "up"
        y1 += 1
    elsif chars (KEY_RIGHT_ARROW) then
        direction := "right"
        x1 += 1
    elsif chars (KEY_LEFT_ARROW) then
        direction := "left"
        x1 -= 1
    elsif chars (KEY_DOWN_ARROW) then
        direction := "down"
        y1 -= 1
    end if
    if chars ('w') then
        direction2 := "up"
        y2 += 1
    elsif chars ('d') then
        direction2 := "right"
        x2 += 1
    elsif chars ('a') then
        direction2 := "left"
        x2 -= 1
    elsif chars ('s') then
        direction2 := "down"
        y2 -= 1
    end if
    if y1 + 6 >= maxy then     %p1 boundaries
        y1 -= 1
    end if
    if y1 - 6 <= 0 then
        y1 += 1
    end if
    if x1 + 6 >= maxx then
        x1 -= 1
    end if
    if x1 - 6 <= 0 then
        x1 += 1
    end if
    if y2 + 6 >= maxy then     %p2 boundaries
        y2 -= 1
    end if
    if y2 - 6 <= 0 then
        y2 += 1
    end if
    if x2 + 6 >= maxx then
        x2 -= 1
    end if
    if x2 - 6 <= 0 then
        x2 += 1
    end if
    drawfilloval (x1, y1, 5, 5, 2)
    drawfilloval (x2, y2, 5, 5, 3)
    if chars ('/') then
        if direction = "up" then
            for i : y1 .. maxy
                if whatdotcolor (x1, i) = 1 then
                    new bullet, i
                    exit
                end if
                new bullet, 0
            end for
        elsif direction = "right" then
            for i : x1 .. maxx
                if whatdotcolor (i, y1) = 1 then
                    new bullet, i
                    exit
                end if
                new bullet, 0
            end for
        elsif direction = "left" then
            for decreasing i : x1 .. 0
                if whatdotcolor (i, y1) = 1 then
                    new bullet, i
                    exit
                end if
                new bullet, 0
            end for
        elsif direction = "down" then
            for decreasing i : y1 .. 0
                if whatdotcolor (x1, i) = 1 then
                    new bullet, i
                    exit
                end if
                new bullet, 0
            end for
        end if
        fork fire
    end if
    if chars (' ') then
        if direction2 = "up" then
            for i : y2 .. maxy
                if whatdotcolor (x2, i) = 1 then
                    new bullet2, i
                    exit
                end if
                new bullet2, 0
            end for
        elsif direction2 = "right" then
            for i : x2 .. maxx
                if whatdotcolor (i, y2) = 1 then
                    new bullet2, i
                    exit
                end if
                new bullet2, 0
            end for
        elsif direction2 = "left" then
            for decreasing i : x2 .. 0
                if whatdotcolor (i, y2) = 1 then
                    new bullet2, i
                    exit
                end if
                new bullet2, 0
            end for
        elsif direction2 = "down" then
            for decreasing i : y2 .. 0
                if whatdotcolor (x2, i) = 1 then
                    new bullet2, i
                    exit
                end if
                new bullet2, 0
            end for
        end if
        fork fire2
    end if
    delay (3)
    View.Update
    cls
    exit when win > 0
end loop
if win = 1 then
    put "Player one has won."
else
    put "Player two has won."
end if

Author:  apython1992 [ Tue May 10, 2011 7:27 am ]
Post subject:  RE:my attempt at shooting

I realize that it works, but processes are a bad way to go about something as simple as game animation. For some more insight about why they are a bad idea here, read this topic.

Author:  goroyoshi [ Tue May 10, 2011 5:08 pm ]
Post subject:  RE:my attempt at shooting

I know they are bad but this case works because of the slowdown when you want to fire

Author:  klutzedufus [ Tue May 17, 2011 4:45 pm ]
Post subject:  RE:my attempt at shooting

I would suggest taking the delays out of the if statements and putting one delay at the end, otherwise everything slows down if the if statement is being executed.

Author:  goroyoshi [ Tue May 17, 2011 5:54 pm ]
Post subject:  RE:my attempt at shooting

it has to be in the for loop

Author:  goroyoshi [ Wed Jun 08, 2011 7:08 pm ]
Post subject:  RE:my attempt at shooting

Turing:

var mainWin : int := Window.Open ("nooffscreenonly,graphics:600;600,nobuttonbar,position:center;center")
var bullet, bullet2 : flexible array 1 .. 0 of int
var direction, direction2 : string := "up"
var reply, map : string (1)
var pastx, pasty, pastx2, pasty2, count, count2 : int := 1
var recoil, recoil2, flag, flag2, cap, cap2, spawn, spawn2 : boolean := false
var win : int := 0
var chars : array char of boolean
var x1, y1 : int := 80
var x2, y2 : int := 520
process secure
    if cap = false then
        cap := true
        for x : 1 .. 10000
            delay (1)
            count += 1
            if x2 >= 250 and x2 <= 350 and y2 >= 250 and y2 <= 350 then
                cap := false
                count := 1
                exit
            end if
            if x1 < 250 or x1 > 350 or y1 < 250 or y1 > 350 then
                cap := false
                count := 1
                exit
            end if
            if count = 10000 then
                win := 1
            end if
        end for
    end if
end secure
process secure2
    if cap2 = false then
        cap2 := true
        for x : 1 .. 10000
            delay (1)
            count2 += 1
            if x1 >= 250 and x1 <= 350 and y1 >= 250 and y1 <= 350 then
                cap2 := false
                count2 := 1
                exit
            end if
            if x2 < 250 or x2 > 350 or y2 < 250 or y2 > 350 then
                cap2 := false
                count2 := 1
                exit
            end if
            if count2 = 10000 then
                win := 2
            end if
        end for
    end if
end secure2
process recharge
    delay (600)
    recoil := false
end recharge
process recharge2
    delay (600)
    recoil2 := false
end recharge2
process spawner
    spawn := true
    delay (1000)
    spawn := false
end spawner
process spawner2
    spawn2 := true
    delay (1000)
    spawn2 := false
end spawner2
process fire
    if recoil = false then
        pastx := x1
        pasty := y1
        recoil := true
        fork recharge
        if direction = "up" then
            for i : y1 .. upper (bullet)
                drawfilloval (pastx, i, 1, 1, red)
                if whatdotcolour (pastx, i + 2) = 3 then
                    if map not= "1" and map not= "4" then
                        win := 1
                    else
                        if flag = true then
                            flag := false
                        end if
                        x2 := 520
                        y2 := 520
                        fork spawner2
                    end if
                end if
                delay (1)
            end for
        elsif direction = "right" then
            for i : x1 .. upper (bullet)
                drawfilloval (i, pasty, 1, 1, red)
                if whatdotcolour (i + 2, pasty) = 3 then
                    if map not= "1" and map not= "4" then
                        win := 1
                    else
                        if flag = true then
                            flag := false
                        end if
                        x2 := 520
                        y2 := 520
                        fork spawner2
                    end if
                end if
                delay (1)
            end for
        elsif direction = "left" then
            for decreasing i : x1 .. upper (bullet)
                drawfilloval (i - 2, pasty, 1, 1, red)
                if whatdotcolour (i, pasty) = 3 then
                    if map not= "1" and map not= "4" then
                        win := 1
                    else
                        if flag = true then
                            flag := false
                        end if
                        x2 := 520
                        y2 := 520
                        fork spawner2
                    end if
                end if
                delay (1)
            end for
        elsif direction = "down" then
            for decreasing i : y1 .. upper (bullet)
                drawfilloval (pastx, i, 1, 1, red)
                if whatdotcolour (pastx, i - 2) = 3 then
                    if map not= "1" and map not= "4" then
                        win := 1
                    else
                        if flag = true then
                            flag := false
                        end if
                        x2 := 520
                        y2 := 520
                        fork spawner2
                    end if
                end if
                delay (1)
            end for
        end if
    end if
end fire
process fire2
    if recoil2 = false then
        pastx2 := x2
        pasty2 := y2
        recoil2 := true
        fork recharge2
        if direction2 = "up" then
            for i : y2 .. upper (bullet2)
                drawfilloval (pastx2, i, 1, 1, red)
                if whatdotcolour (pastx2, i + 2) = 2 then
                    if map not= "1" and map not= "4" then
                        win := 2
                    else
                        if flag2 = true then
                            flag2 := false
                        end if
                        x1 := 80
                        y1 := 80
                        fork spawner
                    end if
                end if
                delay (1)
            end for
        elsif direction2 = "right" then
            for i : x2 .. upper (bullet2)
                drawfilloval (i, pasty2, 1, 1, red)
                if whatdotcolour (i + 2, pasty2) = 2 then
                    if map not= "1" and map not= "4" then
                        win := 2
                    else
                        if flag2 = true then
                            flag2 := false
                        end if
                        x1 := 80
                        y1 := 80
                        fork spawner
                    end if
                end if
                delay (1)
            end for
        elsif direction2 = "left" then
            for decreasing i : x2 .. upper (bullet2)
                drawfilloval (i, pasty2, 1, 1, red)
                if whatdotcolour (i - 2, pasty2) = 2 then
                    if map not= "1" and map not= "4" then
                        win := 2
                    else
                        if flag2 = true then
                            flag2 := false
                        end if
                        x1 := 80
                        y1 := 80
                        fork spawner
                    end if
                end if
                delay (1)
            end for
        elsif direction2 = "down" then
            for decreasing i : y2 .. upper (bullet2)
                drawfilloval (pastx2, i, 1, 1, red)
                if whatdotcolour (pastx2, i - 2) = 2 then
                    if map not= "1" and map not= "4" then
                        win := 2
                    else
                        if flag2 = true then
                            flag2 := false
                        end if
                        x1 := 80
                        y1 := 80
                        fork spawner
                    end if
                end if
                delay (1)
            end for
        end if
    end if
end fire2
proc map1
    drawbox (50, 50, 275, 275, 1)
    drawbox (50, 550, 275, 325, 1)
    drawbox (550, 50, 325, 275, 1)
    drawbox (550, 550, 325, 325, 1)
    drawfillbox (51, 51, 149, 124, yellow)
    drawline (150, 275, 175, 275, 0)
    drawline (150, 275, 150, 50, 1)
    drawline (175, 275, 175, 50, 1)
    for x : 1 .. 2
        drawline (50, 50 + x * 75, 150, 50 + x * 75, 1)
        drawline (275, 50 + x * 75, 175, 50 + x * 75, 1)
    end for
    for x : 1 .. 3
        drawline (150, 0 + x * 75, 150, 25 + x * 75, 0)
        drawline (175, 0 + x * 75, 175, 25 + x * 75, 0)
    end for
    drawline (275, 425, 275, 450, 0)
    drawline (275, 425, 50, 425, 1)
    drawline (275, 450, 50, 450, 1)
    for x : 1 .. 2
        drawline (50 + x * 75, 450, 50 + x * 75, 550, 1)
        drawline (50 + x * 75, 425, 50 + x * 75, 325, 1)
    end for
    for x : 1 .. 3
        drawline (25 + x * 75, 425, x * 75, 425, 0)
        drawline (25 + x * 75, 450, x * 75, 450, 0)
    end for
    drawline (425, 325, 450, 325, 0)
    drawline (425, 325, 425, 550, 1)
    drawline (450, 325, 450, 550, 1)
    drawfillbox (549, 549, 451, 476, black)
    for x : 1 .. 2
        drawline (325, 325 + x * 75, 425, 325 + x * 75, 1)
        drawline (450, 325 + x * 75, 550, 325 + x * 75, 1)
    end for
    for x : 1 .. 3
        drawline (425, 275 + x * 75, 425, 300 + x * 75, 0)
        drawline (450, 275 + x * 75, 450, 300 + x * 75, 0)
    end for
    drawline (325, 150, 325, 175, 0)
    drawline (325, 150, 550, 150, 1)
    drawline (325, 175, 550, 175, 1)
    for x : 1 .. 2
        drawline (325 + x * 75, 150, 325 + x * 75, 50, 1)
        drawline (325 + x * 75, 175, 325 + x * 75, 275, 1)
    end for
    for x : 1 .. 3
        drawline (275 + x * 75, 150, 300 + x * 75, 150, 0)
        drawline (275 + x * 75, 175, 300 + x * 75, 175, 0)
    end for
end map1
proc map2
    drawbox (100, 100, 500, 500, 1)
    drawline (275, 100, 325, 100, 0)
    drawline (275, 500, 325, 500, 0)
    drawline (100, 275, 100, 325, 0)
    drawline (500, 275, 500, 325, 0)
    drawline (200, 300, 400, 300, 1)
    drawline (300, 200, 300, 400, 1)
end map2
proc map3
    for x : 1 .. 9
        drawline (0 + x * 60, 0, 0 + x * 60, 600, 1)
        drawline (0, 0 + x * 60, 600, 0 + x * 60, 1)
    end for
    for x : 0 .. 9
        for y : 0 .. 9
            drawline (20 + y * 60, 60 + x * 60, 40 + y * 60, 60 + x * 60, 0)
            drawline (60 + x * 60, 40 + y * 60, 60 + x * 60, 20 + y * 60, 0)
        end for
    end for
    drawfillbox (181, 181, 419, 419, 0)
end map3
proc map4
    drawbox (250, 250, 350, 350, black)
    drawline (0, 100, 100, 100, 1)
    drawline (100, 0, 100, 80, 1)
    drawbox (30, 150, 130, 400, 1)
    drawbox (130, 0, 250, 145, 1)
    drawbox (570, 450, 470, 200, 1)
    drawbox (470, 600, 350, 455, 1)
    drawline (500, 600, 500, 520, 1)
    drawline (600, 500, 500, 500, 1)
end map4
loop
    put "Map 1 is Office Buildings (CTF), Map 2 is Arena, Map 3 is Grids, ", skip, "Map 4 is King of the Hill."
    put "Which map would you like to play?" ..
    loop
        getch (map)
        exit when map = "1" or map = "2" or map = "3" or map = "4"
    end loop
    setscreen ("offscreenonly")
    loop
        drawbox (0, 0, maxx, maxy, 1)
        if map = "1" then
            map1
        elsif map = "2" then
            map2
        elsif map = "3" then
            map3
        else
            map4
        end if
        Input.KeyDown (chars)
        if spawn = false then
            if chars (KEY_UP_ARROW) then
                direction := "up"
                y1 += 1
            elsif chars (KEY_RIGHT_ARROW) then
                direction := "right"
                x1 += 1
            elsif chars (KEY_LEFT_ARROW) then
                direction := "left"
                x1 -= 1
            elsif chars (KEY_DOWN_ARROW) then
                direction := "down"
                y1 -= 1
            end if
        end if
        if spawn2 = false then
            if chars ('w') then
                direction2 := "up"
                y2 += 1
            elsif chars ('d') then
                direction2 := "right"
                x2 += 1
            elsif chars ('a') then
                direction2 := "left"
                x2 -= 1
            elsif chars ('s') then
                direction2 := "down"
                y2 -= 1
            end if
        end if
        if y1 + 6 >= maxy then
            y1 -= 1
        end if
        if y1 - 6 <= 0 then
            y1 += 1
        end if
        if x1 + 6 >= maxx then
            x1 -= 1
        end if
        if x1 - 6 <= 0 then
            x1 += 1
        end if
        if whatdotcolor (x1 + 6, y1) = 1 then
            x1 -= 1
        end if
        if whatdotcolor (x1 - 6, y1) = 1 then
            x1 += 1
        end if
        if whatdotcolor (x1, y1 + 6) = 1 then
            y1 -= 1
        end if
        if whatdotcolor (x1, y1 - 6) = 1 then
            y1 += 1
        end if
        if whatdotcolor (x1 + 6, y1 + 6) = 1 then
            x1 -= 1
            y1 -= 1
        end if
        if whatdotcolor (x1 - 6, y1 + 6) = 1 then
            x1 += 1
            y1 -= 1
        end if
        if whatdotcolor (x1 + 6, y1 - 6) = 1 then
            x1 -= 1
            y1 += 1
        end if
        if whatdotcolor (x1 - 6, y1 - 6) = 1 then
            x1 += 1
            y1 -= 1
        end if
        if y2 + 6 >= maxy then
            y2 -= 1
        end if
        if y2 - 6 <= 0 then
            y2 += 1
        end if
        if x2 + 6 >= maxx then
            x2 -= 1
        end if
        if x2 - 6 <= 0 then
            x2 += 1
        end if
        if whatdotcolor (x2 + 6, y2) = 1 then
            x2 -= 1
        end if
        if whatdotcolor (x2 - 6, y2) = 1 then
            x2 += 1
        end if
        if whatdotcolor (x2, y2 + 6) = 1 then
            y2 -= 1
        end if
        if whatdotcolor (x2, y2 - 6) = 1 then
            y2 += 1
        end if
        if whatdotcolor (x2 + 6, y2 + 6) = 1 then
            x2 -= 1
            y2 -= 1
        end if
        if whatdotcolor (x2 - 6, y2 + 6) = 1 then
            x2 += 1
            y2 -= 1
        end if
        if whatdotcolor (x2 + 6, y2 - 6) = 1 then
            x2 -= 1
            y2 += 1
        end if
        if whatdotcolor (x2 - 6, y2 - 6) = 1 then
            x2 += 1
            y2 -= 1
        end if
        if map = "1" then
            if x2 >= 51 and x2 <= 149 and y2 >= 51 and y2 <= 124 then
                flag := true
            end if
            if x1 >= 451 and x1 <= 599 and y1 >= 476 and y1 <= 599 then
                flag2 := true
            end if
        end if
        if map = "4" then
            if x1 >= 250 and x1 <= 350 and y1 >= 250 and y1 <= 350 then
                if x2 < 250 or x2 > 350 or y2 < 250 or y2 > 350 then
                    fork secure
                    drawfillbox (251, 251, 349, 349, yellow)
                end if
            end if
            if x2 >= 250 and x2 <= 350 and y2 >= 250 and y2 <= 350 then
                if x1 < 250 or x1 > 350 or y1 < 250 or y1 > 350 then
                    fork secure2
                    drawfillbox (251, 251, 349, 349, black)
                end if
            end if
        end if
        drawfilloval (x1, y1, 5, 5, 2)
        if flag2 = true then
            drawfilloval (x1, y1, 3, 3, black)
        end if
        drawfilloval (x2, y2, 5, 5, 3)
        if flag = true then
            drawfilloval (x2, y2, 3, 3, yellow)
        end if
        if spawn = false then
            if chars ('/') then
                if direction = "up" then
                    for i : y1 .. maxy
                        if whatdotcolor (x1, i) = 1 then
                            new bullet, i
                            exit
                        end if
                        new bullet, 0
                    end for
                elsif direction = "right" then
                    for i : x1 .. maxx
                        if whatdotcolor (i, y1) = 1 then
                            new bullet, i
                            exit
                        end if
                        new bullet, 0
                    end for
                elsif direction = "left" then
                    for decreasing i : x1 .. 0
                        if whatdotcolor (i, y1) = 1 then
                            new bullet, i
                            exit
                        end if
                        new bullet, 0
                    end for
                elsif direction = "down" then
                    for decreasing i : y1 .. 0
                        if whatdotcolor (x1, i) = 1 then
                            new bullet, i
                            exit
                        end if
                        new bullet, 0
                    end for
                end if
                fork fire
            end if
        end if
        if spawn2 = false then
            if chars (' ') then
                if direction2 = "up" then
                    for i : y2 .. maxy
                        if whatdotcolor (x2, i) = 1 then
                            new bullet2, i
                            exit
                        end if
                        new bullet2, 0
                    end for
                elsif direction2 = "right" then
                    for i : x2 .. maxx
                        if whatdotcolor (i, y2) = 1 then
                            new bullet2, i
                            exit
                        end if
                        new bullet2, 0
                    end for
                elsif direction2 = "left" then
                    for decreasing i : x2 .. 0
                        if whatdotcolor (i, y2) = 1 then
                            new bullet2, i
                            exit
                        end if
                        new bullet2, 0
                    end for
                elsif direction2 = "down" then
                    for decreasing i : y2 .. 0
                        if whatdotcolor (x2, i) = 1 then
                            new bullet2, i
                            exit
                        end if
                        new bullet2, 0
                    end for
                end if
                fork fire2
            end if
        end if
        if flag2 = true and flag = false and x1 >= 51 and x1 <= 149 and y1 >= 51 and y1 <= 124 then
            cap := true
        end if
        if flag = true and flag2 = false and x2 >= 451 and x2 <= 549 and y2 >= 476 and y2 <= 549 then
            cap2 := true
        end if
        delay (3)
        View.Update
        cls
        if map not= "1" then
            exit when win > 0
        else
            exit when cap = true or cap2 = true
        end if
    end loop
    setscreen ("nooffscreenonly")
    if cap = true then
        win := 1
    else
        win := 2
    end if
    if win = 1 then
        put "Player one has won."
    else
        put "Player two has won."
    end if
    put "Would you like to continue (y/n) "
    loop
        getch (reply)
        exit when reply = "y" or reply = "n"
    end loop
    if reply = "y" then
        x1 := 80
        y1 := 80
        x2 := 520
        y2 := 520
        flag := false
        flag2 := false
        cap := false
        cap2 := false
        win := 0
    else
        exit
    end if
end loop
locate (17, 18)
put "Created by: Bruno Maillette 2011."
locate (18, 18)
put "Press any key to Exit" ..
getch (reply)
Window.Close (mainWin)

Now exits when done, has CTF, king of the hill and deathmatch
COMMENT ON PROCESSES AND I WILL GET ANGRY, i just want an opinion on the game and suggestions on what to add

Author:  Raknarg [ Wed Jun 08, 2011 8:14 pm ]
Post subject:  RE:my attempt at shooting

Found a glitch: If you run the guy perpendicular to an open line, it goes along with the line and then you can pass through the wall in either direction.

There's a simple way to fix this that'll also shorten your code. You put the blocking statements with your movement statement. Ex:
Turing:

if chars (KEY_UP_ARROW) and whatdotcolor (x1, y1 + 1) not= 1 then
                direction := "up"
                y1 += 1

Author:  Raknarg [ Wed Jun 08, 2011 8:17 pm ]
Post subject:  RE:my attempt at shooting

Also, although it's probably not worth mentioning, your guys cant get hit if they haven't moved. Don't know if that was on purpose.

Author:  goroyoshi [ Wed Jun 08, 2011 8:26 pm ]
Post subject:  RE:my attempt at shooting

where did you notice that, i haven't seen that yet

Author:  Raknarg [ Wed Jun 08, 2011 8:39 pm ]
Post subject:  RE:my attempt at shooting

Which one? Because I noticed both of those on every map.

Author:  goroyoshi [ Wed Jun 08, 2011 8:43 pm ]
Post subject:  RE:my attempt at shooting

wtf, i do that all the time for testing, move one player across then shoot down
UPDATE: i just tried that out with all maps and it works, they get hit even without movement
you trolling me?

Author:  Raknarg [ Wed Jun 08, 2011 9:37 pm ]
Post subject:  RE:my attempt at shooting

Why the hell would I troll you? I'm just telling you what I saw. Maybe it works most of the time, it just didn't work for me.

Author:  Raknarg [ Wed Jun 08, 2011 9:38 pm ]
Post subject:  RE:my attempt at shooting

Oh wait, i'm retarded. I forgot they respawned in the same spot that they haven't moved. -.-' The black background in Area 1 tricked me :p

Anyways, the first thing's still an issue.

Author:  Raknarg [ Thu Jun 09, 2011 9:00 pm ]
Post subject:  RE:my attempt at shooting

Oh, sorry, when I said perpenicular to the line, I should have said parrallel to and along the line.


: