• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

making punch effect draw_sprite_pos?

F

Furiosposion

Guest
have a good day, im new in gml and trying to make punch effect like in the images (it's from a game called Growtopia) as i searched from documents i need to use
Code:
draw_sprite_pos(sprite, subimg, x1, y1, x2, y2, x3, y3, x4, y4, alpha);
for it. but i don't know where to place them and how to calculate it.
and hand sprite's start point is obj_player's x and y, end point is mouse position as i added in images.
any help would make me happy thanks





or how can i draw sprite scretched and rot at same time? and scretch and rot by mouse position
 
Last edited by a moderator:

2Dcube

Member
I think you can achieve the same effect with image_xscale, image_yscale, and image_angle.
Use x and y scale to make the hand bigger and image_angle to rotate it to the mouse.
For example to get the angle towards mouse
Code:
var angle = point_direction(character.x, character.y, mouse_x, mouse_y);
 
F

Furiosposion

Guest
Code:
image_xscale = mouse_x - obj_player.x;
image_yscale = mouse_y - obj_player.y;

x = obj_player.x;
y = obj_player.y
image_angle = point_direction(obj_player.x, obj_player.y, mouse_x, mouse_y);
i tried this and result was broken, i guess something wrong with scaling
 

FrostyCat

Redemption Seeker
It's easy to see what's wrong in your attempt once you realize that 1 in image_xscale and image_yscale corresponds to standard size.
Code:
image_xscale = max(1, point_distance(obj_player.x, obj_player.y, mouse_x, mouse_y)/sprite_width);
x = obj_player.x;
y = obj_player.y;
image_angle = point_direction(obj_player.x, obj_player.y, mouse_x, mouse_y);
 
F

Furiosposion

Guest
It's easy to see what's wrong in your attempt once you realize that 1 in image_xscale and image_yscale corresponds to standard size.
Code:
image_xscale = max(1, point_distance(obj_player.x, obj_player.y, mouse_x, mouse_y)/sprite_width);
x = obj_player.x;
y = obj_player.y;
image_angle = point_direction(obj_player.x, obj_player.y, mouse_x, mouse_y);
Code:
image_yscale = max(1, point_distance(obj_player.x, obj_player.y, mouse_x, mouse_y)/25);
x = obj_player.x;
y = obj_player.y;
image_angle = point_direction(obj_player.x, obj_player.y, mouse_x, mouse_y);
works but image's angle is not properly rotating to mouse position.
 

FrostyCat

Redemption Seeker
Code:
image_yscale = max(1, point_distance(obj_player.x, obj_player.y, mouse_x, mouse_y)/25);
x = obj_player.x;
y = obj_player.y;
image_angle = point_direction(obj_player.x, obj_player.y, mouse_x, mouse_y);
works but image's angle is not properly rotating to mouse position.
When using sprites designed to be rotated in GML, always start pointing to the right with the origin at the intended centre of rotation. That works best with built-in functions and variables. If you've done that, my code should have worked as intended.
 
Top