import java.awt.*; import java.applet.*; import java.awt.event.*; import com.genuts.gameui.*; public class DisplayPlatform extends Applet { PlayField playfield = null; public void init() { setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); setBackground(new Color(0xE0E0E0)); // Load Images Image backgroundImage = getImage(getCodeBase(), "background.jpg"); Image groundTileImage = getImage(getCodeBase(), "groundTile.gif"); MediaTracker tracker = new MediaTracker(this); tracker.addImage(backgroundImage, 0); tracker.addImage(groundTileImage, 0); try { tracker.waitForID(0); } catch (InterruptedException e) { System.out.println("Loading interrupted"); } // Init the playfield playfield = new PlayField(512, 352); playfield.setBackgroundImage(backgroundImage); // Constructs the playfield background int[][] cells = {{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1}, {1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1}, {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1}, {1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1}, {1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1}, {1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}}; for (int y = cells.length - 1; y >= 0; y--) { for (int x = 0; x < cells[y].length; x++) { if (cells[y][x] != 0) { Sprite sprite = new GroundTile(new Sprite(groundTileImage)); sprite.setPosition(x*32, y*32); sprite.setId(cells[y][x]); playfield.addSprite(sprite); } } } add(playfield); } public void start() { playfield.setPause(false); } public void stop() { if (playfield != null) { playfield.stop(); } } }