Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: AnasAbdin on Fri 17/02/2012 10:23:11

Title: character movement platformer style
Post by: AnasAbdin on Fri 17/02/2012 10:23:11
Hi all,
I am experimenting with character keyboard-movements with AGS... like cinematic platform games (another world, flash back, prince of persia...)
I need some help being directed to the right methods of achieving this.

my main concerns now:
1. I'd like to know how to make the character walk to a position using a single cycle when the arrow key is pressed only once.
2. how to keep the walk cycle repeating while the arrow key is held down.
3. how to add an initiative cycle before the character starts walking/running, like adding a lean forward animation before walking...

in general, I need tips on making the character as smooth a possible when moving...

many thanks in advance :)
Title: Re: character movement platformer style
Post by: Khris on Fri 17/02/2012 10:57:47
The basic technique is to decouple animation and movement from pressing keys.
So key events put actions in a queue which is in turn processed by the game.

If a queued cycling action completes, it is repeated as long as the key is still pressed.

So as an example:
character is standing. player presses right movement key.
-engine checks which way character faces and if required, adds turn animation to queue
-initiative cycle action is added to queue
-walk right cycle action is added to queue

when walk right cycle action has finished, current keyboard input is checked
-right arrow key still pressed: add another walk right cycle action to queue
-right arrow not pressed any longer and no other key pressed: add stop walking animation to queue
-left arrow key is pressed: add turn while walking animation and walk left animation to queue

TL;DR: the game only reacts to a key being pressed or being no longer pressed after the current animation has finished.
Title: Re: character movement platformer style
Post by: AnasAbdin on Sat 18/02/2012 07:49:28
thanks man, I'll try something this weekend  :)
Title: Re: character movement platformer style
Post by: Kimbra on Mon 20/02/2012 10:56:25
I've been trying to do something similar, failed of course.
there are great AGS platformers but they seem to be coded by professionals
good luck  ::)
Title: Re: character movement platformer style
Post by: Deu2000 on Wed 22/02/2012 12:56:03
I guess that something like "while left key is presed" "move 5 pixels to left".
Soon I will post the code.
Title: Re: character movement platformer style
Post by: AnasAbdin on Wed 22/02/2012 16:35:54
Quote from: deu2000 on Wed 22/02/2012 12:56:03
I guess that something like "while left key is presed" "move 5 pixels to left".
Soon I will post the code.

that'll be appreciated!

the thing is... AGS treats walking differently when using they keyboard according to the player's movement status. If I kept pressing a direction the player's walk is missed up due to walk/stop behavior of the key press....
but I am onto that too, I need a few hours alone with AGS hehe
Title: Re: character movement platformer style
Post by: DoorKnobHandle on Wed 22/02/2012 16:46:47
You don't want to use the Character.Walk function for a platformer, modify the position directly!
Title: Re: character movement platformer style
Post by: AnasAbdin on Wed 22/02/2012 16:58:18
Quote from: dkh on Wed 22/02/2012 16:46:47
You don't want to use the Character.Walk function for a platformer, modify the position directly!

yessir! I know that... trying to make things as simple as possible though  :)
Title: Re: character movement platformer style
Post by: Deu2000 on Wed 11/04/2012 20:43:44
Version 0.1:


 //KEYWALK FUNCTION
 if(keycode==eKeyRightArrow) {
   character.x++;
 }
 if(keycode==eKeyLeftArrow) {
   character.x--;
 }
 if(keycode==eKeyUpArrow) {
   character.y--;
 }
 if(keycode==eKeyDownArrow) {
   character.y++;
 }

(just put it in on_key_press)

NOTE: This is the first version. Working on the second  ;)
Title: Re: character movement platformer style
Post by: Matti on Wed 11/04/2012 23:49:46
You needed two month for those lines? Wow. They aren't even helpful.
Title: Re: character movement platformer style
Post by: Mouth for war on Thu 12/04/2012 09:17:24
Quote from: Matti on Wed 11/04/2012 23:49:46
You needed two month for those lines? Wow. They aren't even helpful.
HAHA couldn't help myself from laughing...sorry... ;D