View Game: ApoBeam4k

ApoBeam4k (http://www.apo-games.de/apoBeam4k/)

By ApoGames, submitted on Dec 2, 2012
Min JRE version: 1.6
4429 downloads.
This game was submitted in the Java4K 2013 Competition.
Source code available! Show source code

(Click on game for focus)


You need Java installed to play this game.
You may use the button below to get it.

Get Java


Description

ApoBeam4k is a clever action puzzler, where players use sets of portals to navigate the character 'Sir Apo' to the treasure. Since Sir Apo automatically moves, players must time when to activate the portal pairs to use the appropriate trajectory.

The basic idea was from Mark Foster.

Instructions

Play the game with the keyboard.

Press the number on the portal to activate it.

User Comments

Total 1 comments:

#1 By Haz0r Mar 7, 2013 at 18:14:48
Beautiful graphics and challenging game play. Preplanning and fast execution of your strategy are the key to victory. Respect.

You need be logged in to write comments. If you need to register click here.

Source code

Note: We recommend you copy+paste this to a better editor. Some special character encoding may have been lost.

* All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import java.applet.Applet; import java.awt.AWTEvent; import java.awt.AlphaComposite; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.event.KeyEvent; import java.awt.image.BufferedImage; public class J extends Applet implements Runnable { /** * 0 = wall * 1 = free * 2 = player * 3 = finish * 4 = spikes * 5 = key * 6 = keyhole * 7 = iceblock * a = first box * b = second box * c = third box * d = fourth box * e = fifth box * f = six box */ private final String[] levels = new String[] { // // "11111111111111"+ // "11111111111111"+ // "1111b511111111"+ // "112a0611111111"+ // "00073611111111"+ // "00440000000000"+ // "11111111111111"+ // "11111111111111"+ // "11111111111111"+ // "11111111111111"+ // "11111111111111"+ // "11111111111111", "11111111111111"+ "11111111111111"+ "11111111111111"+ "11111011011111"+ "1a1210110311b1"+ "00000011000000"+ "11111111111111"+ "10001000100011"+ "10101010101011"+ "10001000101011"+ "10101011101011"+ "10101011100011", "11111111111111"+ "1111131d111111"+ "11110000011111"+ "11111111111111"+ "0121111a44b110"+ "00000000000000"+ "11111111111111"+ "00100100010111"+ "10101101010010"+ "00100100010101"+ "10101101010111"+ "00100101010111", "11111111111111"+ "11111111111111"+ "11110111011166"+ "12a1011101b161"+ "00000111000000"+ "661111c1111111"+ "36e1011101d151"+ "00000111000000"+ "111111f1111111"+ "11111111111111"+ "11111111111111"+ "44444444444444", "11111111111111"+ "11111111111111"+ "1111111c111111"+ "11111111111111"+ "11111111111111"+ "11111111111166"+ "11211b61111163"+ "00000001000000"+ "10110105011111"+ "00000001010001"+ "1000010a010001"+ "11001104011111", "11111111111111"+ "11b11111111111"+ "111111111d1c11"+ "11111111177777"+ "121111a1174737"+ "00000000000000"+ "01111111111111"+ "00000000000004"+ "11111111111f10"+ "40000000000000"+ "01e11111111111"+ "00000000000004", "11111111111e11"+ "21b111111d1177"+ "00000111177744"+ "11117777771666"+ "1c117115a17636"+ "00074777777000"+ "11111144444111"+ "11011000110001"+ "11011011110111"+ "11011011110001"+ "11011011110111"+ "44044000440004", "00111111111100"+ "0121f11111a110"+ "07777777777770"+ "01111444411110"+ "07777777777770"+ "01b1763671c110"+ "00007777770000"+ "07777777777770"+ "04444444444440"+ "051d11577e1110"+ "07777777777770"+ "04444444444440", // "11111111111111"+ // "11111111111111"+ // "11111111111111"+ // "11111111111111"+ // "11111111111111"+ // "11111111111111"+ // "11111111111111"+ // "11111111111111"+ // "11111111111111"+ // "11111111111111"+ // "11111111111111"+ // "11111111111111", "11111111111121"+ "d1111111111000"+ "00011111f11111"+ "00011111111111"+ "00051c111111b1"+ "00000011111111"+ "00000011111111"+ "00000011a11111"+ "00000000011111"+ "00000000011166"+ "0000077771e163"+ "00000444000000", "11111121111111"+ "1b111000777777"+ "10000011111a11"+ "11111111000011"+ "44111111111444"+ "66611111111111"+ "63611111111c11"+ "00000111100001"+ "11111111111111"+ "111111111111e1"+ "1111d517777771"+ "44440004444444", "11111111111121"+ "d1117111111000"+ "0001711111f111"+ "00717111111111"+ "00757c111111b1"+ "00400011777777"+ "00000011744444"+ "00000471a11111"+ "00000000011111"+ "00000000011166"+ "0000077777e163"+ "00000444040000", "362a1111111111"+ "00001111111111"+ "17111117111111"+ "11000001111111"+ "11117f111d7111"+ "11111000001111"+ "111111c7511e71"+ "11111100000011"+ "11111111117111"+ "11111111110000"+ "11111711b11111"+ "44444400044444", "11111111111111"+ "111c1712177a11"+ "00000666600000"+ "11111111777111"+ "1111b11173711d"+ "11110000007111"+ "11111111111111"+ "11111111115111"+ "07700777700000"+ "044001ef100000"+ "00000111100000"+ "00000444400000", "66111111111111"+ "36a21111b11111"+ "00000111000111"+ "11111711111111"+ "1111577f11111d"+ "77770000111110"+ "1e11000011c110"+ "10000000000110"+ "10000000000110"+ "10000000000110"+ "10000000000110"+ "44444444444444", "11111111111111"+ "31b11111111111"+ "00011111111111"+ "111111111111e1"+ "11111111111111"+ "1111c111111111"+ "11111111111111"+ "111111d111111f"+ "11111111111111"+ "11111111111111"+ "21a11111111111"+ "00044444444444", "111111b3111111"+ "10101000101101"+ "10401010101101"+ "10001010101101"+ "11011010104401"+ "11011000100001"+ "11111171211171"+ "10777070007071"+ "10111010101001"+ "10404010101010"+ "11010110007011"+ "1a11d11c71f7e1", }; /** * p[0] == aktuelles Level * p[1] == Spiel gestartet * p[2] == aktuelles Level geschafft klick */ private final int[] p = new int[3]; private boolean[] pressed = new boolean[256]; public void start() { enableEvents(AWTEvent.KEY_EVENT_MASK); new Thread(this).start(); } public void run() { // setSize(400, 400); // für den AppletViewer int y, x, i = 0; String s; BufferedImage iPlayer, iBackground = null; iPlayer = new BufferedImage(30, 30, BufferedImage.TYPE_INT_ARGB_PRE); Graphics2D g = iPlayer.createGraphics(); /** * 0 = durchsichtig * 1 = 128, 128, 128 * 2 = 96, 96, 96 * 3 = 0, 0, 0 * 4 = 192, 192, 192 * 5 = 250, 190, 90 * 6 = 250, 90, 90 * 7 = 0, 0, 127 * 8 = 145, 90, 0 * 9 = 220, 150, 0 * a = 128, 50, 0 * b = 250, 190, 0 */ s = "000111111000000"+ "000111111000000"+ "011221111110000"+ "011221111110000"+ "022222222110000"+ "022222222110000"+ "033553344220000"+ "033553344220000"+ "055555522220000"+ "055555522220000"+ "00566552211bb00"+ "00066552211bb00"+ "07744228888bb00"+ "77144228888bb00"+ "74411aa118899bb"+ "722aaaa881199bb"+ "722aaaa881199bb"+ "7221188882299bb"+ "7721188882299bb"+ "0773322222299bb"+ "0773322222299bb"+ "00033222222bb00"+ "00033222222bb00"; for (y = 0; y < 23; y++) { for (i = 0; i < 15; i++) { String d = s.substring(i + y * 15, i + y * 15 + 1); if (!d.equals("0")) { g.setColor(new Color(128, 128, 128)); if (d.equals("2")) g.setColor(new Color(96, 96, 96)); if (d.equals("3")) g.setColor(new Color(0, 0, 0)); if (d.equals("4")) g.setColor(new Color(192, 192, 192)); if (d.equals("5")) g.setColor(new Color(250, 190, 90)); if (d.equals("6")) g.setColor(new Color(250, 90, 90)); if (d.equals("7")) g.setColor(new Color( 0, 0, 127)); if (d.equals("8")) g.setColor(new Color(145, 90, 0)); if (d.equals("9")) g.setColor(new Color(220, 150, 0)); if (d.equals("a")) g.setColor(new Color(128, 50, 0)); if (d.equals("b")) g.setColor(new Color(250, 190, 0)); g.fillRect(i + 7, y + 7, 1, 1); } } } // Graphische Grundlagen für das Double Buffering BufferedImage screen = new BufferedImage(480,480,BufferedImage.TYPE_INT_RGB); g = screen.createGraphics(); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Graphics2D appletGraphics = (Graphics2D)getGraphics(); // Variablen zum Zeitmessen und genau Timen wann geupdatet werden soll long lastTime = System.nanoTime(); long think = 10000000L; // player runs in the right direction boolean bRight = true; int[][] level = new int[1][1]; level[0][0] = -1; float[] player = new float[4]; // Game loop. while (true) { long now = System.nanoTime(); long delta = now - lastTime; think += delta; // Update / think // Wenn 10 ms vergangen sind, dann denke nach while (think >= 10000000L) { think -= 10000000L; if (level[0][0] == -1) { if (p[0] >= levels.length) { p[0] = 0; } if (p[0] < 0) { p[0] = levels.length - 1; } String l = levels[p[0]]; level = new int[28][16]; player = new float[4]; for (y = 0; y < 12; y++) { for (x = 0; x < 14; x++) { char c = l.charAt(y * 14 + x); if ((int)c < 60) { level[y+1][x+1] = Integer.valueOf(c) - 48; if (level[y+1][x+1] == 2) { player[0] = (x+1)*30; player[1] = (y+1)*30; bRight = true; level[y+1][x+1] = 1; } } else { level[y+1][x+1] = Integer.valueOf(c) - 87; } } } iBackground = new BufferedImage(480, 480, BufferedImage.TYPE_INT_ARGB_PRE); Graphics2D g2 = iBackground.createGraphics(); for (x = 0; x < 16; x++) { for (y = 0; y < 15; y++) { Color c = new Color(172, 172, 172); Color c2 = new Color(182, 182, 182); Color c3 = new Color(192, 192, 192); if ((y > 13) || (level[y][x] == 0)) { c3 = new Color(104, 104, 104); c2 = new Color(74, 74, 74); c = new Color(44, 44, 44); } g2.setColor(c3); g2.fillRect(x * 30, y * 30, 30, 30); g2.setColor(c2); for (i = 0; i < 2; i++) { g2.fillRect(x * 30, y * 30 + 4 + 15 * i, 30, 2); g2.fillRect(x * 30, y * 30 + 11 + 15 * i, 30, 2); g2.fillRect(x * 30 + 4, y * 30 + 15 * i, 2, 6); g2.fillRect(x * 30 + 19, y * 30 + 15 * i, 2, 6); g2.fillRect(x * 30 + 11, y * 30 + 7 + 15 * i, 2, 6); g2.fillRect(x * 30 + 26, y * 30 + 7 + 15 * i, 2, 6); } g2.setColor(c); for (i = 0; i < 2; i++) { g2.fillRect(x * 30 + 6, y * 30 + 15 * i, 1, 6); g2.fillRect(x * 30 + 21, y * 30 + 15 * i, 1, 6); g2.fillRect(x * 30, y * 30 + 6 + 15 * i, 30, 1); g2.fillRect(x * 30, y * 30 + 13 + 15 * i, 30, 2); g2.fillRect(x * 30 + 13, y * 30 + 7 + 15 * i, 2, 6); g2.fillRect(x * 30 + 28, y * 30 + 7 + 15 * i, 2, 6); } } } for (x = 0; x < 16; x++) { for (y = 0; y < 14; y++) { if (level[y][x] != 0) { g2.setColor(Color.BLACK); g2.setStroke(new BasicStroke(2)); if (level[y-1][x] == 0) g2.drawLine(x * 30, y * 30, (x + 1) * 30, y * 30); if (level[y+1][x] == 0) g2.drawLine(x * 30, (y + 1) * 30, (x + 1) * 30, (y + 1) * 30); if (level[y][x-1] == 0) g2.drawLine(x * 30, y * 30, (x + 0) * 30, (y + 1) * 30); if (level[y][x+1] == 0) g2.drawLine((x + 1) * 30, y * 30, (x + 1) * 30, (y + 1) * 30); g2.setStroke(new BasicStroke(1)); if (level[y][x] == 3) { /** Render das Ziel */ g2.setColor(Color.YELLOW); g2.fillRect(x * 30 + 8, y * 30 + 12, 16, 16); g2.setColor(Color.WHITE); g2.fillRect(x * 30 + 8, y * 30 + 14, 14, 2); g2.setColor(new Color(162, 97, 79)); g2.fillRect(x * 30 + 10, y * 30 + 12, 3, 8); g2.fillRect(x * 30 + 18, y * 30 + 12, 3, 8); g2.setColor(Color.BLACK); g2.drawRect(x * 30 + 7, y * 30 + 11, 16, 16); g2.drawRect(x * 30 + 9, y * 30 + 11, 4, 9); g2.drawRect(x * 30 + 17, y * 30 + 11, 4, 9); g2.drawRect(x * 30 + 7, y * 30 + 22, 16, 5); g2.drawRect(x * 30 + 9, y * 30 + 22, 4, 3); g2.drawRect(x * 30 + 17, y * 30 + 22, 4, 3); } if (level[y][x] == 4) { /** Render die Stacheln */ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setColor(Color.BLACK); g2.fillPolygon(new int[] {x * 30, x * 30 + 5, x * 30 + 10, x * 30 + 15, x * 30 + 20, x * 30 + 25, x * 30 + 30}, new int[] {(y + 1) * 30,(y + 1) * 30 - 29, (y + 1) * 30,(y + 1) * 30 - 29, (y + 1) * 30,(y + 1) * 30 - 29, (y + 1) * 30}, 7); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } } } } g2.dispose(); p[1] = p[2] = 0; pressed = new boolean[256]; } else { if (pressed[KeyEvent.VK_N]) { level[0][0] = -1; p[0] += 1; pressed[KeyEvent.VK_N] = false; think += 10000000L; } else if (pressed[KeyEvent.VK_P]) { level[0][0] = -1; p[0] -= 1; pressed[KeyEvent.VK_P] = false; think += 10000000L; } else if (pressed[KeyEvent.VK_R]) { level[0][0] = -1; pressed[KeyEvent.VK_R] = false; think += 10000000L; } else if ((p[1] == 0) || (p[2] == 1)) { for (i = 0; i < pressed.length; i++) { if (pressed[i]) { pressed[i] = false; if (p[1] == 0) { if (((i >= 49) && (i < 55)) || ((i >= 97) && (i < 103))) { pressed[i] = true; } p[1] = 1; } else { level[0][0] = -1; p[0] += 1; think += 10000000L; } break; } } } else if (p[1] == 1) { for (y = level.length/2; y < level.length; y++) { for (x = 0; x < level[y].length; x++) { if ((level[y - level.length/2][x] == 7) && (level[y][x] > 0)) { level[y][x] -= 1; if (level[y][x] <= 0) { level[y - level.length/2][x] = 1; } } } } player[2] -= 1; if (player[2] < 0) { player[2] = 0; } if (bRight) { player[0] += 0.87f; } else { player[0] -= 0.87f; } if (player[3] > 0) { player[3] += 0.025f; } player[1] += player[3]; int newY = (int)(player[1]/30) + 1; int newXLeft = (int)((player[0] + 7)/30); int newXMiddle = (int)((player[0] + 15)/30); int newXRight = (int)((player[0] + 23)/30); if (((level[newY][newXLeft] == 1) || (level[newY][newXLeft] == 5)) && ((level[newY][newXRight] == 1) || (level[newY][newXRight] == 5))) { if (player[3] == 0) player[3] = 0.001f; } else { if ((level[newY][newXMiddle] == 0) || (level[newY][newXMiddle] == 6) || (level[newY][newXMiddle] == 7)) { if ((level[newY][newXMiddle] == 7) && (level[newY + level.length/2][newXMiddle] <= 0)) { level[newY + level.length/2][newXMiddle] = 200; } player[3] = 0.f; player[1] = (newY - 1) * 30; } if (((level[newY][newXLeft] == 4) || (level[newY][newXRight] == 4)) && ((level[newY][newXLeft] != 0) && (level[newY][newXRight] != 0) && (level[newY][newXLeft] != 6) && (level[newY][newXRight] != 6) && (level[newY][newXLeft] != 7) && (level[newY][newXRight] != 7))) { level[0][0] = -1; think += 10000000L; continue; } } int add = 1; if (player[3] != 0) { add = 0; } if ((level[newY - add][newXLeft] == 4) || (level[newY - add][newXRight] == 4)) { level[0][0] = -1; think += 10000000L; continue; } for (i = add; i < 2; i++) { if ((level[newY - i][newXLeft] == 0) || (level[newY - i][newXRight] == 0) || (level[newY - i][newXLeft] == 6) || (level[newY - i][newXRight] == 6) || (level[newY - i][newXLeft] == 7) || (level[newY - i][newXRight] == 7)) { if ((level[newY - i][newXLeft] == 7) && (level[newY - i + level.length/2][newXLeft] <= 0)) { level[newY - i + level.length/2][newXLeft] = 200; } if ((level[newY - i][newXRight] == 7) && (level[newY - i + level.length/2][newXRight] <= 0)) { level[newY - i + level.length/2][newXRight] = 200; } if (((level[newY - i][newXLeft] == 0) || (level[newY - i][newXLeft] == 6) || (level[newY - i][newXLeft] == 7)) && (!bRight)) { bRight = !bRight; } if (((level[newY - i][newXRight] == 0) || (level[newY - i][newXRight] == 6) || (level[newY - i][newXRight] == 7)) && (bRight)) { bRight = !bRight; } break; } } add = 1; int value = (int)(player[0]/30); if ((value * 30 - add < player[0]) && (value * 30 + add > player[0])) { if (level[newY - 1][value] == 3) { p[2] = 1; } if (level[newY - 1][value] == 5) { for (y = 0; y < level.length/2; y++) { for (x = 0; x < level[y].length; x++) { if ((level[y][x] == 5) || (level[y][x] == 6)) { level[y][x] = 1; } } } } if ((level[newY - 1][value] >= 10) || (level[newY][value] >= 10)) { int val = level[newY][value]; if (level[newY - 1][value] >= 10) val = level[newY - 1][value]; if ((pressed[val + 39]) || (pressed[val + 87])) { for (i = 10; i < 20; i++) { if ((val != i) && ((pressed[i + 39]) || (pressed[i + 87]))) { for (y = 0; y < level.length/2; y++) { for (x = 0; x < level[y].length; x++) { if (level[y][x] == i) { int iAdd = -1; if (bRight) { iAdd = 1; } if (player[2] <= 0) { player[0] = (x)*30 + iAdd; player[1] = (y)*30; player[2] = 20; } break; } } } break; } } } } } } } } lastTime = now; // Renderabschnitt // Hintergrund malen if (iBackground != null) g.drawImage(iBackground, 0, 30, null); g.setFont(g.getFont().deriveFont(20f).deriveFont(1)); AlphaComposite composite = (AlphaComposite)(g.getComposite()); for (y = 1; y < level.length/2 - 1; y++) { for (x = 1; x < level[y].length - 1; x++) { if (level[y][x] != 0) { if (level[y][x] == 5) { /** Render der Schlüssel */ g.setColor(Color.DARK_GRAY); g.fillOval(x * 30 + 8, 30 + y * 30 + 8, 6, 14); g.fillRect(x * 30 + 14, 30 + y * 30 + 14, 7, 3); g.fillRect(x * 30 + 18, 30 + y * 30 + 17, 2, 1); } if (level[y][x] == 6) { /** Render die Öffnung */ g.setColor(Color.DARK_GRAY); g.fillRect(x * 30 + 4, 30 + y * 30 + 4, 22, 22); g.setColor(Color.LIGHT_GRAY); g.fillOval(x * 30 + 8, 30 + y * 30 + 8, 6, 14); g.fillRect(x * 30 + 14, 30 + y * 30 + 14, 7, 3); g.fillRect(x * 30 + 18, 30 + y * 30 + 17, 2, 1); } if (level[y][x] == 7) { /** Render iceblock */ if (level[y + level.length/2][x] > 0) { float percent = (float)(1f/200f*(float)(level[y + level.length/2][x])); g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float)(percent))); } g.setColor(new Color(174, 211, 255)); g.fillRoundRect(x * 30, 30 + y * 30, 29, 29, 5, 5); g.setColor(new Color(40, 58, 78)); g.drawRoundRect(x * 30, 30 + y * 30, 29, 29, 5, 5); g.setComposite(composite); } if (level[y][x] >= 10) { g.setColor(Color.RED); if (level[y][x] == 11) { g.setColor(Color.YELLOW); } if (level[y][x] == 12) { g.setColor(Color.GREEN); } if (level[y][x] == 13) { g.setColor(new Color(110, 236, 236)); } if (level[y][x] == 14) { g.setColor(Color.PINK); } if (level[y][x] == 15) { g.setColor(Color.MAGENTA); } int width = 20; if ((pressed[level[y][x] + 39]) || (pressed[level[y][x] + 87])) { width = 26; } else { g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float)(0.6f))); } g.fillRoundRect(x * 30 + 15 - width/2, y * 30 + 30 + 15 - width/2, width, width, 5, 5); g.setComposite(composite); g.setColor(Color.BLACK); g.drawRoundRect(x * 30 + 15 - width/2, y * 30 + 30 + 15 - width/2, width, width, 5, 5); g.drawString(String.valueOf(level[y][x] - 9), x * 30 + 10, y * 30 + 53); } } } } if (!bRight) { g.drawImage(iPlayer, (int)(player[0]), (int)(player[1] + 30), null); } else { g.drawImage(iPlayer, (int)(player[0]), (int)(player[1] + 30), (int)(player[0] + 30), (int)(player[1] + 60), 30, 0, 0, 30, null); } g.setColor(Color.LIGHT_GRAY); g.fillRect(0, 0, 480, 30); g.setColor(Color.DARK_GRAY); g.drawRect(0, 0, 479, 30); s = "ApoBeam4k"; int w = g.getFontMetrics().stringWidth(s); g.drawString(s, 240 - w/2, 24); if ((p[1] <= 0) || (p[2] > 0)) { g.setColor(Color.LIGHT_GRAY); g.fillRect(0, 440, 480, 40); g.setColor(Color.DARK_GRAY); g.drawRect(0, 440, 479, 39); if (p[1] <= 0) { s = "Press any key to start"; w = g.getFontMetrics().stringWidth(s); g.drawString(s, 240 - w/2, 470); } else { g.setFont(g.getFont().deriveFont(15f).deriveFont(1)); s = "Congratulation!"; w = g.getFontMetrics().stringWidth(s); g.drawString(s, 240 - w/2, 456); s = "Press any key to start the next level!"; w = g.getFontMetrics().stringWidth(s); g.drawString(s, 240 - w/2, 475); } } g.setFont(g.getFont().deriveFont(15f).deriveFont(1)); g.drawString("level: "+String.valueOf(p[0]+1)+" / "+levels.length, 10, 21); // Render das Ganze auf den Bildschirm appletGraphics.drawImage(screen, 0, 0, null); try { Thread.sleep(10); } catch (Exception e) { /** nicht schön aber selten */ }; if (!isActive()) { return; } } } @Override public void processEvent(AWTEvent e) { KeyEvent event = (KeyEvent) e; if (e.getID() == KeyEvent.KEY_PRESSED) { if (event.getKeyCode() < 256) { pressed[event.getKeyCode()] = true; } } if (e.getID() == KeyEvent.KEY_RELEASED) { if (event.getKeyCode() < 256) { pressed[event.getKeyCode()] = false; } } } }