Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Team Sapphire: RPG Grid Movement Final Version Now available!
Rukiri
post May 26 2010, 10:55 AM
Post #1


emerge -avt awesome! Wait... it brings me.... HERE?!
Group Icon

Group: Revolutionary
Posts: 1,723
Type: Scripter
RM Skill: Advanced




For those that are creating RPGs in game maker this script will help you out, it's easy to setup collisions and it makes mapping and creating games much faster.

The default tile size is 32X32, change it to any size if it's "too" large for you.

There's ALLOT of keyboard checks but they're necessary to stop irregular movement, you can add diagonal movement if you'd like which isn't hard but make sure you know the direction as "motion" set is used.

without further ado here's the script.

Create Event:
CODE
// RPG Maker VX Movement setup

dir_8 = true;  // Allow diagonal movement, if this is not a feature you want set it to false

tile_x = 32;
tile_y = 32;
dir = "d";
movesteps = room_speed * 0.5;
moving = 0;
image_speed = 0.3;
place_snapped(tile_x,tile_y);


Step Event:
CODE
/*
     RPG Movement by Rukiri
*/

if place_snapped(tile_x,tile_y)
{
 
  if dir_8=false
  {
    // get the direction
    if keyboard_check(vk_down) { dir="d"; }
    else if keyboard_check(vk_left) { dir="l"; }
    else if keyboard_check(vk_right) { dir="r"; }
    else if keyboard_check(vk_up) { dir="u"; }
  }
  else
  {
    // 8 direction
    if !moving
    {
    if keyboard_check(vk_down) { dir="d"; }
    else if keyboard_check(vk_left) { dir="l"; }
    else if keyboard_check(vk_right) { dir="r"; }
    else if keyboard_check(vk_up) { dir="u"; }
    }
  if (keyboard_check(vk_up) && !keyboard_check(vk_left) && !keyboard_check(vk_right)) { dir = "u"; }
  else if (keyboard_check(vk_right) && !keyboard_check(vk_down) && !keyboard_check(vk_up)) { dir = "r"; }
  else if (keyboard_check(vk_down) && !keyboard_check(vk_left) && !keyboard_check(vk_right)) { dir = "d"; }
  else if (keyboard_check(vk_left) && !keyboard_check(vk_down) && !keyboard_check(vk_up)) { dir = "l"; }
  if (keyboard_check(vk_up) && keyboard_check(vk_left) && dir!="u" && dir!="l") { dir = "l"; }
  else if (keyboard_check(vk_up) && keyboard_check(vk_right) && dir!="u" && dir!="r") { dir = "r"; }
  else if (keyboard_check(vk_down) && keyboard_check(vk_left) && dir!="d" && dir!="l") { dir = "l"; }
  else if (keyboard_check(vk_down) && keyboard_check(vk_right) && dir!="d" && dir!="r") { dir = "r"; }
  }
  // move/stop the character
  if keyboard_check(vk_down) { moving=1; motion_set(270, tile_y / movesteps); }
  if keyboard_check(vk_left) { moving=1;  motion_set(180, tile_x / movesteps); }
  if keyboard_check(vk_right) { moving=1;  motion_set(0, tile_x / movesteps); }
  if keyboard_check(vk_up) { moving=1;  motion_set(90, tile_y / movesteps); }
  if keyboard_check(vk_nokey) { moving=0; motion_set(0,0); }  
  // move diagonally
  if dir_8=true
  {
    if keyboard_check(vk_down) && keyboard_check(vk_left)
    {
      motion_set(point_direction(0, 0, -tile_x, tile_y), point_distance(0, 0, tile_x, tile_y) / movesteps);
    }
    if keyboard_check(vk_down) && keyboard_check(vk_right)
    {
      motion_set(point_direction(0, 0, tile_x, tile_y), point_distance(0, 0, tile_x, tile_y) / movesteps);
    }
    if keyboard_check(vk_up) && keyboard_check(vk_left)
    {
      motion_set(point_direction(0, 0, -tile_x, -tile_y), point_distance(0, 0, tile_x, tile_y) / movesteps);
    }
    if keyboard_check(vk_up) && keyboard_check(vk_right)
    {
      motion_set(point_direction(0, 0, tile_x, -tile_y), point_distance(0, 0, tile_x, tile_y) / movesteps);
    }
    if keyboard_check(vk_down) && keyboard_check(vk_up) { moving=0; motion_set(0,0); }
    if keyboard_check(vk_left) && keyboard_check(vk_right) { moving=0; motion_set(0,0); }
}    
  if dir_8=false
  {
    // stop ilregular movement ( if diagonal movement is needed this is the area to add it )
    if keyboard_check(vk_down) && keyboard_check(vk_up) { moving=0; motion_set(0,0); }
    if keyboard_check(vk_left) && keyboard_check(vk_right) { moving=0; motion_set(0,0); }
    if keyboard_check(vk_left) && keyboard_check(vk_down) { moving=0; motion_set(0,0); }
    if keyboard_check(vk_left) && keyboard_check(vk_up) { moving=0; motion_set(0,0); }
    if keyboard_check(vk_right) && keyboard_check(vk_down) { moving=0; motion_set(0,0); }
    if keyboard_check(vk_right) && keyboard_check(vk_up) { moving=0; motion_set(0,0); }
 
  }
  // check for collisions
  // control the sprites. Since VX uses 2 walk frames (walk,stand,walk) it's easier to just switch back and forth
  if moving = 1
  {
    if dir="d"
    {
      sprite_index = spr_player_d;
    }
    else if dir = "l"
    {
      sprite_index = spr_player_l;
    }
    else if dir = "r"
    {
      sprite_index = spr_player_r;
    }
    else if dir = "u"
    {
      sprite_index = spr_player_u;
    }
  }
  else { image_index = 1; }
}



If you do not want diagonal movement in your game than change dir_8 to false.

tile_x and tile_y are the variables you want to edit if you want a higher or smaller grid.

movesteps is what you want to edit when you're changing the speed of your character, only change it if you're sprite is running.

Well have fun!

DOWNLOAD DEMO! 3.44MB (There's tilesets inserted for a future RMVX Demo)
RPG Maker VX Engine, Movement demo


__________________________
Xeilsoft
- Follow your dreams to the very end..

Kits that I'm working on.
[Unity3D 4.0] LTTP/Minish Cap - I don't have time for custom gfx like what the pze folks are doing but I will try and work on some enhanced LTTP graphics.

Main PC
Core i7 3820 overclocked @ 4.8GHZ
Galaxy: Nvidia Geforce GTX 680 GDDR5 2GB
Asrock X79 Extreme9 w' creative sound
64GB corsair platinum @ 1600MHZ
Muchkin 128GB SSD(boot), OZKIN 2TB SSD, Western Digital GREEN 1TB HDD.
Rosewill Lightning 1000W PSU
OS: Funtoo Linux, Windows 8 (Virtual Machine)

iMac (March 2013)
3.4GHz Quad-core Intel Core i7, Turbo Boost up to 3.9GHz
16GB 1600MHz DDR3 SDRAM - 2X8GB
1TB Serial ATA Drive @ 7200 rpm
NVIDIA GeForce GTX 680MX 2GB GDDR5
Go to the top of the page
 
+Quote Post
   
Rukiri
post May 31 2010, 02:26 PM
Post #2


emerge -avt awesome! Wait... it brings me.... HERE?!
Group Icon

Group: Revolutionary
Posts: 1,723
Type: Scripter
RM Skill: Advanced




Full Version is now available, a demo is also available.

RPG Maker VX Engine will be completed soon!


__________________________
Xeilsoft
- Follow your dreams to the very end..

Kits that I'm working on.
[Unity3D 4.0] LTTP/Minish Cap - I don't have time for custom gfx like what the pze folks are doing but I will try and work on some enhanced LTTP graphics.

Main PC
Core i7 3820 overclocked @ 4.8GHZ
Galaxy: Nvidia Geforce GTX 680 GDDR5 2GB
Asrock X79 Extreme9 w' creative sound
64GB corsair platinum @ 1600MHZ
Muchkin 128GB SSD(boot), OZKIN 2TB SSD, Western Digital GREEN 1TB HDD.
Rosewill Lightning 1000W PSU
OS: Funtoo Linux, Windows 8 (Virtual Machine)

iMac (March 2013)
3.4GHz Quad-core Intel Core i7, Turbo Boost up to 3.9GHz
16GB 1600MHz DDR3 SDRAM - 2X8GB
1TB Serial ATA Drive @ 7200 rpm
NVIDIA GeForce GTX 680MX 2GB GDDR5
Go to the top of the page
 
+Quote Post
   
Azuaya
post Jun 14 2010, 06:12 PM
Post #3


Random Wanderer
Group Icon

Group: Revolutionary
Posts: 157
Type: Scripter
RM Skill: Beginner




Well done Rukiri, good keyboard checks, GM is a bit harsh on the keyboard checks every single time you press something then release then press something again.


__________________________
I wander around the RPG Maker VX forums to help others in need... if I'm bothered.

Go to the top of the page
 
+Quote Post
   
darkyoshi
post Jun 14 2010, 07:05 PM
Post #4


o_O
Group Icon

Group: Revolutionary
Posts: 1,244
Type: None
RM Skill: Undisclosed




QUOTE (Azuaya @ Jun 14 2010, 09:12 PM) *
Well done Rukiri, good keyboard checks, GM is a bit harsh on the keyboard checks every single time you press something then release then press something again.

What do you mean by harsh? I've never had any issues with it, so I'm curious to what you mean.


__________________________
Click to go to the Distorted Travesty thread.

Other Stuff

Voted "Best New Member of 2007"


Funny things people say

Pandemikk: "Please don't let your your homosexuality give you biased judgments on a person's artwork." -Source
Phantsmal: "In those times, China and Japan where very much alike. i'd say china because that's where most people knew martial arts,But i dunno." -Source

Normal IRC shenanegans

Some posts here make me feel kinda like this.
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 24th May 2013 - 09:03 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker