Movement for Point and click

N

Noname194

Guest
Hello everyone!

I'm trying to make a point and click game, like lucasart games, but I can't figure out how to move the player.
I can make the player follow the mouse when clicking, but I can't make it move like Fran Bow in a limited space.

I use mp_grid to follow the mouse click.


Thanks in advance for your help.

Sorry for my english =)
 

Niels

Member
Make a target_x and target_y variable for the player and set it to the player x and y in the create event.
Then in the step event:
When mouse_button_pressed (mb_left) {
Target_x = mouse_x and target_y = mouse_y ;
}
When target_x !=x or target_y !=y {
/// MOVE CODE HERE TO MOVE PLAYER TO TARGET_X AND Y
}
 
N

Noname194

Guest
Thaks for the fast reply!

That works perfectly to move the player. But how can I make the area that the player can walk?

For exemple, I want the player, only walk on the ground. When I click in the walls, I want the Player to go to that direction, but stop where the ground ends.

something like this (check the gifs) - https://www.groebelsloot.com/2015/12/24/pathfinding-part-1/

By the way, nice Pixel art Niels!!
 
Top