I've been having some trouble with trying to get a bullet to fire at angle that I put in. I am using eclipse with java.
My code:
x += (int) (spd * Math.cos(dir));
y -= (int) (spd * Math.sin(dir));`
The feel like the reason it's not working is because it is casted to an int which possibly makes it so inaccurate. But in order for it to draw the rectangle it needs ints.
When inputting dir as 0 it's fine and shoots to the right. The problem is when I put in 90, instead of shooting striaght up it shoots off a little to the left.
Any idea on how I can fix this? Thanks!