MODULE: 8-Direction Movement v0.1

Started by Bernie, Mon 11/07/2005 17:13:54

Previous topic - Next topic

Bernie

This is my first go at a script module thing. This is an attempt to simulate a movement similar to the ones in games like Chrono Trigger or Terranigma.

Speed, character widths and other things can be altered through functions. I've also added a Thrust() function which allows for the character to be pushed around. Maybe useful when he's colliding with an enemy, or something.

I've added an explanation for each value in the module's description. Please try it out and let me know if you find this useful.

Functions:

EightDir.SetSpeed(int x, int y);
             Sets character speed. Can be changed at any time.
             You could, for example, make the character run
             faster when a button is pressed down.

             SetSize(int x, int y);
             Sets the size of the character's collision width
             and height.

             WalkViewSpeed(int speed);
             Sets Speed of the walking view.

             SetWalkView(int view);
             Sets a new walking view used by the movement.

             SetSlide(int value);
             The lower this value is, the slower the character
             will get to full speed and stop.
         
             Disable(bool value);
             Disables the movement. Set to either 1 or 0.

             NoDirSet(bool value);
             Disable the movement's internal direction setting.

             DiagSlow(bool value);
             If this is true, the character will only move
             at 70% when walking diagonal.

             Thrust(int x, int y);
             Pushes the character into a direction. Useful
             when the character is being hit or similar.

             EightLoopsMode(bool value);
             If this is true, the movement will utilize 8 loops
             instead of 4.

             IsMoving();
             Returns if the player is currently being moved.

             IsThrusting();
             Returns wheter the function Thrust() is still active.

Download here
Mirror
--

I've also made a small platform engine recently. It works well, but the code is very messy. It's not a script module, just an experiment:

http://www.origamihero.com/files/plat2.zip (Use space bar to jump)

Khris

Sorry for bumping this, but:

I've tried out this module today and after wondering for ten minutes why it wouldn't work correctly, I found the problem:
The character's normal view in AGS must not be set to the one set by EightDir.SetWalkView(); Otherwise the player doesn't animate.

I'm not exactly sure why, though. Seems like locking the char to his normal view isn't appreciated by AGS.

Bernie

Yes, that's how it is - I mentioned it in the readme file. You can assign a normal (stopped/walking) view, but the EightDir.SetWalkView needs to be different for a reason I don't remember.

SMF spam blocked by CleanTalk