public class canvasGame extends GameCanvas implements Runnable {
// Constructor and initialization
public canvasGame() {
super(true);
...
}
// Automatically start thread for game loop
public void start() {
isPlay = true;
Thread t = new Thread(this);
t.start();
}
public void stop() { isPlay = false; }
// Main Game Loop
public void run() {
Graphics g = getGraphics();
while (isPlay == true) {
input();
drawScreen(g);
try { Thread.sleep(delay); }
catch (InterruptedException ie) {}
}
}
// Method to Handle User Inputs
private void input() {
int keyStates = getKeyStates();
// Left
if ((keyStates & LEFT_PRESSED) != 0)
currentX = Math.max(0, currentX - 1);
...
}
// Method to Display Graphics
private void drawScreen(Graphics g) {
...
flushGraphics();
}
}
gan, tolong dong.. mau tanya ni.
ReplyDeleteapa netbeans 6.7.1 bisa buatgame untuk skripsi??
caranya?
trims