Java Reference
In-Depth Information
Figure 8.2 GhostPong
The code below shows the game canvas - for the full application
please refer to the code on the topic's website.
1 public class GhostPongCanvas extends GameCanvas implements Runnable {
2
3
GhostPongMIDlet midlet;
4
boolean running;
5
final Graphics graphics;
6
int pongX, pongY, pongWidth, pongHeight;
7
Image ghostImage;
8
Sprite pong;
9
LayerManager layerManager;
10
Random random = new Random();
11
long startTime, lastGenTime;
12
int points = 0;
13
Font font;
14
Player tonePlayer;
15
ToneControl toneControl;
16
byte G = (byte)(ToneControl.C4 + 7);
17
byte[] soundSeq = {
ToneControl.VERSION,1,ToneControl.TEMPO,127,G,8,G,8 } ;
18
19
public GhostPongCanvas(GhostPongMIDlet midlet) throws Exception {
20
super(true);
21
setFullScreenMode(true);
22
this.midlet = midlet;
23
graphics = getGraphics();
24
font = Font.getFont(Font.FACE_PROPORTIONAL,
Font.STYLE_BOLD,...SIZE_LARGE);
25
ghostImage = Image.createImage("/ghost.png");
 
Search WWH ::




Custom Search