Use keydowns to move objects

hey,
let's say i wanted to sidestep something, strafe and fire
can you use key down events to move a character, example if i press the x button can i have the character suddenly move 32 pixels to the right, this would be definitely different from a simply pressing the right arrow.

------------------
(url="http://"http://www.geocities.com/ellrx/index.html")The trinity complete: COldstone, TNT Basic, Klick&Play;(/url)

Quote

Originally posted by ellrx:
can you use key down events to move a character, example if i press the x button can i have the character suddenly move 32 pixels to the right, this would be definitely different from a simply pressing the right arrow.

Mr. Ellrx,

Yes, but not with pixels as you may want, as the player uses movement tiles and not the pixels grid. However a solution to this is to set your movement grid up to however many pixels you want the player to be able to move, and then move him the corresponding amount of movement tiles.

Anyways, how to do it:

Since the map position event object can accept tag values, this is fairly easy.

  • Create 2 globals, &&newX; and &&newY;
  • Create your keydown event: move_character_west.cet
  • In move_character_west.cet have the following objects:

Change globals object, which sets &&newX; to &&PlayerX;
Change globals object, which subtracts however many numbers of movement tiles to &&newX; as you care to move him.
map position object, which sets the players coordinates to (&&newX;, &&PlayerY;)

If you moved west/east, then &&newX; would be incremented by a negative/positive number respectively. If you moved north/south then you would use &&newY; and &&PlayerY.;

Then, of course, link the events to whatever keys you wish to utilize.

------------------
"But soon, soon, soon... the world will be a better place, with meadows and bunnies and fiber optics in every home..."
- Tom Dowdy, Apple Computer
------------------
(url="http://"http://www.avalon.net/~honda/pog/pogwalkthrough2a.htm")PoG Walkthrough and Compendium(/url) | (url="http://"http://www.ambrosiasw.com/cgi-bin/vftp/dl-redirect.pl/PoG_Dev_Tools_Source.sit?path=coldstone/resources&file;=PoG_Dev_Tools_Source.sit")PoG Dev Tools(/url)