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

Username:   Password: 
 RegisterRegister   
 I cant move while I shoot!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
NeutronX




PostPosted: Fri Nov 09, 2007 3:34 pm   Post subject: I cant move while I shoot!

I want to be able to drive my race cars and also have the player 1 car be able to shoot without pausing the rest of the game. This is a racing game. Can someone please edit this code so that I can do that? THX!

code:

import GUI

setscreen ("graphics:1080;400,nobuttonbar")


drawfill (1, 1, 9, 9)


process engine
    loop
        Music.PlayFile ("lancia_integrale.wav")
    end loop
end engine

procedure start
    locate (1, 1)
    cls
    drawfill (100, 100, red, 7)
    locatexy (430, 200)
    colourback (red)
    put "RACE STARTING IN 5 SECONDS"
    delay (100)
    cls

    drawfillbox (0, 0, 1080, 20, 21)
    drawfillbox (0, 400, 640, 20, 100)
    var pic7 : int := Pic.FileNew ("cloud.bmp")
    Pic.Draw (pic7, 0, 18, 0)
    var x : int := 120
    var y : int := 35
    var x1 : int := 50
    var y1 : int := 35
    var centered : boolean := false
    var chars : array char of boolean
 
 

    var pic1 : int := Pic.FileNew ("coolcar.bmp")
    var sprite1 : int := Sprite.New (pic1)

    var pic6 : int := Pic.FileNew ("orb1.bmp")
    Pic.Draw (pic6, 500, 20, 0)

    var pic5 : int := Pic.FileNew ("coolcar2.bmp")
    var sprite2 : int := Sprite.New (pic5)

    var mypic7 : int := Pic.FileNew ("rocket.bmp")
    var mypic8 : int := Pic.FileNew ("speed.bmp")
    var pic9 : int := Pic.FileNew ("bullet.bmp")
    var sprite3 : int := Sprite.New (pic9)


    var gravity : int := -1

    var vx, vy : int
    vy := 0
    vx := 0

    var vx1, vy1 : int
    vy1 := 0
    vx1 := 0

    var jumping : boolean := false
    var jumping1 : boolean := false
   
    var special:boolean:=false
    var special1:boolean:=false
   
   
var bullety : int
var bulletx : int

bullety := 200
var bullet : int

var Shooting : boolean := false

    fork engine

    loop
        Sprite.Show (sprite1)
        Sprite.SetPosition (sprite1, x, y, true)

        delay (20)


        Sprite.Show (sprite1)
        Sprite.SetPosition (sprite1, x, y, true)

        Input.KeyDown (chars)
        if x >= 1050 then
            chars (KEY_UP_ARROW) := false
        end if

        if chars (KEY_UP_ARROW) and not jumping then
            jumping := true
            vy := 10
        end if

        if jumping then
            x += 1
            y += vy
            vy += gravity
            delay (7)
        end if

        if y <= 35 then
            jumping := false
            y := 35
        end if

        if x <= 30 then
            chars (KEY_LEFT_ARROW) := false
        end if

        if chars (KEY_LEFT_ARROW) then
            x -= 4
        end if

        if x >= 1050 then
            chars (KEY_RIGHT_ARROW) := false
            locatexy (2, 390)
            colourback (white)
            put "PLAYER 1 WINS!" ..
            exit
        end if

        if chars (KEY_RIGHT_ARROW) then
            x += 4
        end if
       
       
       
        Sprite.Show (sprite1)
        Sprite.SetPosition (sprite1, x, y, true)
        delay (1)
        View.Update

       
        if x > 500 and x < 510 then
            locatexy (56, 350)
            colourback (white)
            put "Player 1 has their SPECIAL!!!!!!" ..
            Pic.Draw (mypic7, 2, 315, 0)
        end if
       
        if x > 900 and x<maxx then
           locatexy (56, 350)
            colourback (white)
            put "Player 1 has lost their SPECIAL!" ..
        end if
       



        if x1 >= 1050 then
            chars ('w') := false
        end if

        if chars ('w') and not jumping1 then
            jumping1 := true
            vy1 := 10
        end if

        if jumping1 then
            x1 += 1
            y1 += vy1
            vy1 += gravity
            delay (7)
        end if

        if y1 <= 35 then
            jumping1 := false
            y1 := 35
        end if

        if x1 <= 30 then
            chars ('a') := false
        end if

        if chars ('a') then
            x1 -= 4
        end if

        if x1 >= 1050 then
            chars ('d') := false
            locatexy (2, 370)
            colourback (white)
            put "PLAYER 2 WINS!" ..
            exit
        end if

       
        if chars ('d') then
            x1 += 4
        end if

     
        if x1 >= 500 and x1<900 then
            if chars ('f') then
                if chars ('d') then
                    x1 += 8
                end if
            end if
        end if


        if x1 > 500 and x1 < 510 then
            locatexy (56, 280)
            colourback (white)
            put "Player 2 has their SPECIAL!!!!!!" ..
            Pic.Draw (mypic8, 2, 250, 0)
        end if
       
        if x1 > 900 and x1<maxx then
             locatexy (56, 280)
            colourback (white)
            put "Player 2 has lost their SPECIAL!" ..
        end if
       


        Sprite.Show (sprite2)
        Sprite.SetPosition (sprite2, x1, y1, true)
        delay (1)
        View.Update
       
        if x>500 and x<900 then
        if x<x1 then
        if chars (' ') then
        for i: bulletx .. x1 by 10           
        Sprite.Show (sprite3)
        Sprite.SetPosition (sprite3, i, y, true)       
        delay (50)
        View.Update
        end for
        Sprite.Hide (sprite3)
        Sprite.Hide (sprite2)
        Sprite.Show(sprite2)
        Sprite.SetPosition (sprite2, 500, y, true)
        x1:=500
        end if
        end if
        end if

        bulletx := x
        if bulletx = x1 then
            Shooting := false           
            bulletx := -20
        end if

    end loop

end start

procedure help
    locate (1, 1)
    cls

    drawfillbox (540, 150, 1080, 400, green)

    var mypic : int := Pic.FileNew ("racer.bmp")
    Pic.Draw (mypic, 100, 250, 0)

    var mypic1 : int := Pic.FileNew ("orb.bmp")
    Pic.Draw (mypic1, 30, 80, 0)

    var mypic2 : int := Pic.FileNew ("rocket.bmp")
    Pic.Draw (mypic2, 30, 10, 0)

    var mypic3 : int := Pic.FileNew ("speed.bmp")
    Pic.Draw (mypic3, 280, 10, 0)

    locatexy (710, 390)
    colourback (green)
    put "*PLAYER 1 CONTROLS*"
    locatexy (660, 370)
    colourback (green)
    put "-PRESS THE 'LEFT' BUTTON TO MOVE BACKWARD"
    locatexy (660, 360)
    colourback (green)
    put "-PRESS THE 'RIGHT' BUTTON TO MOVE FORWARD"
    locatexy (660, 350)
    colourback (green)
    put "-PRESS THE 'UP' BUTTON TO HOP YOUR CAR"
    locatexy (660, 330)
    colourback (green)
    put "-PRESS THE SPACE BUTTON TO USE YOUR SPECIAL"
    locatexy (710, 280)
    colourback (green)
    put "*PLAYER 2 CONTROLS*"
    locatexy (660, 260)
    colourback (green)
    put "-PRESS THE 'A' BUTTON TO MOVE BACKWARD"
    locatexy (660, 240)
    colourback (green)
    put "-PRESS THE 'D' BUTTON TO MOVE FORWARD"
    locatexy (660, 230)
    colourback (green)
    put "-PRESS THE 'W' BUTTON TO HOP YOUR CAR"
    locatexy (660, 210)
    colourback (green)
    put "-PRESS THE 'F' BUTTON WHILE HOLDING THE 'D'"
    locatexy (665, 200)
    colourback (green)
    put "BUTTON TO USE YOUR SPECIAL"

    locatexy (10, 150)
    colourback (white)
    put "DRIVE OVER THE BLUE ORBS TO GET"
    put " A SPECIAL"
    locatexy (10, 70)
    colourback (white)
    put "THE PLAYER 1 SPECIAL"
    locatexy (250, 70)
    colourback (white)
    put "THE PLAYER 2 SPECIAL"
    var button3 : int := GUI.CreateButton (450, 100, 0, "Play", start)
end help

var button1 : int := GUI.CreateButton (500, 250, 0, "Start Game", start)
var button2 : int := GUI.CreateButton (500, 200, 0, "How to Play", help)

loop
    exit when GUI.ProcessEvent
end loop
Sponsor
Sponsor
Sponsor
sponsor
Nick




PostPosted: Fri Nov 09, 2007 3:38 pm   Post subject: RE:I cant move while I shoot!

dont spam
HeavenAgain




PostPosted: Fri Nov 09, 2007 3:41 pm   Post subject: RE:I cant move while I shoot!

werent you that guy from the other topic we gave you some feed backs, and you ingored us? Surprised
NeutronX




PostPosted: Fri Nov 09, 2007 3:50 pm   Post subject: Re: I cant move while I shoot!

ya my bad but I made some minor changes. I still cant move my car and shoot though so I still need help
HeavenAgain




PostPosted: Fri Nov 09, 2007 3:58 pm   Post subject: RE:I cant move while I shoot!

i bet the solution to this is still Input.KeyDown, and you did make changes, cept for that
NeutronX




PostPosted: Fri Nov 09, 2007 5:43 pm   Post subject: Re: I cant move while I shoot!

whats wrong with it?
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  [ 6 Posts ]
Jump to:   


Style:  
Search: