Go Back   The PokéCommunity Forums > Create & Discover > Game Development > Scripts & Tutorials
Reload this Page Script [Game Maker] RMXP/VX Move_Step Script

Notices
For all updates, view the main page.

Scripts & Tutorials This forum is for scripts and code, as well as all kinds of tutorials, software, tools and so forth. Remember to give credit!
The thread revival limit does not apply here.



Reply
 
Thread Tools
  #1    
Old November 2nd, 2010 (2:30 PM).
rm2kdude's Avatar
rm2kdude rm2kdude is offline
Advanced Pixel-Artist
 
Join Date: Jun 2004
Location: usa
Age: 27
Gender: Male
Nature: Jolly
Posts: 356

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

Code:
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

Spoiler:
Code:
//=========================//
//   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

Spoiler:
Code:
// 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

Spoiler:
Code:
// 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

__________________
Mother of god... it's almost been 12 years since I joined this community!!
Damn, time sure does fly ^O^
Reply With Quote

Relevant Advertising!

  #2    
Old December 30th, 2010 (6:08 PM).
Cilerba Cilerba is offline
the hearts of lonely people
Silver Tier
 
Join Date: Feb 2010
Location: Massachusetts
Age: 19
Gender: Male
Nature: Quiet
Posts: 1,172

Quote originally posted by superanthony182:
what is this for because i need it

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

__________________
Reply With Quote
Reply
Quick Reply

Sponsored Links
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 1:34 PM.