Results 1 to 10 of 121

Thread: G.T.A.2 Map Editor

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #33
    How to properly handle key presses in game?
    After a long break i decided to take another look at adding ped(s) to map editor or any demo i work here.
    But problem is that if i detect the key pressed (either VK_LEFT or RIGHT) or whatever the ped starts moving always with some delay.

    I mean:

    1) I press the up key (forward movement)
    2) It waits for few secs and then starts moving
    3) I release the key and press again..
    4) Again it waits for 1sec or 2 and then starts moving.

    Same with rotating, first the small delay then the rotation.

    Why is that? its in nxpascal code and in my non nxpascal code.
    I have to look how i did it in nxpascal version, ie where i was reading the input..

    EDIT1:
    Ok, i found the src and i handle input in formshortcut event.
    For some reasons in old versions of my editor the gameunit keypressing code didnt work.
    Or stopped working after doing something in graphicsunit or main.pas
    I dont remember.

    How to properly handle input?

    I got the movement to work for ped, i mean with sin/cos and it walks in direction he is looking but the delay at the start of the moving/rotating is really bad.

    In the meantime i will try with fresh src from nxpascal and gameunit keyhandling.

    EDIT2: also it must always move, even if i press rotation key when he is moving. But he stops.

    In my non nxpascal demo i use form.keydown and timer with interval of 16ms.
    Thanks.

    EDIT3:
    As expected, in fresh source and gameunit keyprocessing everything is smooth and nice.
    No delays.
    So i guess keydown/keyup are not for games.


    Actually its mega smooth. Looks so great, i can rotate ped with arrows and walk around, it doesnt stop when rotating and walking at the same time.
    Just like in original game.

    What do you guys think, coldet will be able to get the collisions for me?
    The vertices are so simple and each block face is made of 2 triangles in my vertex data.
    Each slope has own vertices but because many slopes have lids, then lids are same and use same vertices, i dont share them ( i know i could to reduce my vertex data unit size even more, atm its 322KB).

    Coldet had recently a update with useful example.

    Probably not all the blocks on whole map must be checked but only those that are near to the ped. But since my visible are of map is just 15x15 (x,y) blocks + Z maximum 8 blocks i probably could check all these blocks in visible range.
    I dont care about speed atm, i just want quick and dirty to test, if it works, then i will try to make it better.

    It will never probably be full game, i just want to walk around and have collisions.
    Last edited by hwnd; 20-08-2013 at 08:19 PM.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •