Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 This is my shooting game plz help me!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Darkmantis




PostPosted: Tue Nov 22, 2005 7:45 pm   Post subject: This is my shooting game plz help me!

I've been working on this program but i've run into a bit of trouble, try the game, for 1st player hold an arrow and press enter to fire and the 2nd player controls are a,w,s,d and b to fire, hold a moving butten and the fire butten to fire. I need to make it so the charactors move during a shot. PLZ help

code:
setscreen ("graphics:800,600")
var x, y, c, d, q, u, k, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, speed1, speed2, lives, lives1, lives2 : int
var kp : array char of boolean
var nme1, nme2 : string
var ch : string (1)
var text2 : int := Font.New ("Times New Roman:28")
var text1 : int := Font.New ("Times New Roman:38:Bold")
x := 400
y := 100
c := 100
d := 400
speed1 := 5
speed2 := 5
procedure drawcar
    drawfilloval (x, y, 4, 4, blue)
    drawline (x + 2, y - 3, x + 2, y + 3, grey)
    delay (speed1)
end drawcar
procedure drawcarleft
    drawfilloval (x, y, 4, 4, blue)
    drawline (x - 2, y + 3, x - 2, y - 3, grey)
    delay (speed1)
end drawcarleft
procedure drawcarup
    drawfilloval (x, y, 4, 4, blue)
    drawline (x - 2, y + 3, x + 2, y + 3, grey)
    delay (speed1)
end drawcarup
procedure drawcardown
    drawfilloval (x, y, 4, 4, blue)
    drawline (x - 2, y - 3, x + 2, y - 3, grey)
    delay (speed1)
end drawcardown

procedure drawcar2
    drawfilloval (c, d, 4, 4, red)
    drawline (c + 2, d - 3, c + 2, d + 3, grey)
    delay (speed2)
end drawcar2

procedure drawcarleft2
    drawfilloval (c, d, 4, 4, red)
    drawline (c - 2, d + 3, c - 2, d - 3, grey)
    delay (speed2)
end drawcarleft2
procedure drawcarup2
    drawfilloval (c, d, 4, 4, red)
    drawline (c - 2, d + 3, c + 2, d + 3, grey)
    delay (speed2)
end drawcarup2
procedure drawcardown2
    drawfilloval (c, d, 4, 4, red)
    drawline (c - 2, d - 3, c + 2, d - 3, grey)
    delay (speed2)
end drawcardown2

procedure erasecar
    drawfilloval (x, y, 5, 5, white)
end erasecar

procedure erasecar2
    drawfilloval (c, d, 5, 5, white)
end erasecar2

procedure game
    randint (q, 1, 800)
    randint (u, 1, 600)
    Pic.ScreenLoad ("arena.bmp", 1, 1, picMerge)
    drawcar
    drawcar2
    lives1 := lives
    lives2 := lives
    locate (1, 30)
    put nme1
    locate (2, 30)
    put nme2
    loop
        locate (1, 40)
        put lives1
        locate (2, 40)
        put lives2
        drawfilloval (q, u, 5, 5, green)
        c1 := whatdotcolor (x - 7, y)
        c2 := whatdotcolor (x + 7, y)
        c3 := whatdotcolor (x, y + 7)
        c4 := whatdotcolor (x, y - 7)
        c5 := whatdotcolor (c - 7, d)
        c6 := whatdotcolor (c + 7, d)
        c7 := whatdotcolor (c, d + 7)
        c8 := whatdotcolor (c, d - 7)

        if c1 = red or c1 = black then
            x := x + 1
            speed1 := 5
        end if
        if c2 = red or c2 = black then
            x := x - 1
            speed1 := 5
        end if
        if c3 = red or c3 = black then
            y := y - 1
            speed1 := 5
        end if
        if c4 = red or c4 = black then
            y := y + 1
            speed1 := 5
        end if

        if c1 = green then
            speed1 := 2
        end if
        if c2 = green then
            speed1 := 2
        end if
        if c3 = green then
            speed1 := 2
        end if
        if c4 = green then
            speed1 := 2
        end if

        if c5 = blue or c5 = black then
            c := c + 1
            speed2 := 5
        end if
        if c6 = blue or c6 = black then
            c := c - 1
            speed2 := 5
        end if
        if c7 = blue or c7 = black then
            d := d - 1
            speed2 := 5
        end if
        if c8 = blue or c8 = black then
            d := d + 1
            speed2 := 5
        end if

        if c5 = green then
            speed2 := 2
        end if
        if c6 = green then
            speed2 := 2
        end if
        if c7 = green then
            speed2 := 2
        end if
        if c8 = green then
            speed2 := 2
        end if

        Input.KeyDown (kp)
        if kp (KEY_RIGHT_ARROW) then
            erasecar
            drawcar
            x := x + 1
            if x > 794 then
                x := x - 1
            end if
            if kp (KEY_ENTER) then
                k := y
                for b : x + 10 .. 800 by 2
                Input.KeyDown (kp)   
                 c9 := whatdotcolor (b - 7, k)
                    c10 := whatdotcolor (b + 7, k)
                    c11 := whatdotcolor (b, k + 7)
                    c12 := whatdotcolor (b, k - 7)
                    drawfilloval (b, k, 3, 3, blue)
                    delay (3)
                    drawfilloval (b, k, 3, 3, white)
                    if c9 = black or c9 = red then
                        k := 1000
                    end if
                    if c10 = black or c10 = red then
                        k := 1000
                    end if
                    if c11 = black or c11 = red then
                        k := 1000
                    end if
                    if c12 = black or c12 = red then
                        k := 1000
                    end if

                    if c9 = red then
                        lives2 := lives2 - 1
                    end if
                    if c10 = red then
                        lives2 := lives2 - 1
                    end if
                    if c11 = red then
                        lives2 := lives2 - 1
                    end if
                    if c12 = red then
                        lives2 := lives2 - 1
                    end if
                end for
            end if
        end if
        if kp (KEY_LEFT_ARROW) then
            erasecar
            drawcarleft
            x := x - 1
            if x < 6 then
                x := x + 1
            end if
            if kp (KEY_ENTER) then
                k := y
                for decreasing b : x - 10 .. 0 by 2
                Input.KeyDown (kp)
                   c9 := whatdotcolor (b - 7, k)
                    c10 := whatdotcolor (b + 7, k)
                    c11 := whatdotcolor (b, k + 7)
                    c12 := whatdotcolor (b, k - 7)
                    drawfilloval (b, k, 3, 3, blue)
                    delay (3)
                    drawfilloval (b, k, 3, 3, white)
                    if c9 = black or c9 = red then
                        k := 1000
                    end if
                    if c10 = black or c10 = red then
                        k := 1000
                    end if
                    if c11 = black or c11 = red then
                        k := 1000
                    end if
                    if c12 = black or c12 = red then
                        k := 1000
                    end if
                    if c9 = red then
                        lives2 := lives2 - 1
                    end if
                    if c10 = red then
                        lives2 := lives2 - 1
                    end if
                    if c11 = red then
                        lives2 := lives2 - 1
                    end if
                    if c12 = red then
                        lives2 := lives2 - 1
                    end if
                end for
            end if
        end if

        if kp (KEY_UP_ARROW) then
            erasecar
            drawcarup
            y := y + 1
            if y > 594 then
                y := y - 1
            end if
            if kp (KEY_ENTER) then
                k := x
                for b : y + 10 .. 600 by 2
                    c9 := whatdotcolor (k - 7, b)
                    c10 := whatdotcolor (k + 7, b)
                    c11 := whatdotcolor (k, b + 7)
                    c12 := whatdotcolor (k, b - 7)
                    drawfilloval (k, b, 3, 3, blue)
                    delay (3)
                    drawfilloval (k, b, 3, 3, white)
                    if c9 = black or c9 = red then
                        k := 1000
                    end if
                    if c10 = black or c10 = red then
                        k := 1000
                    end if
                    if c11 = black or c11 = red then
                        k := 1000
                    end if
                    if c12 = black or c12 = red then
                        k := 1000
                    end if
                    if c9 = red then
                        lives2 := lives2 - 1
                    end if
                    if c10 = red then
                        lives2 := lives2 - 1
                    end if
                    if c11 = red then
                        lives2 := lives2 - 1
                    end if
                    if c12 = red then
                        lives2 := lives2 - 1
                    end if
                end for
            end if
        end if

        if kp (KEY_DOWN_ARROW) then
            erasecar
            drawcardown
            y := y - 1
            if y < 6 then
                y := y + 1
            end if
            if kp (KEY_ENTER) then
                k := x
                for decreasing b : y - 10 .. 0 by 2
                    c9 := whatdotcolor (k - 7, b)
                    c10 := whatdotcolor (k + 7, b)
                    c11 := whatdotcolor (k, b + 7)
                    c12 := whatdotcolor (k, b - 7)
                    drawfilloval (k, b, 3, 3, blue)
                    delay (3)
                    drawfilloval (k, b, 3, 3, white)
                    if c9 = black or c9 = red then
                        k := 1000
                    end if
                    if c10 = black or c10 = red then
                        k := 1000
                    end if
                    if c11 = black or c11 = red then
                        k := 1000
                    end if
                    if c12 = black or c12 = red then
                        k := 1000
                    end if
                    if c9 = red then
                        lives2 := lives2 - 1
                    end if
                    if c10 = red then
                        lives2 := lives2 - 1
                    end if
                    if c11 = red then
                        lives2 := lives2 - 1
                    end if
                    if c12 = red then
                        lives2 := lives2 - 1
                    end if

                end for
            end if
        end if

        if kp ('d') then
            erasecar2
            drawcar2
            c := c + 1
            if c > 794 then
                c := c - 1
            end if
            if kp ('b') then
                k := d
                for b : c + 10 .. 800 by 2
                    c9 := whatdotcolor (b - 7, k)
                    c10 := whatdotcolor (b + 7, k)
                    c11 := whatdotcolor (b, k + 7)
                    c12 := whatdotcolor (b, k - 7)
                    drawfilloval (b, k, 3, 3, red)
                    delay (3)
                    drawfilloval (b, k, 3, 3, white)
                    if c9 = black or c9 = blue then
                        k := 800
                    end if
                    if c10 = black or c10 = blue then
                        k := 800
                    end if
                    if c11 = black or c11 = blue then
                        k := 800
                    end if
                    if c12 = black or c12 = blue then
                        k := 800
                    end if
                    if c9 = blue then
                        lives1 := lives1 - 1
                    end if
                    if c10 = blue then
                        lives1 := lives1 - 1
                    end if
                    if c11 = blue then
                        lives1 := lives1 - 1
                    end if
                    if c12 = blue then
                        lives1 := lives1 - 1
                    end if
                end for
            end if
        end if
        if kp ('a') then
            erasecar2
            drawcarleft2
            c := c - 1
            if c < 6 then
                c := c + 1
            end if
            if kp ('b') then
                k := d
                for decreasing b : c - 10 .. 0 by 2
                    c9 := whatdotcolor (b - 7, k)
                    c10 := whatdotcolor (b + 7, k)
                    c11 := whatdotcolor (b, k + 7)
                    c12 := whatdotcolor (b, k - 7)
                    drawfilloval (b, k, 3, 3, red)
                    delay (3)
                    drawfilloval (b, k, 3, 3, white)
                    if c9 = black or c9 = blue then
                        k := 1000
                    end if
                    if c10 = black or c10 = blue then
                        k := 1000
                    end if
                    if c11 = black or c11 = blue then
                        k := 1000
                    end if
                    if c12 = black or c12 = blue then
                        k := 1000
                    end if
                    if c9 = blue then
                        lives1 := lives1 - 1
                    end if
                    if c10 = blue then
                        lives1 := lives1 - 1
                    end if
                    if c11 = blue then
                        lives1 := lives1 - 1
                    end if
                    if c12 = blue then
                        lives1 := lives1 - 1
                    end if
                end for
            end if
        end if

        if kp ('w') then
            erasecar2
            drawcarup2
            d := d + 1
            if d > 594 then
                d := d - 1
            end if
            if kp ('b') then
                k := c
                for b : d + 10 .. 600 by 2
                    c9 := whatdotcolor (k - 7, b)
                    c10 := whatdotcolor (k + 7, b)
                    c11 := whatdotcolor (k, b + 7)
                    c12 := whatdotcolor (k, b - 7)
                    drawfilloval (k, b, 3, 3, red)
                    delay (3)
                    drawfilloval (k, b, 3, 3, white)
                    if c9 = black or c9 = blue then
                        k := 1000
                    end if
                    if c10 = black or c10 = blue then
                        k := 1000
                    end if
                    if c11 = black or c11 = blue then
                        k := 1000
                    end if
                    if c12 = black or c12 = blue then
                        k := 1000
                    end if
                    if c9 = blue then
                        lives1 := lives1 - 1
                    end if
                    if c10 = blue then
                        lives1 := lives1 - 1
                    end if
                    if c11 = blue then
                        lives1 := lives1 - 1
                    end if
                    if c12 = blue then
                        lives1 := lives1 - 1
                    end if
                end for
            end if
        end if

        if kp ('s') then
            erasecar2
            drawcardown2
            d := d - 1
            if d < 6 then
                d := d + 1
            end if
            if kp ('b') then
                k := c
                for decreasing b : d - 10 .. 0 by 2
                    c9 := whatdotcolor (k - 7, b)
                    c10 := whatdotcolor (k + 7, b)
                    c11 := whatdotcolor (k, b + 7)
                    c12 := whatdotcolor (k, b - 7)
                    drawfilloval (k, b, 3, 3, red)
                    delay (3)
                    drawfilloval (k, b, 3, 3, white)
                    if c9 = black or c9 = blue then
                        k := 1000
                    end if
                    if c10 = black or c10 = blue then
                        k := 1000
                    end if
                    if c11 = black or c11 = blue then
                        k := 1000
                    end if
                    if c12 = black or c12 = blue then
                        k := 1000
                    end if
                    if c9 = blue then
                        lives1 := lives1 - 1
                    end if
                    if c10 = blue then
                        lives1 := lives1 - 1
                    end if
                    if c11 = blue then
                        lives1 := lives1 - 1
                    end if
                    if c12 = blue then
                        lives1 := lives1 - 1
                    end if
                end for
            end if
        end if
        if lives1 = 0 then
            cls
            Draw.Text ("Red Wins!", maxx div 3, maxy div 2, text1, green)
            exit
        elsif lives2 = 0 then
            cls
            Draw.Text ("Blue Wins!", maxx div 3, maxy div 2, text1, green)
            exit
        end if

    end loop
end game

procedure mainmenu

    Draw.Text ("Manuver Shooter", maxx div 3, maxy div 1.5, text2, green)
    Draw.Text ("PRESS ANY KEY TO CONTINUE", 125, 50, text2, green)
    getch (ch)
    cls
    put "Player One enter your name"
    get nme1
    Draw.Text ("PRESS ANY KEY TO CONTINUE", 125, 50, text2, green)
    getch (ch)
    cls
    put "Player Two enter your name"
    get nme2
    Draw.Text ("PRESS ANY KEY TO CONTINUE", 125, 50, text2, green)
    getch (ch)
    cls
    put "Choose the amount of lives"
    get lives
    Draw.Text ("PRESS ANY KEY TO CONTINUE", 125, 50, text2, green)
    getch (ch)
    cls
    game
end mainmenu

setscreen ("position:truemiddle,centre")
var clr : int := 218
drawfillbox (0, 0, 800, 600, black)
for n : 0 .. 39
    RGB.SetColor (clr, 0, n / 39, 0)
    Font.Draw ("DarkMantis Productions", (maxx div 2) - (Font.Width ("DarkMantis Productions", text1) div 2), (maxy div 1.5) - 9, text1, clr)
    RGB.SetColor (clr, 0, n / 39, 0)
    Font.Draw ("Presents...", (maxx div 2) - (Font.Width ("Presents...", text1) div 2), (maxy div 2.5) - 9, text1, clr)
    View.Update
    View.Update
    delay (50)
end for
delay (1000)
for decreasing n : 39 .. 0
    RGB.SetColor (clr, 0, n / 39, 0)
    Font.Draw ("DarkMantis Productions", (maxx div 2) - (Font.Width ("DarkMantis Productions", text1) div 2), (maxy div 1.5) - 9, text1, clr)
    RGB.SetColor (clr, 0, n / 39, 0)
    Font.Draw ("Presents...", (maxx div 2) - (Font.Width ("Presents...", text1) div 2), (maxy div 2.5) - 9, text1, clr)
    View.Update
    delay (50)
end for
mainmenu
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: