
-----------------------------------
superman500
Tue Nov 14, 2006 11:55 pm

getting a character without having to stop the program
-----------------------------------
hey guys...im trying to make a DDR program for my g11 final game project and right now im trying to see how im gonna make the program detect keys without stopping the arrows....


%//////////////////////////////////////////////////////////////////////////////
procedure start
    setscreen ("graphics:800;800")
    colorback (red)
    cls
    var x : array 1 .. 7 of int := init (180, 180, 80, 80,
        30, 80, 80)
    var y : array 1 .. 7 of int := init (740, 710, 700, 675,
        725, 775, 750)
    Draw.FillPolygon (x, y, 7, brightblue)
    Draw.Polygon (x, y, 7, cyan)
end start

procedure sety (num : int, var y : array 1 .. 7 of int)
    y (1) := num + 15
    y (2) := num - 15
    y (3) := num - 25
    y (4) := num - 50
    y (5) := num
    y (6) := num + 50
    y (7) := num + 25
end sety

procedure leftarrow
    var x : array 1 .. 7 of int := init (180, 180, 80, 80,
        30, 80, 80)
    var y : array 1 .. 7 of int
    var key : string (1)

    for i : 1 .. 800
        start
        View.Set ("offscreenonly")
        sety (i, y)
        Draw.FillPolygon (x, y, 7, brightred)
        Draw.Polygon (x, y, 7, red)
        View.Update
        delay (1)
        Draw.FillPolygon (x, y, 7, colorbg)
        Draw.Polygon (x, y, 7, colorbg)

        locate (50, 1)


    end for

end leftarrow

start
leftarrow
%//////////////////////////////////////////////////////////////////////////////


thats my program so far...just really basic......theres an arrow at the top of the screen and another arrow is coming upwards from the bottom. Im gonna decide to score by the difference between the one of the y values of the arrow compared to a constant so i have that covered. I just need to figure out how to get a character and make sure its the Left Arrow Key (using ord) without stopping the program (because im gonna have a lot more arrows running at the same time and on the same screen). i need a way to detect what keys the user hits without stopping the program basically. Any suggestions?

-----------------------------------
superman500
Tue Nov 14, 2006 11:57 pm


-----------------------------------
wow nvm i just found the answer in another topic XD

Input.Keydown

now i just have to learn how to use it =\

-----------------------------------
ericfourfour
Wed Nov 15, 2006 12:18 am


-----------------------------------
Try this one instead.

var input : string
loop
    if Input.hasch () then
        input = Input.getchar ()
    end if
end loop

That one only gets a character only when there is one in the keyboard buffer. Input.hasch () returns false if no keys are pressed, however if a key is pressed it returns true. Input.getchar () returns the character representing the key being pressed. Plus it handles shift+letter (for capitals) and does not crash with ctrl+z. The only down side is it cannot handle multiple keys at once.

-----------------------------------
Andy
Wed Nov 15, 2006 1:54 am


-----------------------------------
Input.Keydown is the way you should do it, but getch would work just fine

-----------------------------------
superman500
Wed Nov 15, 2006 10:45 pm


-----------------------------------
i've been playing around with it...i realized using Input.Keydown won't work cuz they can just hold the arrow key down and they would still get the points...anyone have a way to bypass this? >