1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Movement for Point and click

Discussion in 'Programming' started by Noname194, Apr 24, 2018.

  1. Noname194

    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 =)
     
  2. Niels

    Niels Member

    Joined:
    Jun 22, 2016
    Posts:
    828
    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
    }
     
  3. Noname194

    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!!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice