Simon Donkers
Game Maker
Home > GameMaker > Scripts > Isometric grid based movement script

Isometric grid based movement script

An isometric grid based movement example. Handles collsions and everything

 
 Isometric grid based movement script
//////////////// Isometric grid based movement script ////////////////////
//
// Copyright Simon Donkers 27-1-2005
// www.simondonkers.com - gmmentor@simondonkers.com
//
// the arguments are:
// argument0 is horizontal grid
// argument1 is vertcal grid
// argument2 is speed (Use a speed for which both argument0 devided
// by this as argument1 devided by this will give an integer number!!!
//
// This script will generate a correct grid based movement for an isometric game
// make sure to use the built in grid with arguments0 and 1 and also make sure
// that the character is alligned at the begin
//
/////////////////////////////////////////////////////
if (argument0/argument2)mod(1)>0 then show_debug_message('Illigal speed used!');
if (argument1/argument2)mod(1)>0 then show_debug_message('Illigal speed used!');
if ((x)mod(argument0)=argument0/2 and (y)mod(argument1)=argument1/2) or((x)mod(argument0)=0 and (y)mod(argument1)=0) then
{
        speed:=0;
        image_speed:=0.2;
        image_single:=0;
        if keyboard_check(vk_leftand place_free(x-argument0/2,y-argument1/2) then
        {
                hspeed:=-2*argument2;
                vspeed:=-1*argument2;
                sprite_index:=spr_nw;
                image_single:=-1;
        }
        if keyboard_check(vk_rightand place_free(x+argument0/2,y+argument1/2) then
        {
                hspeed:=+2*argument2;
                vspeed:=+1*argument2;
                sprite_index:=spr_se;
                image_single:=-1;
        }
        if keyboard_check(vk_upand place_free(x+argument0/2,y-argument1/2) then
        {
                hspeed:=+2*argument2;
                vspeed:=-1*argument2;
                sprite_index:=spr_ne;
                image_single:=-1;
        }
        if keyboard_check(vk_downand place_free(x-argument0/2,y+argument1/2) then
        {
                hspeed:=-2*argument2;
                vspeed:=+1*argument2;
                sprite_index:=spr_sw;
                image_single:=-1;
        }
}
Loading...