This is a bit of a maths question as much as java i think.
i have been stuck for about 3 weeks trying to make a silly racing car game. everything was going well apart from controlling the little things:
public void move()
//place checks in here as well and move from center of object
double radi = Math.toRadians(angle);// left over from one of many failed experiments
double x= Math.cos(angle);
double y= Math.sin(angle);
double fullspeed = speed * 1.5; //makes positive number change name
int centerX = x + 25;
int centerY = y + 25;
int addToX = (int)Math.round(fullspeed * x);
int addToY = (int)Math.round(y* fullspeed);
//this need to account for center
if(((x + addToX >= 50) && (x + addToX <=750)) && ((y + addToY >= 100) && (y + addToY <=550 )))
private void changePos(int xMove, int yMove)
x = x + xMove;
y = y + yMove;
my cars are going all over the place. they start ok then start reversing and all sorts very un predictable.
when i do cos(270) on calculater i get 0 and sin(270) i get -1; cos(90) = 0 and sin(90) = 1. this is the pattern i want and expected.
but i am getting from the code:
Math.sin(270) = -0.1760459464712114
Math.cos(270) = 0.9843819506325049
on my calculater there is just "cos" & "sin" + "cosh" & "sinh" is this why and how do i get the results i need.