Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: NsMn on Tue 12/05/2009 17:47:16

Title: Keyboard Movement... With key pressed
Post by: NsMn on Tue 12/05/2009 17:47:16
Hi,

I'm currently looking for a script for keyboard movement.
I kno, theres a module, but It should only walk if the key is being pressed (like Jump'n'runs, e.g. Trilby:Art of Theft)
Do you know how to do this?

Title: Re: Keyboard Movement... With key pressed
Post by: on Tue 12/05/2009 18:23:49
The code for that is already in the default AGS game- you just need to alter one line in your game's GLOBAL SCRIPT.

OPen up the global script, find game_start, and there, change:


KeyboardMovement.SetMode(eKeyboardMovement_Tapping);

to

KeyboardMovement.SetMode(eKeyboardMovement_Pressing);

Title: Re: Keyboard Movement... With key pressed
Post by: .M.M. on Tue 12/05/2009 18:24:48
You can use two modes in Keyboard Movement module: eKeyboardMovement_Tapping, and eKeyboardMovement_Pressing. Put this line into your game_start function: KeyboardMovement.SetMode(eKeyboardMovement_Pressing);
[EDIT] Sorry, I didn´t see your post, Ghost.
Title: Re: Keyboard Movement... With key pressed
Post by: Matti on Tue 12/05/2009 18:25:56
From the module's readme:

Three modes are currently available:

 * eKeyboardMovement_None: Keyboard movement disabled (the default)

 * eKeyboardMovement_Pressing: Player walks while the direction key is pressed.
   Releasing the key stops the character.

 * eKeyboardMovement_Tapping: Player starts walking when direction is pressed
   once and walks until key is pressed again. Numpad-5 also stops him.

So what you're looking for is eKeyboardMovement_Pressing, if I understand you correctly.


Ah, Mirek beat me. Oh, and Ghost too.
Title: Re: Keyboard Movement... With key pressed
Post by: Khris on Tue 12/05/2009 18:27:14
It's high time:

RTFM.
Title: Re: Keyboard Movement... With key pressed
Post by: on Tue 12/05/2009 19:50:42
Quote from: KhrisMUC on Tue 12/05/2009 18:27:14
It's high time:
RTFM.

Actually, no, since the keyboard movement script isn't covered in the manual- you can figure out how to change the settings of the module after reading the module documentation.
Maybe a short notice in the main script could be added?

Generally spoken you're totally right though, I think we had the same question a couple o'dozens of times.  ;)
We need a cool acronym for Do A Friggin' Forum Search.

Title: Re: Keyboard Movement... With key pressed
Post by: Trent R on Tue 12/05/2009 21:10:44
Technically, the module's manual is right in the header, so his acronym still works.

But I do like DAFFS, or maybe STFF to keep in the same rhythm?
[Edit]: Or maybe FITF (Find [it] In The Forum)?


~Trent
Title: Re: Keyboard Movement... With key pressed
Post by: Khris on Tue 12/05/2009 21:56:29
How about "Search The Forums, You!"
Acronym: STFU ;)
Title: Re: Keyboard Movement... With key pressed
Post by: NsMn on Wed 13/05/2009 17:45:33
Sorry, but I found something... a-v-o's script helped, but although, thank you very much.