|
This script is to replicate RPG Makers set-move-route, it does it perfectly, the only problem is.. it won't do diagonals, yes you would need to remove the "exit" command but than you got timing issues. Hopefully someone can help ================================================================================================ Here's my diagonal moving code, and my RPG Maker like Move_step script. // 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); } }
RM like move_step. Create event, should be in every object you make. move_speed = 4; tile_size_x = 32; tile_size_y = 32; tile_x = x / tile_size_x; tile_y = y / tile_size_y;
Step event, just place in before or after step. if (tile_x * tile_size_x > x) { x += move_speed; exit; } else if (tile_x * tile_size_x < x) { x -= move_speed; exit; } else if (tile_y * tile_size_y > y) { y += move_speed; exit; } else if (tile_y * tile_size_y < y) { y -= move_speed; exit; }
Actual scrip: // Moves the character based on tile position in direction argument0 { // This set of conditionals is strictly for Movement! /* move_up = 1 move_down = 2 move_left = 3 move_right = 4 */ // example, scr_move_step(1,5) will move up 5 tiles. if (move_up = argument0) { if (!place_meeting(tile_x *tile_size_x, (tile_y - 1) * tile_size_y, obj_wall)) tile_y -= argument1; } else if (move_down = argument0) { if (!place_meeting(tile_x * 32, (tile_y + 1) * tile_size_y, obj_wall)) tile_y += argument1; } else if (move_left = argument0) { if (!place_meeting((tile_x - 1) * tile_size_x, tile_y * tile_size_y, obj_wall)) tile_x -= argument1; } else if (move_right = argument0) { if (!place_meeting((tile_x + 1) * tile_size_x, tile_y * 32, obj_wall)) tile_x += argument1; } }
Basically once you can move in all 8 directions with this script, it's pretty easy to just use it for movement(and save a ton of time) the script works like this. scr_move_step(1,1); First argument is direction, the second argument is how many tiles are you going to move. For actual players you're only going to use 1 as you're going to be using keyboard checks, but for cut scenes you won't have to. But you're going to have time issues with out exit. hopefully someone can help as this could be a really useful script. Thanks! Here's a demo if it helps. http://rapidshare.com/files/427798936/RPG_Maker_VX_Engine.gmkReally need this for my engine, literally.. almost have everything done(you're only going to find movement here) don't both with obj_player and just worry about the contents of object6. This script if someone can actually get 8-dir working on this without either moving exit or making it so tile_x or tile_y doesn't add rapidly when holding down the key, it should only add when it's on a new tile. Or stop on the current or next tile. For 4-way this is done as is, I just can't get 8-dir working. And I don't want to go back to really long(100+) for just getting directions, movement etc. This makes everything simpler and I don't have to code just use the script.
« Last Edit: October 29, 2010, 03:23:31 pm by Shiku »
Logged
|