I can make an enemy chase the player and move around but in terms of changing the enemies angle in the direction of a players location at a given time I'm clueless. So how do you get a player to turn its angle to the center of a player's location?

Thank You,

Jordan

Thank You,

Jordan

Hi,

you must calculate the angle.

tan^−1 delta_y/delta_x=θ

Where θ is yor angle, delta_y and delta_x are coordinate difference between your character (player and enemie).

Calculated the angle you can draw image rotated, using**draw_rot** method instead of **draw**.

Maybe this mine little Ruby test can helps you , how to use**draw_rot**

you must calculate the angle.

tan^−1 delta_y/delta_x=θ

Where θ is yor angle, delta_y and delta_x are coordinate difference between your character (player and enemie).

Calculated the angle you can draw image rotated, using

Maybe this mine little Ruby test can helps you , how to use

You can find the angle from point 1 to point 2 using

`Gosu::angle(x1, y1, x2, y2)`

, which internally does the tan^-1 that nifriz mentioned.
Thank you!

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill