You are browsing as a guest. Sign up (or log in) to start making projects!

2h 38m 12s logged

devlog #2

I finally got the rotation to work after working on it for a while and ngl it was not as easy as i thought it would be. But atleast the player faces the cursor now.

So, i divided the area in 4 parts like the 4 quadrants of a graph, then did the math for each one of them and added a certain amount to make up for the previous quadrants. At first it felt easy and i got the first quadrant to work really easily, it was after that that things started to not make sense, because in theory I was pretty sure that i should’ve be able to find out the opposite cathetus for both of the bottom quadrants the same way, but for some reason it wasnt working like that and acting weird. Then i tried to make a different triangle with a different cathetus and which worked, so i ended up solving the opposite cathetus differently for each quadrant :)

I also had to add like a 90 degrees offset because the game starts with the player facing a different direction and 0 degrees in raylib is right i think, so i had to add 90 degrees to fix that.

And for the hypotenuse’s length i used the distance formula:
d = ((x1 - x2)^2 + (y1 - y2)^2))^0.5

then to find the angle i used the formula for sine which is:
sin(angle) = oppositecathetus/hypotenuse
from this i solved out the angle so i got:
angle = sin^-1(oppositecathetus/hypotenuse)

But the asin (arcsine - sin^-1) function was returning the value in radians which i am not comfortable with at all, so i just converted it into degrees by multiplying the value i got from the asin function by:
(180/3.14)

As for the next step, it will probably be something like getting the player to move or maybe bullets because i’m still unsure about how i want the movement and i dont really want to completely copy hotline miami’s movement either. So i’ll think about it

0
3

Comments 0

No comments yet. Be the first!