You are not logged in.
Pages: 1
/*
** Usage:
** turn_to_position(x_tar,y_tar,max_deg)
**
** Arguments:
** x/y_tar position to Direct to
** max_deg the max degree to rotate by step
**
**
** Returns:
** return if direction=point_direction(x,y,x_target,y_target)
**
** Notes:
** This Is The function That Used By The Most Of Games To Make
** A Roket Follw A Target Automatically With Smooth Method
** And It Used For More Other Things
** But This Is A Short Script I Make It
*/
{
var ROT; ROT=point_direction(x,y,argument0,argument1)
if abs(ROT-direction)<=argument2 {direction=ROT; return 1} else
{
var TMP; TMP=ROT-direction; if TMP<0 TMP+=360
if TMP>180 {direction-=argument2; if direction<0 direction+=360}
else {direction+=argument2; if direction>=360 direction-=360}
return 0
}
}
Last edited by FreePalestine (2013-12-04 11:17:36)
Offline
Example:
create_event:
speed=5
Step_event
turn_to_position(mouse_x,mouse_y,5)
image_angle=direction
Last edited by FreePalestine (2013-12-04 11:19:23)
Offline
another form to the script
this is a general form:
//turn_dir_to_dir(dir1,dir2,speed)
if abs(argument0-argument1)<=argument2 return argument1
var TMP; TMP=argument1-argument0; if TMP<0 TMP+=360
if TMP>180 {TMP=argument0-argument2; if TMP<0 return TMP+360}
else {TMP=argument0+argument2; if TMP>=360 return TMP-360}
return TMP
Example:
Create_Event:
speed=5
Step_Event:
direction=turn_dir_to_dir(direction,point_direction(x,y,mouse_x,mouse_y),5)
image_angle=direction
Last edited by FreePalestine (2013-12-04 11:13:56)
Offline
image_angle+=median(-5,angle_difference(point_direction(x,y,mouse_x,mouse_y),image_angle),5);
or
image_angle+=lengthdir_y(5, image_angle - point_direction(x,y,mouse_x,mouse_y));
Last edited by icuurd12b42 (2013-12-08 22:58:54)
Offline
Pages: 1