Drawing sprites like lines

Gizmo199

Member
THE IDEA
I am trying to create a system that lets me create animations using the sequencer from a side perspective and then adjust the coordinates from the sequencer instances to rotate properly around in a faux-3d space. Here are some gifs of the idea:
Sequencer.gifWorking Lines.gif

as you can see in the Second gif it works like a charm if I am just drawing lines to x/y coordinates.
Create
GML:
// UAR = Upper arm right | LAR = Lower arm right | HAR = Hand arm right
connect_array = [bone_UAR, bone_LAR, bone_HAR];
for ( var i=0; i<array_length(connect_array); i++ ){
    dx[i] = x;
    dy[i] = y;
}
Step
GML:
direction = point_direction(x, y, mouse_x, mouse_y);

for ( var i=0; i<array_length(connect_array); i++ ){
    var _ins = connect_array[i];
    dx[i] = _ins.x * dcos(direction);
    dy[i] = _ins.y;
}
Draw
GML:
for ( var i=0; i<array_length(connect_array)-1; i++ ){
    draw_line_width(x + dx[i], y + dy[i], x + dx[i+1], y + dy[i+1], connect_array[i].thickness);
}


THE PROBLEM
So I am having a hard time figuring out how to draw a sprite as a line. By that, I mean drawing a sprite to stretch to a certain coordinate. If I alter the code in the draw event to:

Draw
GML:
for ( var i=0; i<array_length(connect_array)-1; i++ ){
    var _pdir = point_direction(x + dx[i], y + dy[i], x + dx[i+1], y + dy[i+1]);
    draw_sprite_ext(connect_array[i].sprite_index, connect_array[i].image_index, x+dx[i], y+dy[i],
                    connect_array[i].image_xscale, connect_array[i].image_yscale, _pdir,
                    connect_array[i].image_blend, connect_array[i].image_alpha);

}
I get something like this:
Not working sprites.gif

So what I am asking is what is the best way to make it so that the sprites will stretch accordingly depending on the rotation. I have tried altering image_xscale values along the directional sine (dsin) of the angle but it just makes all of the individual bone/limbs shrink to nothing. Any help would be amazing! Thanks in advance! :D

EDIT: The Reason I need it to stretch it is because once the y position of the connect-ED bone is above the y position of the connect-ING you get that weird jittery 'point_direction' issue when the points are too close together.
 

DaveInDev

Member
I won't burn my brain to find the trigos formulas :p
but I think that you should use draw_sprite_pos which is the function that can strectch/skew the way you need (in perspective).
draw_sprite_ext cannot skew : just rotate and scale...
 

Gizmo199

Member
I won't burn my brain to find the trigos formulas :p
but I think that you should use draw_sprite_pos which is the function that can strectch/skew the way you need (in perspective).
draw_sprite_ext cannot skew : just rotate and scale...
Yeah, I already explored the draw_sprite_pos function but funny enough it doesn't include rotation. haha. I thought about doing something like using a for loop and draw_sprite_part but that just seems sooooo excessive for what I need. My assumption is somewhere in the image_xscale but I just don't know exactly what math I should be trying to implement honestly. haha
 

DaveInDev

Member
ok, I did not notice for the rotation, sorry.

But for the xscale and yscale, for me, they are not enough to induce a "skew" effect that you need to create perspective :
rota+xscale+yscale keep the form of the sprite as a parallelogram.
But to create perspective, you need a "vanishing Point" : so you need that at least 2 opposite edges are not parrallel. (sorry for my english...)
 

Gizmo199

Member
ok, I did not notice for the rotation, sorry.

But for the xscale and yscale, for me, they are not enough to induce a "skew" effect that you need to create perspective :
rota+xscale+yscale keep the form of the sprite as a parallelogram.
But to create perspective, you need a "vanishing Point" : so you need that at least 2 opposite edges are not parrallel. (sorry for my english...)
I got ya! I might play around with it some and see what looks best. Thanks!
 
Top