# Programming Problems

**URL:** <https://forum.kirupa.com/t/programming-problems/16092>\
**Category:** flash\
**Created:** [March 20, 2003, 9:57pm UTC](https://forum.kirupa.com/t/programming-problems/16092 "2003-03-20T21:57:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deathjr](https://avatars.discourse-cdn.com/v4/letter/d/35a633/32.png) [@Deathjr](https://forum.kirupa.com/u/Deathjr)\
**Post date:** [March 20, 2003, 9:57pm UTC](https://forum.kirupa.com/t/programming-problems/16092/1 "2003-03-20T21:57:03Z")

</div>

I haven’t found a single tutorial around here that’ll teach it, so i’ll ask instead.

I have planned for making a diablo-like game, pretty well a parody of it with my own aspects and quirks.

I’ve gotten all the animation for it done, and what I want to do is when the player clicks on the ground, the character will load the correct movement image and have the character run or walk in that direction. I’ve seen ones where you use the keyboard, but not the mouse, and I haven’t seen one that changes the image, but I know _that_ can be done. If any of you know where a tutorial like this may be found please tell me, or if you know, please post it for me.  
Thanks anyway.:cyclops:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 20, 2003, 10:09pm UTC](https://forum.kirupa.com/t/programming-problems/16092/2 "2003-03-20T22:09:17Z")

</div>

Well, it all depends on how your game works… is it tiled-based?  
in any case… all you have to do is to get the location of the mouse when clicked. You can have a movie clip that fills the whole screen. Add an on(release) handler that will send the coordinates of the mouse (in the screen) to your avatar. Your avatar should then translate the screen coordinates to the mouse to the map coordinates in relation to itself.

To move, you just do it with vectors… knowing the starting point and the end point, you can figure out the angle and the magnitude of the vector that points from your starting point to your end point, and then you can determine in which direction your avatar should move per frame.

If there are obstacles in the way, that becomes more complicated. You need to know the A\* path finding algorithm. You can find a tutorial on it here:

> **[Yahoo Small Business - Cheap Domains, Web Hosting, Website Builder, Ecommerce...](https://smallbusiness.yahoo.com/)**
>
> Yahoo Small Business Offers Cheap Domain Names, Web Hosting, Easy Website Builder, Business Email, Local Listings, and Ecommerce Solutions for Your Small Business.

hope this helped
