private void handle_left_straight() { percentage += straight_per_inc; angle = 0; x = myLocation.x + myLocation.getW() - (int) (myLocation.getH() * percentage); y = myLocation.y + myLocation.getH() / 2; try_transition(Dir.LEFT); }
private void handle_down_straight() { percentage += straight_per_inc; angle = 90; x = myLocation.x + myLocation.getW() / 2; y = myLocation.y + (int) (myLocation.getH() * percentage); try_transition(Dir.DOWN); }
// Sets the location of this car. // We will assume that cars start on a right facing straight segment of track. public void setLocation(TrackPiece track) { myLocation = track; moving = true; x = myLocation.x + myLocation.getW() / 2; y = myLocation.y + myLocation.getH() / 2; percentage = .5; angle = 0; // Starts facing right. }
private void handle_left_curve_down() { percentage += curve_per_inc; int radius = myLocation.getW() * 3 / 4; angle = (int) (-90 * percentage); // Angle along the curve. double theta = Math.toRadians(90 * percentage); x = (int) (myLocation.x + myLocation.getW() - radius * Math.sin(theta)); y = (int) (myLocation.y + myLocation.getH() - radius * Math.cos(theta)); try_transition(Dir.DOWN); }