import java.applet.*;
import java.awt.*;
public class Game extends Applet implements Runnable {
Image buffer; // faster than BufferedImage, I've experienced
Thread me;
public void init() {
buffer = createImage(getWidth(),getHeight());
me = new Thread(this);
me.start();
}
public void run() {
while (me.isAlive()) {
// game logic here
if (getGraphics() != null) paint(getGraphics());
try {
Thread.sleep(10);
}
catch (InterruptedException e) {}
}
}
public void paint(Graphics g) {
Graphics gfx = buffer.getGraphics();
// work your drawing magic here
g.drawImage(buffer,0,0,null);
}
}
Learning how to program/code video games step by step in Java. Platformers, Shooters, Turn Based Strategy, Real Time Strategy.
donderdag 31 maart 2011
Skeleton game code.
I found this code on java gaming.
Abonneren op:
Reacties posten (Atom)
Geen opmerkingen:
Een reactie posten
Opmerking: Alleen leden van deze blog kunnen een reactie posten.