Fixed sails so they behave correctly

- Changed sail angle calculations back
- Luffing currently displays no sail as a temporary representation of sails in

#story[1098]
main
Jessica Syder 8 years ago
parent f6cdf66bfe
commit ace1252c1d

@ -328,32 +328,30 @@ public class ResizableRaceCanvas extends ResizableCanvas {
double sailRotateAngle; // required rotation for correct sail display double sailRotateAngle; // required rotation for correct sail display
Image sailImage; Image sailImage;
gc.save(); // remove when method is finished
// right half of points of sail sailRotateAngle = 0;
if (boatBearing < 180) { sailImage = null;
sailImage = sailsRight;
sailRotateAngle = boatBearing; // math
xPos -= 1; // right align to boat edge on canvas
// System.out.println("right side -- boat: " + boatBearing +
// "|| rotate: " + sailRotateAngle);
}
// left half of points of sail
else {
sailImage = sailsLeft;
sailRotateAngle = -(360 - boatBearing); // math
xPos -= 5; // left align to boat edge on canvas
// System.out.println("left side -- boat: " + boatBearing +
// "|| rotate: " + sailRotateAngle);
}
// Change the angle of the sail if the sail is out gc.save();
if (ThisBoat.getInstance().isSailsOut()) { if (ThisBoat.getInstance().isSailsOut()) {
if (boatBearing < 180) { if (boatBearing < 180) { // right half of points of sail
sailRotateAngle -= 90; sailImage = sailsRight;
} else { sailRotateAngle = boatBearing * 0.5; // math
sailRotateAngle += 90; xPos -= 1; // right align to boat edge on canvas
// System.out.println("right side -- boat: " + boatBearing +
// "|| rotate: " + sailRotateAngle);
}
else { // left half of points of sail
sailImage = sailsLeft;
sailRotateAngle = -(360 - boatBearing) * 0.5; // math
xPos -= 5; // left align to boat edge on canvas
// System.out.println("left side -- boat: " + boatBearing +
// "|| rotate: " + sailRotateAngle);
} }
} }
else {
// TODO: display luffing sail
}
// rotate sails based on boats current heading // rotate sails based on boats current heading
rotate(sailRotateAngle, boatPos.getX(), boatPos.getY()); rotate(sailRotateAngle, boatPos.getX(), boatPos.getY());

Loading…
Cancel
Save