character movement platformer style

Started by AnasAbdin, Fri 17/02/2012 10:23:11

Previous topic - Next topic

AnasAbdin

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 :)

Khris

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.

AnasAbdin

thanks man, I'll try something this weekend  :)

Kimbra

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  ::)

Deu2000

#4
I guess that something like "while left key is presed" "move 5 pixels to left".
Soon I will post the code.



AnasAbdin

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

DoorKnobHandle

You don't want to use the Character.Walk function for a platformer, modify the position directly!

AnasAbdin

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  :)

Deu2000

#8
Version 0.1:

Code: ags

  //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  ;)



Matti

You needed two month for those lines? Wow. They aren't even helpful.

Mouth for war

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
mass genocide is the most exhausting activity one can engage in, next to soccer

SMF spam blocked by CleanTalk