Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Guineapiggy

#1
Well as we've seen from the issue that bugged this script not neccesarily, it would have produced sporadic jumps in walk speed.
#2
Quote from: Ashen on Wed 21/11/2007 15:20:26
Why not just use '>' and skip the +1 you've had to include. i.e.:
Because the +1 delays the walking somewhat, the whole thing is a delay loop to regulate the character's speed. That said I've since replaced this system with a better one.
#3
I'll upload it for y'all when it's in all there for sure, though it's designed for a side-on view so it'd take some modification for top down. The script you see there is missing a header and very basic compared to what I've modified it to.
#4
Thanks for the info, Khris. I discovered it was using the walkaccel == clause, as somehow it managed to increase beyond where it should. To resolve the issue I replaced it for a >=. Fiddly variables I guess. Still, I've managed to make a fairly decent walking system so far which includes running, sliding to force a sudden turn and soon I'm hoping to code in running in to walls, jumping and falling.
#5
Dear OP,
             I love you.

Sincerely, a huge Who nerd.
#6
Okay, so I've generated a script that allows for keyboard movement of the character with an acceleration and deceleration instead of the sudden stop and it works nicely save I've yet to link it to animation. (All in good time).

I also added a function that allows the user to sprint or proceed cautiously by holding either the shift or ctrl key at the same time as walking. Now... this works to an extent, if you hold either key the character will indeed speed up or slow down but curiously... frustratingly it also seems to randomly freeze the character in their tracks and they don't move again until I reload the game. I've tried everything I can think of but I still can't find what I might be doing wrong, part of me thinks it may be a bug with the AGS 3 beta I'm currently using.

Anyways, here's the script.

Note - I'd love to do it a more simple way than the rather hacked-togehter move X method but not being able to change character walk speeds whilst in motion is a royal pain. Why is this the case?

Quote//****************************************************************************************************
// VARIABLES
//****************************************************************************************************

// keycodes as variables for future key customization functions (static variables?):
int KeyboardMovement_KeyLeft = 375; // left arrow
int KeyboardMovement_KeyRight = 377; // right arrow
int walkloop;
int walkaccel = 1;

KeyboardMovement_Modes KeyboardMovement_Mode = eKeyboardMovement_None; // stores current keyboard control mode (disabled by default)

KeyboardMovement_Directions KeyboardMovement_CurrentDirection = eKeyboardMovement_Stop; // stores current walking direction of player character

//****************************************************************************************************
// USER FUNCTIONS
//****************************************************************************************************

//====================================================================================================

static function KeyboardMovement::SetMode(KeyboardMovement_Modes mode) {
   KeyboardMovement_Mode = mode;
}

//====================================================================================================

// key customization functions here

//====================================================================================================

//****************************************************************************************************
// EVENT HANDLER FUNCTIONS
//****************************************************************************************************

//====================================================================================================

function repeatedly_execute() {

   //--------------------------------------------------
   // Pressing mode
   //--------------------------------------------------
  int WlkSpd = 2;
  if (IsKeyPressed(403)) {
  WlkSpd = 1;
  }
  else if (IsKeyPressed(405)) {
  WlkSpd = 3;
  }

  if (walkloop > 0 && walkloop <= 20){
    walkaccel = walkaccel + 1;
    if (walkaccel == (WlkSpd + 1)) {
    player.x = player.x + 1;
    walkaccel = 0;
    }
   }
  else if (walkloop >= 20) {
    walkaccel = walkaccel + 1;
    if (walkaccel == (WlkSpd + 1)) {
    player.x = player.x + 2;
    walkaccel = 0;
    }
   }
   if (walkloop < 0 && walkloop >= -20){
    walkaccel = walkaccel + 1;
    if (walkaccel == (WlkSpd + 1)) {
    player.x = player.x - 1;
    walkaccel = 0;
    }
   }
  else if (walkloop <= -20) {
    walkaccel = walkaccel + 1;
    if (walkaccel == (WlkSpd + 1)) {
    player.x = player.x - 2;
    walkaccel = 0;
    }
   }
   if ((IsGamePaused() == true) || (KeyboardMovement_Mode != eKeyboardMovement_Pressing) || (IsInterfaceEnabled() == false) || (player.on == false)) return 0;
     // if game is paused, module or mode disabled, interface disabled or player character hidden, quit function

   KeyboardMovement_Directions newdirection; // declare variable storing new direction

   // get new direction:
   if (IsKeyPressed(KeyboardMovement_KeyLeft)) newdirection = eKeyboardMovement_Left; // left arrow
   else if (IsKeyPressed(KeyboardMovement_KeyRight)) newdirection = eKeyboardMovement_Right; // right arrow
   else {
    if (walkloop > 1) {
      walkloop = walkloop - 1;
     }
    else if (walkloop <= 1 && walkloop >= -1){
      walkloop = 0;
      }
    else if (walkloop < 1) {
      walkloop = walkloop + 1;
     }
     }
      if (newdirection == eKeyboardMovement_Left) {
         
          if (walkloop > -40) { //Basic build-up of walk speed
            walkloop = walkloop - 1;
            }
          if (walkloop > 0) { //Makes turning or suddenly stopping a little sharper
            walkloop = walkloop - 1;
            }
        }
          else if (newdirection == eKeyboardMovement_Right) {
         if (walkloop < 40) { //Basic build-up of walk speed
           walkloop = walkloop +1;
          }
         if (walkloop < 0) { //Makes turning or suddenly stopping a little sharper
           walkloop = walkloop + 1;
          }
         }         
   }

//====================================================================================================
SMF spam blocked by CleanTalk