Game Development Reference
In-Depth Information
// Determine if ball is on the green.
if ( golfball.getX() > distanceToHole - 10.0 &&
golfball.getX() < distanceToHole + 10.0 &&
golfball.getY() < 10.0) {
g.drawString("You're on the green", 100, 30);
}
else {
drawingPanel.getGraphics().drawString("You missed", 100, 30);
}
}
}
}
}
Because the SimpleProjectile class is a subclass of ODE , the Java compiler will have to have
access to the ODE class source file or class file when the GolfGame class is compiled. Play around
with the Golf Game. You will find that it takes some fairly small adjustments to get the ball to
land within 10 m of the green. If the view axes are changed to “XY”, the result is a bird's-eye
view of the hole as shown in Figure 5-5. The display now tracks the horizontal components of
the golf ball trajectory. The green is shown as a circle with a radius of 10 m . Try giving the golf
ball an initial y-velocity component and see what happens.
Figure 5-5. A bird's-eye view of the Golf Game
Search WWH ::




Custom Search