Well as we've seen from the issue that bugged this script not neccesarily, it would have produced sporadic jumps in walk speed.
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 MenuQuote from: Ashen on Wed 21/11/2007 15:20:26Because 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.
Why not just use '>' and skip the +1 you've had to include. i.e.:
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;
}
}
}
//====================================================================================================
By continuing to use this site you agree to the use of cookies. Please visit this page to see exactly how we use these.
Page created in 0.073 seconds with 13 queries.