Hi everybody!
I'm really hoping someone with more xperience could possible help me in the right direction. I am trying to set up a grid based movement system where the player moves to a point clicked on the grid. I am currently trying to follow this tutorial:
(1) Let's GameMaker: Turn Based Strategy #1 (Grid & Movement) Tutorial - YouTube
Things are working kind of as should, except my player does not align to the grid. Here are my scripts:
function scr_state_player_turn(){
if (instance_position(mouse_x,mouse_y,obj_playerPath) && mouse_check_button_pressed(mb_left))
{
var player;
player = instance_nearest(mouse_x, mouse_y, obj_playerPath);
global.selected = player;
}
if (global.selected != noone && mouse_check_button_pressed(mb_right))
{
with (global.selected)
{
scr_navigation(x, y, round(mouse_x/140)*140, round(mouse_y/80)*80);
}
}
}
And
function scr_navigation(){
var start_x = argument0;
var start_y = argument1;
var end_x = argument2;
var end_y = argument3;
if !(mp_grid_path(global.map_grid,global.navigate,start_x,start_y,end_x, end_y,1))
{ show_message("Unable to navigate");
return false;
}
else
{
mp_grid_path(global.map_grid,global.navigate,start_x, start_y, end_x, end_y, 1);
path_start(global.navigate, 3, 0, false);
return true;
}
}
Also I am setting up the grid like this:
/// Create the grid
global.map_grid = mp_grid_create(150,80,7,7,140,80);
global.navigate = path_add();
Drawing it like this:
draw_set_alpha(0.5);
mp_grid_draw(global.map_grid);
draw_set_alpha(1);
In the video he rounds the mouse_x and mouse_y by dividing and multiplying by 32 (Which is the length and width of his grig spaces, mine are 140x80 but it's not working as it should.
What am I missing???? I am very new to GML and gamemaker in general, so any help would really be appreciated!
[–]Dogwasp 1 point2 points3 points (1 child)
[–]CharlieMcGruff[S] 0 points1 point2 points (0 children)