#Calculating Damage in GML

20 messages · Page 1 of 1 (latest)

runic meteor
#

Sorry if this is something easy but I'm making an rpg game and I'm rotating a sword around its origin. I want to calculate damage based on the speed of the swords movement, is there anything I can do to track rotation speed?

honest lantern
#

How're you rotating it?

runic meteor
#

image_angle = point_direction(x,y,mouse_x,mouse_y);

#

every step its being aligned with my player

weak violet
#

you could track how much image_angle is changing each step to get that speed

var prev_angle = image_angle;
image_angle = point_direction(x,y,mouse_x,mouse_y);

var rotation_speed = abs(image_angle - prev_angle);```
#

then take that number and apply whatever multipliers you want to it to get the damage

runic meteor
#

thank you ill try that

honest lantern
#

Subtracting may get a lil tricky

weak violet
#

ah yeah that'd also work

runic meteor
#

what would that do

weak violet
#

angle_difference returns the difference between two angles

honest lantern
#

Angle difference takes two angle values. And it will account for things going from 359 -> 0 or 0 -> 359

runic meteor
#

oh ok

weak violet
#

yeah what I posted before will get weird if it went from 340 to 20 or something

#

so angle_difference would be better

#

var rotation_speed = abs(angle_difference(image_angle, prev_angle)); just swap out the subtraction stuff for angle_difference

runic meteor
#

thank you ive been thinking of a way but i just started like a week ago ill try that

weak violet
#

I added the abs (makes any negative number positive) because you presumably don't wanna do negative damage to something if you rotate the sword to the right lol

runic meteor
#

makes sense lol