public void update(Graphics g2) { try { Graphics g = this.img_back.getGraphics(); g.setColor(Color.black); g.fillRect(0, 0, APPLET_SIZE, APPLET_SIZE); // Draw map if (getMapData() != null) { getMapData() .paint( g, (int) this.view_top_left.x, (int) this.view_top_left.y, this.show_map_owners, this.show_threats, this.show_targets); } if (sprites != null) { Sprite sprite; for (int i = 0; i < sprites.size(); i++) { sprite = (Sprite) sprites.get(i); if (sprite != null) { try { if (this.getMapData().map[sprite.getMapX()][sprite.getMapY()].seen) { sprite.paint( g, (int) this.view_top_left.x - (APPLET_SIZE / 2), (int) this.view_top_left.y - (APPLET_SIZE / 2)); } } catch (java.lang.ArrayIndexOutOfBoundsException ex) { // Do nothing } } } } if (menus != null) { g.setFont(font_large); AbstractControl ac = null; for (int i = 0; i < menus.size(); i++) { ac = (AbstractControl) menus.get(i); ac.paint(g); } } if (i_game_stage < Main.STAGE_GAME_MENU) { g.setColor(Color.yellow); g.setFont(font_xlarge); g.drawString(TITLE, 50, 200); g.setFont(font_large); g.drawString(VERSION, 60, 250); if (this.img_cache.areImagesLoaded()) { if (this.i_game_stage == Main.STAGE_FIRST_TIME) { g.drawString("Click to Start!", APPLET_SIZE / 2 - 100, APPLET_SIZE / 2 + 40); } else { g.drawString("Press S to Start!", APPLET_SIZE / 2 - 100, APPLET_SIZE / 2 + 40); } } else { g.drawString( "Please wait... (" + this.img_cache.percent + "%)", APPLET_SIZE / 2 - 100, APPLET_SIZE / 2 + 40); } } else if (i_game_stage == Main.STAGE_GAME_FINISHED) { g.setColor(Color.yellow); g.setFont(font_xlarge); if (won) { g.drawString("YOU HAVE WON!", 150, 200); } else { g.drawString("You have LOST!", 150, 200); } g.setFont(font_large); g.drawString("Press R to restart", APPLET_SIZE / 2, APPLET_SIZE / 2 + 40); } log.paint(g, 20, APPLET_SIZE - LogWindow.HEIGHT - 20); if (i_game_stage >= Main.STAGE_PLAYING_GAME) { stats.paint(g, 20, 20); if (icon_panel != null) { icon_panel.paint(g); } } g.setFont(font_small); g.setColor(Color.DARK_GRAY); g.drawString(VERSION, APPLET_SIZE - 50, 20); g2.drawImage(this.img_back, 0, 0, this); } catch (Exception e) { e.printStackTrace(); System.exit(-1); } }