
-----------------------------------
TrAnCeIn4LiFe
Sat Jun 05, 2004 9:43 am

double button
-----------------------------------
is there a way to make two buttons work at once, because i have missles shooting out of my plane and when i shoot everything pauses until the missle hits.. is there a way to get ride of that?

-----------------------------------
Paul
Sat Jun 05, 2004 10:09 am


-----------------------------------
Don't enclose your missile moving part in it's own loop, have it as a part of the other parts of the program (like plane moving) or have a process.

-----------------------------------
Dan
Sat Jun 05, 2004 2:01 pm


-----------------------------------
Don't enclose your missile moving part in it's own loop, have it as a part of the other parts of the program (like plane moving) or have a process.

I whould not recomend process for this, probly best to make one main loop with deals with eveything. Process can be good but you have to understand how they work and turing has limited conortl over them. Since turing has no way to set proity of a process all you know is that the code may run at some time. So baliky unless you got a dual CPU system a process will run lines of code in it at basicly random times durning the excution of your progame. If it dose not mater when they run then it could be good to use them but it gives you less conortl over things.

-----------------------------------
Cervantes
Sat Jun 05, 2004 5:09 pm

Re: double button
-----------------------------------
is there a way to make two buttons work at once, because i have missles shooting out of my plane and when i shoot everything pauses until the missle hits.. is there a way to get ride of that?

are you using getch?  if so, use Input.KeyDown.  are you talking about mouse buttons or keyboard buttons?  if mouse buttons, then use Mouse.ButtonChoose("multibutton")

-----------------------------------
omni
Sat Jun 05, 2004 6:24 pm


-----------------------------------
i dont think those are the buttons hes talking about Cervantes. I had a similiar problem with my shooting game. Whenever the user pressed a button to shoot, I would call a procedure to shoot the bullet. THAT was my mistake. As the others said, make your main game loop handle the bullet increasing. I think this is what TrAnCeIn4LiFe code looks like:

proc shoot
   loop
      %increase bullet
      exit when bullethitwall=true
   end loop
end shoot
loop
  if key(shoot) then
  shoot
  end if 
end loop

Well at least thats what my code looked like before.

-----------------------------------
TrAnCeIn4LiFe
Sat Jun 05, 2004 8:35 pm


-----------------------------------
ahem this is what my code looks like

    % input keys to move plane around
    loop
        Input.KeyDown (chars)
        if chars (KEY_UP_ARROW) then
            for x : 1 .. 1
                xx (x) := x
                yt := 4
            end for
        elsif chars (KEY_RIGHT_ARROW) then
            for x : 1 .. 1
                xx (x) := 2
                xr := 4
            end for
        elsif chars (KEY_DOWN_ARROW) then
            for x : 1 .. 1
                xx (x) := x
                yb := yb - 4
            end for
        elsif chars (KEY_LEFT_ARROW) then
            for x : 1 .. 1
                xx (x) := x + 2
                xl := xl - 4
            end for
        end if
        if chars ('x') then
            if xx (1) > 0 then
                for bullet : 1 .. maxy
                    for x : 1 .. 1
                        bxr := bxr + xl + xr
                        byt := byt + yb + yt
                        View.Update
                        Pic.Draw (background, 0, 0, picCopy)
                        Pic.Draw (sprite (xx (x)), bxr, byt, picMerge)
                        Pic.Draw (missle, bxr + 25, byt + bullet, picMerge)
                        View.Update
                        Pic.Draw (missle, bxr + 0, byt + bullet, picMerge)
                        View.Update
                        Pic.Draw (missle, bxr + 50, byt + bullet, picMerge)
                        bars
                    end for
                end for
            end if
        elsif chars ('z') then
            if xx (1) > 0 then
                for bullet : 1 .. maxy
                    for x : 1 .. 1
                        bxr := bxr + xl + xr
                        byt := byt + yb + yt
                        View.Update
                        Pic.Draw (background, 0, 0, picCopy)
                        Pic.Draw (sprite (xx (x)), bxr, byt, picMerge)
                        Pic.Draw (missle, bxr + 25, byt + bullet, picMerge)
                        bars
                    end for
                end for
            end if
        end if

        if xx (1) > 0 then         % move the airplane
            for x : 1 .. 1
                bxr := bxr + xl + xr
                byt := byt + yb + yt
                View.Update
                Pic.Draw (background, 0, 0, picCopy)
                Pic.Draw (sprite (xx (x)), bxr, byt, picMerge)
                bars
            end for
            View.Update
        end if


adn the problem is i have liek wind factor in my game so it pushes you to the sides... ehe makes it more challenging but the main problem is when i shoot the plain gets stuck with the shot like the screen freezes in the spot until the shot gets to the end of y...

-----------------------------------
omni
Sat Jun 05, 2004 9:30 pm


-----------------------------------
still is the same thing, you put the bullet increasing and drawing in a separate loop. So that means that the program has to finish with that loop before going on with the main game loop. If you move it somehow into the main game loop, then you wouldn't have the problem.
