INFO
This little script was made for creating RPGs and making them much much easier to code, this way you do not have to time HOW long
a sprite should move with a grid.
If you're using pixel-movement change the timer in the object to 2, though 4X4 or 8X8 is good.
Chrono Trigger and the Mana games used these grids.
Usage
RPG:Move_Sprite(object,direction,# of tiles to move)
Facts:
The timer for the movement object is timed for a 8X8 grid(snes) so if you need to time for say 32X32 it should be no different in time.
But, each grid has a different time which it needs to be set at.
Please be advised that you'll need to code the actual move sprite object, I gave an example for moving south(down), it's the same process for each direction. Just use the switch function and carry out the motion sets accordingly.
- Rukiri
// obj_move_sprite
This little script was made for creating RPGs and making them much much easier to code, this way you do not have to time HOW long
a sprite should move with a grid.
If you're using pixel-movement change the timer in the object to 2, though 4X4 or 8X8 is good.
Chrono Trigger and the Mana games used these grids.
Usage
RPG:Move_Sprite(object,direction,# of tiles to move)
Facts:
The timer for the movement object is timed for a 8X8 grid(snes) so if you need to time for say 32X32 it should be no different in time.
But, each grid has a different time which it needs to be set at.
Please be advised that you'll need to code the actual move sprite object, I gave an example for moving south(down), it's the same process for each direction. Just use the switch function and carry out the motion sets accordingly.
- Rukiri
- //==============================================================================
- // ** RPG: Move Sprite
- //------------------------------------------------------------------------------
- // Usage:
- // Argument0 is for what object you plan on moving
- // Argument1 is for the direction
- // Argument2 is for how many steps the sprite will move.
- //------------------------------------------------------------------------------
- // Written by Rukiri of Team Sapphire
- //==============================================================================
- if(instance_number(obj_move_sprite) == 0) {
- // choose the sprite you plan to move
- with (argument0) {
- // get direction
- direction = argument1; // use to change the sprites facing.
- // Sprite_Steps is used for counting, so a tile is 8X8 for example and you set it to 3, so you're mvoing 3X8 in the direction you choose.
- globalvar sprite_steps;
- sprite_steps = argument2;
- // call object_move sprite to handle the movement.
- instance_create(x,y,obj_move_sprite);
- }
- }
Expand to see the code.
// obj_move_sprite
- if tiles_moved > sprite_steps
- {
- moving=1;
- player_move_timer +=1;
- if player_move_timer >= 9
- {
- sprite_steps +=1;
- player_move_timer = 0;
- }
- motion_set(270, movesteps);
- }
- if tiles_moved == sprite_steps
- {
- sprite_steps = 0;
- instance_destroy();
- }
Expand to see the code.