ID:1513306
 
(See the best response by Koshigia.)
Hi! How are you? Well, a mob can only move in 8 different directions by default (North, Souht, East, West, Northeast, Northweast, Southeast, Southwest) and I want to change that. I know that many libraries talk about this but I want to solve this problem by myself...

I'm aware that the solution to this problem might be very simple but I sadly can't see it...
mob/verb/TEST()

var/icon/i = src.icon // a variable that contains the player's icon
src.icon = turn(i,20) // This will turn the player's icon 20 degrees





client
North

//NOW I WANT to make the mob move in the direction that it is facing to (even after we hit the TEST verb
// BUT I don't HOW



Thanks,
,MistY,
Wouldn't you change the icon under the direction they are moving? And I think you are looking for pixel movement as far as the more than 8 directions thing goes.
Best response
You'll need to use a little bit of trigonometry here. The short of it is that you must remember that a vector is a combination of magnitude and direction (speed and direction).
If you use google, you can easily pull up some information on any part of this subject (pictures may help too).

In fact, instead of writing a whole lot of information that is already out there. Please refer to this link.

http://tinyurl.com/360movement

This should help you understand what is being done. If you have any further questions, feel free to ask.
Do you know trigonometry? If not, you can either learn it or use a library.

Also, you're better off using transform to rotate your icon, rather than turn(icon, angle).
Hi ;) Yeah, i'm familiarized with trigonometry, the problem was that i wasn't sure about how would i use it in the correct way in my codes so I could get the expected result. But thanks to all of you now I have an idea about what to do.

Koshigia, Thanks for everything, you helped me a lot. ( that link is excelent)

Kaiochao, Thanks for everything, your advices are great (i'll use transform instead of turn).

Thanks,
,MistY,
In response to Misticone
Not a problem, good sir. :)