Game Development Reference
In-Depth Information
Figure 5-16.
A typical Golf Game version 4 screen shot
Since much of the
GolfGame4
code is the same as the previous versions of the Golf Game,
only a couple of aspects of the code will be discussed. A
SpinProjectile
object is declared as a
field of the
GolfGame4
class and will be used to model the golf ball.
import javax.swing.*;
import java.awt.*;
import javax.swing.border.BevelBorder;
import java.awt.event.*;
import javax.swing.Timer;
public class GolfGame4 extends JFrame implements ActionListener
{
// GUI component declarations not shown ...
// The golf ball is a SpinProjectile.
private SpinProjectile golfball;