MODULE: KeyboardMovement v1.02

Started by strazer, Wed 21/09/2005 01:10:48

Previous topic - Next topic

strazer

This simple script module makes it easy to allow moving the player character using the keyboard. It is based on a-v-o's code from this thread.

Features
* Move the player character with keyboard keys
* Choice of two control modes: Pressing or tapping direction keys

Download here (Script module and documentation)

Ideas for future releases include key customization features and interaction functions.

Edit:

Check out the coding competition entries for modules that include interaction functions: http://americangirlscouts.org/agswiki/index.php/Coding_Contest#Keyboard_Control

Pumaman

Good idea, having this available as a module should make things a lot easier for newbies than having to copy & paste code into their scripts :)

scourge

its not that bad, just not ideal. When the character moves he sort of lags from update to update when you continuously hold down the button. Its because of that function walkstraight(). I think Kinoko's game GOA is a good example. I think she uses your module. It doesn't move cleanly if you know what i mean.

It's not unresponsive, just a small delay between each character position update.

I downloaded the module and found the exact same lag in your module. So i went for a different approach. But i think the amount of workarounds (for the perfect smooth movement) will be huge in collision detection etc. Everything that function (walkstraight) includes.

If i can successfully achieve all those workarounds then i'll post it here, but for beginners i think you module is ideal.


Bernie

#3
I think the problem you describe is caused by the anti-glide mode. You could try to deactivate it and see what result you get.

Or, if for whatever reason you need a keyboard movement that works without WalkStraight(), you could try my 8-dir module:

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=21766.0

It acts directly on the x and y coordinates of the character and supports slow speeds as well.

scourge

thanks bernie, turning anti-glide off fixes it. Might as well use my own movement thing now.

Your keyboard module is perfect rui and strazer, sorry.  :P

strazer

Version 1.02 now up:

- Bugfix by Rui "Trovatore" Pires: If you changed rooms, sometimes you had to double-tap on the next room in order to get the player moving again

Elessar

Great module! Would it be possible to make it so that if you pressed two buttons (such as down & right), that the character would move on a diagonal? I know that this can be accomplished using the 1,3,7,9 buttons on the keypad, but most people that I know prefer the standard arrow keys.

P.S. The txt file still says KeyboardMovement_101.scm instead of KeyboardMovement_102.scm in section 4. Setup.

Rui 'Trovatore' Pires

This already happens if you set it to "Pressing". If you set it to tapping it's kind of a blind-man's-game which gets recorded - direction 1, direction 2, or the diagonal in-between. So I think we'll leave it as is. ;)
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

SMF spam blocked by CleanTalk