Game Development Reference
In-Depth Information
// Create a SoccerBall object representing the soccer ball.
soccerBall = new SoccerBall(x0, y0, z0, vx0, vy0, vz0,
0.0, ballMass, area, density, cd, windVx, windVy,
rx, ry, rz, omega, radius, temperature);
// Update the display.
updateDisplay();
// Start the box sliding using a Timer object
// to slow down the action.
gameTimer.start();
}
Play around with the Free-Kick Game. If the ball crosses the goal line, hits the ground, or
hits one of the defenders, the simulation stops. A message written across the GUI informs the
user the result of the shot—“Wide left,” “Wide right,” “GOAL!,” and so on. Try scoring goals to
both the left and right of the defenders. Because of the way the lift coefficient is computed, the
Magnus force term will always be positive. To change the direction that the ball will curve,
change the direction of the spin axis. For example, you could change the value of r z from -1.0 to 1.0.
Basketball
The sport of basketball was invented by Dr. James Naismith. In 1891 at the YMCA Training
School in Springfield, Massachusetts, Dr. Naismith was looking for a game that students could
play indoors when it was too cold outside for them to play. He was interested in creating a
game in which success would be based on skill rather than on brute strength. The first basket-
ball game was played using a soccer ball and two peach baskets as goals.
From these rather humble beginnings, basketball has grown into an international sport
played and watched by millions of people. In thinking about the sport in terms of game
programming, basketball is similar to the other sports we have studied in this chapter in that it
involves throwing and bouncing a ball. We'll start our investigation in building a basketball
simulation by looking at the equipment that is used to play the game.
Equipment Specifications
Basketball, like soccer, is a relatively simple game to play in that it doesn't require much equip-
ment. All you need is a ball, a flat area called the court , and two (or even just one) baskets.
There are at least three standards for determining the specifications of the ball, court, and
basket for men's basketball. Additional standards exist for women's play. In this section,
details will be provided according to the National Basketball Association (NBA), Federation
Internationale de Basketball (FIBA), and NCAA college specifications.
The Ball
The circumference, radius, and mass of a regulation men's basketball, as shown in Figure 7-17,
depends on whether the NBA, FIBA, or NCAA standards are used. There are slight differences
between them, and these are highlighted in Table 7-4. The values shown in Table 7-4 are for
Search WWH ::




Custom Search