J
jar_are_red
Guest
I have a horror game that is 3d but uses flat 2d sprites. I am trying to add a "3d" animation to the sprite by having the monster's sprite's legs move back and forth with a timer.
Monster's Create:
Monster's Step:
angle=point_direction(x, y, obj_player.x, obj_player.y)
image_index=angle*8/360;
stepTimer--;
if(stepTimer <= 0)
{
xBack = obj_collector.x;
yBack = obj_collector.y;
stepTimer = 180;
}
jointX = obj_collector.x;
jointY = obj_collector.y;
Monster's Draw:
///Draw Body
d3d_transform_set_identity();
d3d_transform_add_rotation_x(90);
d3d_transform_add_rotation_z(point_direction(x, y, obj_player.x, obj_player.y)+90);
d3d_transform_add_translation(x, y, 68)
draw_sprite_ext(spr_collector, image_index, 0, 0, 1, 1, 0, c_white, 1);
d3d_transform_set_identity();
//Draw Leg
var leg = sprite_get_texture(spr_collectorRightLeg,0);
d3d_draw_wall(jointX,jointY,30,xBack,yBack,0,leg,1,1);
This code works for leaving the foot behind, then when the timer hits 0, bring the foot back into a normal place (it isnt polished obviously). However, when the foot gets left behind, the sprite does not face the player like it does when it is re-placed normally. How can I fix this?
Monster's Create:
xBack = x;
yBack = y;
jointX = x;
jointY = y;
stepTimer = 40;
yBack = y;
jointX = x;
jointY = y;
stepTimer = 40;
Monster's Step:
angle=point_direction(x, y, obj_player.x, obj_player.y)
image_index=angle*8/360;
stepTimer--;
if(stepTimer <= 0)
{
xBack = obj_collector.x;
yBack = obj_collector.y;
stepTimer = 180;
}
jointX = obj_collector.x;
jointY = obj_collector.y;
Monster's Draw:
///Draw Body
d3d_transform_set_identity();
d3d_transform_add_rotation_x(90);
d3d_transform_add_rotation_z(point_direction(x, y, obj_player.x, obj_player.y)+90);
d3d_transform_add_translation(x, y, 68)
draw_sprite_ext(spr_collector, image_index, 0, 0, 1, 1, 0, c_white, 1);
d3d_transform_set_identity();
//Draw Leg
var leg = sprite_get_texture(spr_collectorRightLeg,0);
d3d_draw_wall(jointX,jointY,30,xBack,yBack,0,leg,1,1);