I have run into a issue while coding my game. I am using Slick Libraries and Light Weight Java Games libraries. I am trying to make my player (Plane) go to a certain area on the map. For example if I set the target coords to (50,50) My plane will go to 50 on the X and then go to 50 on they Y. But I am stuck on rotation. I am trying to get my plane to rotate to 90 degrees, like a player would if he was controlling it, So I don't want to just set the rotation I want it to rotate at the normal rate (0.2*delta), until it hits 90 degrees.
The code bellow will only work if the plane is rotated facing left currently.
This is my Current code.
if(AIToggle){
AIStatus = "ON";
if(TargetX < x){
if(plane.getRotation() < 0 ){
if(plane.getRotation()<=-270 ){
plane.rotate(-0.2f * delta);
}
}
}
}
What it currently does: If the plane is rotated left more then 90 degrees and AI is on then it will slowly rotate it to 0 degrees. Which is what I don't understand.
What I am trying to get it to do: If the plane is rotated left more then 90 degrees, rotate the plane to -90 degrees then stop.