Hi, I just started making a Java 1.5 applet parallax side-scrolling adventure game using tiles. The game is going to be similar to Donkey Kong Country, Sonic the Hedgehog, and Super Mario World. However, I do not want to use any third-party game engines because of customization and speed issues. Third-party game engines are bloaty, unprofessional, and they are for novices. I want the fastest methods for making a game like that. I am using MemoryImageSource, but calling the drawImage(image, 0, 0, null) method on every frame is very slow. image.flush() is also slow, but not as slow as drawImage. The only thing that slows down the game is the drawImage method. How can I make the game run at 60 fps? I don’t know how to scroll it smoothly. How can I add sprites? Are there any faster methods for making games like this for Java 1.5 applets? The game is 512x512 pixels using 16x16 pixel tiles. Are there any faster methods to make this kind of game instead of memoryimagesource? If memoryimagesource is the fastest, how can I make it faster?
Here’s the code I’m using:
// the two-dimensional array of tiles
public byte tile[][];
static final int tilesX = 32;
static final int tilesY = 32;
static final int tileWidth = 16;
static final int tileHeight = 16;
static final int screenWidth = tileWidth * tilesX;
static final int screenHeight = tileHeight * tilesY;
protected int videoBuffer[] = new int[screenWidth * screenHeight];
private Image img;
img = createImage(new MemoryImageSource(screenWidth, screenHeight, videoBuffer, 0, screenWidth));
while (true)
{
// modify the image
img.flush();
appletGraphics.drawImage(img, 0, 0, null);
}