// drawing the NPC
// it's basically just a transformed background
d3d_set_culling(false);
var ca=camera_angle(id);
d3d_transform_set_rotation_x(90);
d3d_transform_add_translation(-16, 0, 0);
// this is honestly very bad coding practice but it works
d3d_transform_add_rotation_z(direction+90+90*(ca==CameraAngles.side));
d3d_transform_add_translation(x, y, z+40);
// this is like using sprite_index, except for a background
draw_background_part(all_npc_images[image], (32*floor(frame)+32)%96, 48*ca, 32, 48, 0, 0);
d3d_transform_set_identity();
d3d_set_culling(true);
// animation speed depends on how fast the NPC is moving
frame=frame+point_distance(0, 0, xspeed, yspeed)/12;
/// CameraAngle camera_angle(object);
// Returns a value representing the side of the object visible to the camera.
enum CameraAngles {
front, //=0
side, //=1
back, //=2
}
var angle=(((Camera.direction mod 360)-argument0.direction)+360) mod 360;
if (angle<=45||angle>315)
return CameraAngles.back;
if (angle<=135)
return CameraAngles.side;
if (angle<=225)
return CameraAngles.front;
return CameraAngles.side;
Comments
0 B
|👍
/👎
0 B
|👍
/👎