Blog week 1 – Projectile shooting

Blog picture 1

Hi!
The whole prototyping has been rough, not becuase it was hard but more lack of time. And by lack of time i do not mean that we had little time but our group prioritised the wrong thig, since writing everything in main seemed wrong so we started to build an engine.

However we started prototyping and I’ve done so the character can shoot and aim with the mouse, however its a bit strange right now since its flying all over where i do not want it to be. I’ve yet to figure out a good way for the arrow to move exactly thowars the possition of the mouse.

I have a way to calculate the angle that is between the character and the mouse now i only need a way to draw a ”line” and make the arrow move according to it. But right now the arrow flies off somewhere mostly upwards of to the left, however it stays on the screen and does not travel out from it, no clue why. Never gotten it to fly to the right for now, but I can’t really continue unless im getting this correct.

Before I tried the angle calculation I though that maybe a way to use linear equation with Y = kx + m so i calculated delta X and delta Y and divided to get k and let the Y possition of the arrow be influenced by the x possition and only let it move right or left. The idea was good but in initiation it did not work, how do i know that? Well there where three possitions the arrow could be in, one in the top right, one in the middle top and the last was  in the top left. So i gave up on the idea of that, maybe i could have gotten it to work with enough time but i felt it was a hard and painfull way.

After that i started with the other way of doing it, I already had both delta X and Y so i could start from there, and in c++ there is a thing called atan2 wich could be used as a way to calculate angle so i took atan2(delta X, delta Y) / 180 * PI and this is really where I am at right now, trying to figure out a way to make it shoot to the point of the mouse.

Blog week 1 – Projectile shooting