Java Reference
In-Depth Information
trPlayer.get(plyrPos);
RayIntersection rayIntersection = new RayIntersection();
attackGroup.pick(-1, plyrPos[3], plyrPos[7], plyrPos[11], // player loc
- plyrPos [2], - plyrPos [6], - plyrPos [10], // direction
rayIntersection);
Node hit = rayIntersection.getIntersected();
if(hit != null) {
numberOfHits++;
updateScore();
hit.setRenderingEnable(false); // don't show it again
hit.setPickingEnable(false);
// don't allow it to be picked again
...
One last point tomake with our sample game is that it also demonstrates
the large effect that the number of pixels to be updated has on frame rate.
As you move the camera around the 3D universe, the large blue-green
planet in the distance comes in and out of view. Since this game always
displays the current frame rate in the top left corner you can see the frame
rate vary sharply as this happens. As you do this take into account that
the small orbiting planetoid is the same mesh (therefore has the same
polygon count) but occupies far fewer pixels on the screen.
8.4.7 Using the Bluetooth API (JSR-82)
Multiplayer games are one of the fastest growing areas in the games
industry and one of the great things about mobile phones is multiplayer
games over Bluetooth. Bluetooth is a wireless radio technology that
operates in the 2.4GHz range over distances of up to 10 meters. These
days, we use Bluetooth to connect all types of peripheral devices so it is a
great technology to know how to use. Before proceeding, we recommend
reading an excellent series of articles on multiplayer games available
from the Sun Developers' Network, 11 which gives a great background
into a number of concepts.
Bluetooth can be reasonably difficult to understand at first because,
unlike most other areas of networking, the actual topology of the network
can be very dynamic as new devices may come in and out of range
at any time. Even the process of establishing a connection between
two Bluetooth devices is unusual because connections are initiated from
the server (or 'master') device to clients that listen on server sockets.
Most examples you find online mix UI code directly in with connection
management code and events, often making it difficult to focus on the
key concepts.
The Bluetooth code included in our sample game has been taken
directly from Forum Nokia, 12 specifically Sections 5.1 and 5.2 of 'Games
11 developers.sun.com/mobility/allarticles/#games
12 Bluetooth API Developer's Guide and Games over Bluetooth.
Search WWH ::




Custom Search