PDA

View Full Version : [Script] [Game Maker] RMXP/VX Move_Step Script


rm2kdude
November 2nd, 2010, 02:30 PM
RPG Maker Move Step
Version: 1.0
Author: Rukiri
Exclusive to: Planet RPG, Rpg Revolution, PokeCommunity
Style: RPG Maker XP/VX
Tile_move: Yes
Pixel_move: No
because x is divided by tile_size so if you set it to 1 the tile_x or y variable will be the same as x. I recommend using just 2 instead of 1 as the tile_size variables have to be a dividend of 2 basically X or y need to be divided by something that equals a whole number.


How to use
tiles_to_move_x = x Change X to the number of tiles you want to move horizontally.
tiles_to_move_y = x Change X to the number of tiles you want to move vertically.

scr_move_step(direction)

There's an example already in the step event coding.

You can also use this for actual player movement, just remove the code block for, stop_cutscene_move = false

and replace it with
if (x = tile_x * tile_size_x and y = tile_y * tile_size_y) {
if keyboard_check(vk_down) {
scr_move_step(1);
}
}

Create Event
//=========================//
// Author: Rukiri
// 10/29/10
// Completed: 10/30/10
//========================//

// dir 4 or 8

dir_4 = true; // set to false if you want diagonal movements

// can this object move?
can_move=true

//Movement speed
move_speed = 2;

// Animation Speed
ani_speed = 0.3;

// Tile Size
tile_size_x = 32;
tile_size_y = 32;

// Tile X/Y
tile_x = x/tile_size_x;
tile_y = y/tile_size_y;
tile_x_old = xprevious/tile_size_x;
tile_y_old = yprevious/tile_size_y;

// Tiles to move x/y set to 0 for creation
tiles_to_move_x = 0;
tiles_to_move_y = 0;

// destination tile x/y use the coding in step event
dest_tile_x = tile_x_old + tiles_to_move_x;
dest_tile_y = tile_y_old + tiles_to_move_y;

// stop cut_scene movement, only use if your using scr_move_step without keyboard checks. Use an alarm for delays in
// switching directions.
stop_cutscene_move = false;

// move
move_down = 1;
move_left = 2;
move_right = 3;
move_up = 4;

Step Event
// Get the tile ID number y/gridsize
if can_move = true or stop_cutscene_move = false { // checks to see if we're moving if not, x/y will not be added or subtracted from.
if (tile_x * tile_size_x > x) { // checks if tile_x is greater than x
x += move_speed; // moves your object to the right
} else if (tile_x * tile_size_x < x) { // checks if tile_x is less than x
x -= move_speed; // moves your object to the left
}

if (tile_y * tile_size_y > y) { // checks if tile_y is greater than y
y += move_speed; // moves your object down
} else if (tile_y * tile_size_y < y) { // checks if tile_y is less than y
y -= move_speed; // moves your object up
}

}

// Movement Code Block
if stop_cutscene_move = false { // set stop_cutscene to false when move_step has not been used
if (x = tile_x * tile_size_x and y = tile_y * tile_size_y) { // check to see if you're at the destination tile
tiles_to_move_y = 1; // set how many tiles the NPC should move at a time (use random for a more NPC like movement)
dest_tile_x = tile_x_old + tiles_to_move_x; // Make sure you're not walking past your destination tile
dest_tile_y = tile_y_old + tiles_to_move_y; // Make sure you're not walking past your destination tile
scr_move_step(1); // move_step script scr_move_step(direction), 1=down, 2=left, 3=right, 4=up

}
}

// make sure an NPC doesn't walk past it's destination tile
if tiles_to_move_x >= 1
{
if dest_tile_x = tile_x { stop_cutscene_move = true; }
}
if tiles_to_move_y >= 1
{
if dest_tile_y == tile_y { stop_cutscene_move = true; }
}

// stop event at the right tile.
if (tile_x * tile_size_x = x and tile_y * tile_size_y = y) { // make sure we're not moving when we release our direction keyboard keys
can_move = false; // set can_move to false when we're not moving
}
else { can_move = true } // set can_move to true when we are moving

scr_move_step
// Moves the character based on tile position in direction argument0
// This set of conditionals is strictly for Movement!
/*
move_up = 4
move_down = 1
move_left = 2
move_right = 3
*/
// example, scr_move_step(1,5) will move up 5 tiles.
if (move_up = argument0) { if (!place_meeting(tile_x *32, (tile_y - 1) * 32, obj_wall)) tile_y -= 1; }
else if (move_down = argument0) { if (!place_meeting(tile_x * 32, (tile_y + 1) * 32, obj_wall)) tile_y += 1; }
else if (move_left = argument0) { if (!place_meeting((tile_x - 1) * 32, tile_y * 32, obj_wall)) tile_x -= 1; }
else if (move_right = argument0) { if (!place_meeting((tile_x + 1) * 32, tile_y * 32, obj_wall)) tile_x += 1; }

// usage
// scr_move_step(argument0)
// argument 0 is for direction

Cilerba
December 30th, 2010, 06:08 PM
what is this for because i need it

In the title it says "[Game Maker] RMXP/VX ..."
It's obviously for Game Maker.