1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Make d3d_draw_wall sprite face player?

Discussion in 'Programming' started by jar_are_red, Apr 11, 2019.

Tags:
  1. jar_are_red

    jar_are_red Member

    Joined:
    Jan 3, 2019
    Posts:
    3
    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:

    xBack = x;
    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);
    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?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice