View Game: ApoImp4k

ApoImp4k (http://www.apo-games.de/apoImp4k/)

By ApoGames, submitted on Dec 2, 2012
Min JRE version: 1.6
2571 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

ApoImp4k is an awesome addictive puzzle game!

The two imps love christmas and want to idle at the christmas tree. So please: Help them to reach the christmas tree.

The gameplay is adapted by the great "About Love, Hate and the other ones" game.

Instructions

Guide the imps with the cursor keys.
Change the current imp with the spacebar or the right mouse button.
You can use the other imp as a ladder.

Green present:
Click with the mouse on a green present to push or pull the present.
The red imp pull boxes, the other imp push boxes.

Red present:
A red present can't be moved.

Blue present:
The blue present is a ladder. So you can reach higher places.

Beamer:
With a beamer you can change your position, click with the mouse on it.

Press 'n' to load the next level
Press 'p' to load the previous level
Press 'r' to restart the level

User Comments

No comments have been made.

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.Color; import java.awt.Graphics2D; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; public class K extends Applet implements Runnable { /** * 0 = wall * 1 = free * 2 = red imp * 3 = blue imp * 4 = goal * 5 = box * 6 = upair / ladder [the real ladder * 7 = can't move box * 8 = beamer */ private final String[] levels = new String[] { "00000000000000"+ "00000000000000"+ "00000000000000"+ "00001111111000"+ "00003121114000"+ "00000100100000"+ "00000000000000"+ "00000000000000"+ "00000000000000"+ "00000000000000"+ "00000000000000"+ "00000000000000"+ "00000000000000"+ "00000000000000", "00000000000000"+ "00000000000000"+ "00000000011100"+ "00111111111400"+ "00111111111000"+ "00111213111000"+ "00000000000000"+ "00000000000000"+ "00000000000000"+ "00000000000000"+ "00000000000000"+ "00000000000000"+ "00000000000000"+ "00000000000000", "00000000000000"+ "00000000000000"+ "00000000000000"+ "00111111111500"+ "00153121114000"+ "00000100100000"+ "00000100100000"+ "00000000100000"+ "00000000000000"+ "00000000000000"+ "00000000000000"+ "00000000000000"+ "00000000000000"+ "00000000000000", "000000000000000000000000000000000000000000000011111110000000213511400000000100100000000001001000000000011110000000000000000000000000000000000000000000000000000000000000", "00000000000000"+ "00000000000000"+ "00000000011510"+ "00000000111540"+ "00000001111000"+ "00000011111000"+ "00011111111000"+ "00011111111000"+ "00061213111000"+ "00000010000000"+ "00000000000000"+ "00000000000000"+ "00000000000000"+ "00000000000000", "00000000000000"+ "00000000000000"+ "00111111110000"+ "01131111111000"+ "11151151111100"+ "11101100111110"+ "11111100111110"+ "01115100111140"+ "00002000111000"+ "00005111111000"+ "00000111100000"+ "00000000000000"+ "00000000000000"+ "00000000000000", "00000000000000"+ "00001111100000"+ "00001010100000"+ "00001050100110"+ "00311020100140"+ "00611050101100"+ "00011050111000"+ "00011151110000"+ "00000001100000"+ "00000001100000"+ "00000001100000"+ "00000000100000"+ "00000000100000"+ "00000000100000", "00000000000000"+ "00000000000000"+ "00000000000000"+ "00000000000000"+ "00111111100000"+ "00217000100000"+ "00315111101110"+ "00007001001140"+ "11115111111000"+ "11117111111000"+ "00000000011000"+ "00000000000000"+ "00000000000000"+ "00000000000000", "00000000000000"+ "00001111111100"+ "00011111111111"+ "00111111171511"+ "00111110000011"+ "00181310000011"+ "00000000000011"+ "00000000000011"+ "00000000111111"+ "01111100111111"+ "04811100110011"+ "00011100110012"+ "00111111110010"+ "00000000000000", "00000000000000"+ "00000001111111"+ "00000001175111"+ "01111111185111"+ "11111111100111"+ "11111511111111"+ "11111000011111"+ "23111000011111"+ "00001000015114"+ "00000000010010"+ "00000000010010"+ "00000000000010"+ "00000000000010"+ "00000000000000", "00000000000000"+ "00000000000000"+ "00000000000000"+ "00000000000000"+ "01111111115111"+ "01111111110141"+ "01111111110000"+ "01151511120000"+ "01103511000000"+ "00000000000000"+ "00000000000000"+ "00000000000000"+ "00000000000000"+ "00000000000000", "00000000000000"+ "04110000000000"+ "00111111111000"+ "00111111000000"+ "00001001151111"+ "00111101561111"+ "00111101751123"+ "00101511001100"+ "00111011011100"+ "00011111110000"+ "00010010000000"+ "00010000000000"+ "00010000000000"+ "00010000000000", "00000000000000"+ "01115111111110"+ "01415111111110"+ "00007111111110"+ "13105111511110"+ "12100100051110"+ "15111151151010"+ "10111101100000"+ "11111101100000"+ "11101001100000"+ "00000000000000"+ "00000000000000"+ "00000000000000"+ "00000000000000", "00000000000000"+ "00000000111100"+ "01161551111100"+ "01001000111400"+ "01001000115000"+ "01001000110000"+ "01111500011000"+ "01001000011000"+ "02111500000000"+ "06011000000000"+ "00011311000000"+ "00011000000000"+ "00000000000000"+ "00000000000000", "00000000000000"+ "00000000000000"+ "01111011110110"+ "04011010110100"+ "00061110100100"+ "00001010110600"+ "01111000110800"+ "01111110111800"+ "01111011111000"+ "01110000111000"+ "01110000312000"+ "01110000010000"+ "00000000000000"+ "00000000000000", "01111111111110"+ "01141111111110"+ "00000011118610"+ "00000011110000"+ "00011511110000"+ "11180000110110"+ "01105111113110"+ "21105111110110"+ "00115111111110"+ "11115111111110"+ "11110000010000"+ "11000000000000"+ "00000000000000"+ "00000000000000", "0000000000000000181111111000005511111140000055511111000000776113111111000000101101110000001000011112111010111110751185111111005515551000000000000010000000000000100000000000000000000000000000000000", }; /** * p[0] == aktuelles Level * p[1] == Spiel gestartet * p[2] == aktuelles Level geschafft klick * p[3] == mouse X-click * p[4] == mouse Y-click * p[5] == time */ private final int[] p = new int[6]; private boolean[] pressed = new boolean[256]; public void start() { enableEvents(AWTEvent.KEY_EVENT_MASK); enableEvents(AWTEvent.MOUSE_EVENT_MASK); new Thread(this).start(); } public void run() { // setSize(480, 640); // für den AppletViewer // Graphische Grundlagen für das Double Buffering BufferedImage screen = new BufferedImage(480,560,BufferedImage.TYPE_INT_RGB); Graphics2D 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; boolean[][] ladder = new boolean[1][1]; int[][] level = new int[1][1]; level[0][0] = -1; int addX = 0; int addY = 0; int wallX = -1; int wallY = -1; int goalX = -1; int goalY = -1; int changeY = 30; int curSelect = 2; float vecX = -1; float vecY = -1; float curShootX = -1; float curShootY = -1; int add = 0; boolean bBlink = false; boolean bFall = false; /** * 0 = x-position * 1 = y-position * 2 = vecX * 3 = vecY */ float[] snow = new float[400]; // Game loop. while (true) { long now = System.nanoTime(); long delta = now - lastTime; think += delta; int x, y, i; // Update / think // Wenn 10 ms vergangen sind, dann denke nach while (think >= 10000000L) { for (i = 0; i < snow.length; i += 4) { if ((snow[i+1] <= 0) || (snow[i+1] > 480)) { snow[i] = (int)(Math.random() * 470 + 1); if (snow[i+1] <= 0) snow[i+1] = (int)(Math.random() * 470 + 1); else snow[i+1] = 1; snow[i+2] = 0.004f + (float)(Math.random() * 0.004f); snow[i+3] = (float)(Math.random() * 0.1f) + 0.01f; } else { snow[i] += snow[i+2]; snow[i+1] += snow[i+3]; } } think -= 10000000L; p[5] += 10; if (p[5] % 1000 == 0) { bBlink = !bBlink; } 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[(l.length() / 14 + 2) * 2][16]; ladder = new boolean[level.length][level[0].length]; for (y = 0; y < (level.length - 4)/2; y++) { for (x = 0; x < level[0].length - 2; x++) { char c = l.charAt(y * 14 + x); level[y+1][x+1] = Integer.valueOf(c) - 48; if (level[y+1][x+1] == 4) { goalX = x+1; goalY = y+1; } } } curSelect = 2; addX = addY = p[1] = p[2] = p[3] = p[4] = 0; pressed = new boolean[256]; bFall = false; } else { int curX = -1, curY = -1; int addLeft = 0; for (y = 0; y < level.length/2; y++) { for (x = 0; x < level[y].length; x++) { if (level[y][x] == curSelect) { curX = x; curY = y; } } } if ((pressed[KeyEvent.VK_N]) || (pressed[KeyEvent.VK_P]) || (pressed[KeyEvent.VK_R])) { if (pressed[KeyEvent.VK_N]) p[0] += 1; if (pressed[KeyEvent.VK_P]) p[0] -= 1; level[0][0] = -1; think += 10000000L; } else if (p[2] == 1) { if (p[5] < 256) { break; } boolean bSolved = false; if (p[3] > 0) { bSolved = true; } for (i = 0; i < pressed.length; i++) { if (pressed[i]) { bSolved = true; } } if (bSolved) { level[0][0] = -1; p[0] += 1; think += 10000000L; } } else if ((addX == 0) && (addY == 0) && (curShootX < 0) && (!bFall)) { ladder = new boolean[level.length][level[0].length]; for (x = 0; x < level[0].length; x++) { int addFall = 0; int addFallPlayer = 0; for (y = level.length - 1; y >= 0; y--) { if (level[y][x] == 0) { addFallPlayer = addFall = 0; } if ((level[y][x] == 1) && ((x != goalX) || (y != goalY))) { addFall += 1; addFallPlayer += 1; } if ((x == goalX) && (y == goalY)) { addFallPlayer += 1; } else if ((((level[y][x] >= 5) && (level[y][x] <= 8)) && (addFall > 0)) || (((level[y][x] == 2) || (level[y][x] == 3)) && (addFallPlayer > 0) && (!ladder[y][x]))) { if (level[y][x] != 5) { addFall = addFallPlayer; } level[y + 16 + addFall][x] = addFall * 30; level[y + addFall][x] = level[y][x]; level[y][x] = 1; bFall = true; } else if (level[y][x] == 6) { int count = 0; int play = 0; for (int above = y - 1; above >= 0; above--) { if (level[above][x] == 0) { break; } if ((level[above][x] == 2) || (level[above][x] == 3)) { play += 1; } if ((level[above][x] >= 5) || (play > 1)) { count = -1; break; } count += 1; } if (count > 0) { for (int above = y; above >= y - count; above--) { ladder[above][x] = true; } } } } } if (bFall) { } else // mouse clicked if (p[3] >= 0) { if ((p[3] > 0) && (p[3] < 480) && (p[4] > changeY) && (p[4] < 480 + changeY)) { int levelX = p[3] / 30; int levelY = (p[4] - changeY) / 30; if ((level[levelY][levelX] == 5) || (level[levelY][levelX] == 8) || (level[levelY][levelX] == 6)) { int goalShootX = p[3]; int goalShootY = p[4] - changeY; for (y = 0; y < level.length/2; y++) { for (x = 0; x < level[y].length; x++) { if (level[y][x] == curSelect) { curShootX = x * 30 + 15; curShootY = y * 30 + 15; if (levelX == x) { curShootX = -1; } } } } if (curShootX > 0) { if (levelX < curX) { add = 2; } else { add = 0; } int ins = (int)(Math.abs(goalShootX - curShootX) + Math.abs(goalShootY - curShootY)); vecX = (goalShootX - curShootX) / (float)(ins) * 2; vecY = (goalShootY - curShootY) / (float)(ins) * 2; } } } p[3] = -1; } else { int addUp = 0; // check the cursor keys and space if (pressed[KeyEvent.VK_SPACE]) { pressed[KeyEvent.VK_SPACE] = false; curSelect += 1; if (curSelect > 3) { curSelect = 2; } } if ((pressed[KeyEvent.VK_LEFT]) || (pressed[KeyEvent.VK_A])) { // pressed[KeyEvent.VK_LEFT] = pressed[KeyEvent.VK_A] = false; addLeft = -1; add = 2; } if ((pressed[KeyEvent.VK_RIGHT]) || (pressed[KeyEvent.VK_D])) { // pressed[KeyEvent.VK_RIGHT] = pressed[KeyEvent.VK_D] = false; addLeft = 1; add = 0; } if ((pressed[KeyEvent.VK_UP]) || (pressed[KeyEvent.VK_W])) { // pressed[KeyEvent.VK_UP] = pressed[KeyEvent.VK_W] = false; addUp = -1; } if ((pressed[KeyEvent.VK_DOWN]) || (pressed[KeyEvent.VK_S])) { // pressed[KeyEvent.VK_DOWN] = pressed[KeyEvent.VK_S] = false; addUp = 1; } if (addUp != 0) { if ((ladder[curY + addUp][curX]) && (level[curY + addUp][curX] != 6)) { addY = addUp * -30; level[curY][curX] = 1; level[curY+addUp][curX] = curSelect; } } else if (addLeft != 0) { if ((curX + addLeft >= 0) && (curX + addLeft < level[curY].length)) { if ((level[curY][curX + addLeft] == 1) || ((curY == goalY) && (curX + addLeft == goalX))) { level[curY][curX] = 1; addX = -addLeft * 30; level[curY][curX + addLeft] = curSelect; addY = 0; } else if ((curY - 1 >= 0) && (level[curY - 1][curX] == 1) && (((level[curY - 1][curX + addLeft] == 1) || ((curY - 1 == goalY) && (curX + addLeft == goalX))))) { level[curY][curX] = 1; level[curY-1][curX + addLeft] = curSelect; addX = -addLeft * 30; addY = 30; } } } } } else if (bFall) { bFall = false; for (y = level.length - 1; y >= level.length/2; y--) { for (x = 0; x < level[0].length; x++) { if (level[y][x] > 0) { level[y][x] -= 1; bFall = true; } } } if (!bFall) { if (level[goalY][goalX] == curSelect) { p[5] = 0; p[2] = 1; } } } else if (curShootX >= 0) { curShootX += vecX; curShootY += vecY; if ((level[(int)(curShootY/30)][(int)(curShootX/30)] == 0) || (level[(int)(curShootY/30)][(int)(curShootX/30)] == 6) || (level[(int)(curShootY/30)][(int)(curShootX/30)] == 7) || (level[(int)(curShootY/30)][(int)(curShootX/30)] == 5) || (level[(int)(curShootY/30)][(int)(curShootX/30)] == 8)) { if (level[(int)(curShootY/30)][(int)(curShootX/30)] == 8) { level[(int)(curShootY/30)][(int)(curShootX/30)] = level[curY][curX]; level[curY][curX] = 8; } if ((level[(int)(curShootY/30)][(int)(curShootX/30)] == 5) || (level[(int)(curShootY/30)][(int)(curShootX/30)] == 6)) { int cur = level[(int)(curShootY/30)][(int)(curShootX/30)]; if (cur == 6) ladder = new boolean[level.length][level[0].length]; addLeft = 1; if (vecX > 0) { addLeft = -1; } if (curSelect == 3) { addLeft = -addLeft; } curX = (int)(curShootX/30); curY = (int)(curShootY/30); if (addLeft != 0) { if ((curX + addLeft >= 0) && (curX + addLeft < level[curY].length)) { if (level[curY][curX + addLeft] == 1) { level[curY][curX] = 1; addX = -addLeft * 30; wallX = curX + addLeft; wallY = curY; level[curY][curX + addLeft] = cur; addY = 0; } } } } curShootX = -1; curShootY = -1; } } else { if (addY > 0) { addY -= 2; } else if (addX > 0) { addX -= 1; } else if (addX < 0) { addX += 1; } else if (addY < 0) { addY += 1; } if ((addY == 0) && (addX == 0)) { if (wallX >= 0) { wallX = -1; } if (level[goalY][goalX] == curSelect) { p[5] = 0; p[2] = 1; } } } } } lastTime = now; // Renderabschnitt // Hintergrund malen g.setColor(new Color(40, 40, 80)); g.fillRect(0, changeY, 480, 480 + changeY); g.setColor(Color.WHITE); for (i = 0; i < snow.length; i+=4) { g.fillRect((int)(snow[i] - 1), (int)(snow[i + 1] - 1) + changeY, 2, 2); } g.setColor(new Color(150, 150, 190)); g.fillRect(0, 0, 480, changeY); g.fillRect(0, changeY + 480, 480, 80 - changeY); g.setColor(new Color(40, 40, 80)); g.drawRect(0, 0, 479, changeY); g.drawRect(0, changeY + 480, 479, 79 - changeY); g.setFont(g.getFont().deriveFont(20f).deriveFont(1)); for (y = -level.length/2; y < level.length/2; y++) { for (x = 0; x < level[0].length; x++) { if (y < 0) { if (level[y + level.length/2][x] != 0) { g.setColor(new Color(150, 150, 190)); g.fillRect(x * 30, changeY + (y + level.length/2) * 30, 30, 30); } if (ladder[y + level.length/2][x]) { g.setColor(new Color(7, 50, 7)); g.fillRect(x * 30 + 7, changeY + (y + level.length/2) * 30, 2, 30); g.fillRect(x * 30 + 22, changeY + (y + level.length/2) * 30, 2, 30); g.fillRect(x * 30 + 7, changeY + (y + level.length/2) * 30 + 5, 16, 3); g.fillRect(x * 30 + 7, changeY + (y + level.length/2) * 30 + 15, 16, 3); g.fillRect(x * 30 + 7, changeY + (y + level.length/2) * 30 + 25, 16, 3); } if ((curShootX > 0) && (x == level[0].length - 1) && (y == -1)) { g.setColor(Color.RED); if (curSelect == 3) { g.setColor(Color.BLUE); } g.fillOval((int)(curShootX - 3), (int)(curShootY - 3 + changeY), 6, 6); g.setColor(Color.BLACK); g.drawOval((int)(curShootX - 3), (int)(curShootY - 3 + changeY), 6, 6); } continue; } if (level[y][x] != 0) { g.setColor(Color.LIGHT_GRAY); if (level[y-1][x] == 0) g.drawLine(x * 30, changeY + y * 30, (x + 1) * 30, changeY + y * 30); if (level[y+1][x] == 0) g.drawLine(x * 30, changeY + (y + 1) * 30, (x + 1) * 30, changeY + (y + 1) * 30); if (level[y][x-1] == 0) g.drawLine(x * 30, changeY + y * 30, (x + 0) * 30, changeY + (y + 1) * 30); if (level[y][x+1] == 0) g.drawLine((x + 1) * 30, changeY + y * 30, (x + 1) * 30, changeY + (y + 1) * 30); if ((x == goalX) && (y == goalY)) { /** Render das Ziel */ g.setColor(new Color(26, 157, 26)); for (i = 0; i < 20; i += 2) { g.fillRect(x * 30 + i/2 + 5, y * 30 + changeY + 25 - i, 20 - i, 2); } g.setColor(new Color(78, 58, 11)); g.fillRect(x * 30 + 13, y * 30 + changeY + 25, 4, 5); g.setColor(new Color(228, 255, 0)); g.fillRect(x * 30 + 11, y * 30 + changeY + 3, 8, 2); g.fillRect(x * 30 + 14, y * 30 + changeY, 2, 8); Color c = new Color(220, 40, 40); if (bBlink) { c = new Color(255 - c.getRed(), 255 - c.getGreen(), 255 - c.getBlue()); } g.setColor(c); g.fillRect(x * 30 + 10, y * 30 + changeY + 25 - 4, 2, 2); g.fillRect(x * 30 + 18, y * 30 + changeY + 25 - 6, 2, 2); g.fillRect(x * 30 + 12, y * 30 + changeY + 25 - 11, 2, 2); } int addPX = 0; int addPY = -level[y+16][x]; if (level[y][x] == 8) { if ((x == wallX) && (y == wallY)) { addPX += addX; addPY += addY; } g.setColor(new Color(40, 60, 80)); g.fillRect(x * 30 + 8 + addPX, changeY + y * 30 + 10 + addPY, 14, 20); g.fillRect(x * 30 + 14 + addPX, changeY + y * 30 + addPY, 3, 3); g.fillRect(x * 30 + 15 + addPX, changeY + y * 30 + 3 + addPY, 1, 7); g.setColor(Color.WHITE); g.fillRect(x * 30 + 10 + addPX, changeY + y * 30 + 13 + addPY, 4, 2); g.fillRect(x * 30 + 16 + addPX, changeY + y * 30 + 13 + addPY, 4, 2); } if ((level[y][x] >= 5) && (level[y][x] <= 7)) { if ((x == wallX) && (y == wallY)) { addPX += addX; addPY += addY; } g.setColor(new Color(70, 195, 50)); if (level[y][x] == 7) { g.setColor(new Color(195, 50, 70)); } if (level[y][x] == 6) { g.setColor(new Color(100, 120, 245)); } g.fillRect(x * 30 + 3 + addPX, changeY + y * 30 + 4 + addPY, 24, 24); g.setColor(Color.BLACK); g.drawRect(x * 30 + 3 + addPX, changeY + y * 30 + 4 + addPY, 24, 24); g.setColor(new Color(167, 73, 70)); if (level[y][x] == 7) { g.setColor(new Color(73, 70, 167)); } if (level[y][x] == 6) { g.setColor(new Color(7, 50, 7)); } g.fillRect(x * 30 + 4 + addPX, changeY + y * 30 + 4 + addPY + 11, 23, 4); g.fillRect(x * 30 + 3 + addPX + 10, changeY + y * 30 + 5 + addPY, 4, 23); g.fillRect(x * 30 + 3 + addPX + 7, changeY + y * 30 + 4 + addPY - 3, 3, 3); g.fillRect(x * 30 + 3 + addPX + 14, changeY + y * 30 + 4 + addPY - 3, 3, 3); g.fillRect(x * 30 + 3 + addPX + 10, changeY + y * 30 + 4 + addPY - 2, 4, 2); } if ((level[y][x] == 2) || (level[y][x] == 3)) { if (level[y][x] == curSelect) { if (wallX < 0) { addPX = addX; addPY += addY; } } for (i = 0; i < 2; i++) { int curX = x * 30 + addPX; int curY = changeY + y * 30 + addPY; if (i == 1) { if (level[y][x] != curSelect) { break; } curX = 5; curY = changeY + 480 + 10; g.setColor(new Color(40, 40, 80)); g.drawRoundRect(curX, curY, 30, 30, 10, 10); } if (i == 0) { if (level[y][x] == curSelect) { g.setColor(Color.LIGHT_GRAY); g.drawRoundRect(x * 30 + 7 + addPX, changeY + y * 30 + 3 + addPY, 14, 27, 10, 10); } } g.setColor(new Color(218, 60, 60)); if (level[y][x] == 3) { g.setColor(new Color(60, 60, 218)); } g.fillRect((int)(curX) + 10, (int)(curY) + 12, 10, 6); g.fillRect((int)(curX) + 12, (int)(curY) + 6, 6, 6); g.fillRect((int)(curX) + 8, (int)(curY) + 22, 14, 2); g.fillRect((int)(curX) + 10, (int)(curY) + 26, 10, 2); g.setColor(new Color(253, 188, 111)); g.fillRect((int)(curX) + 10, (int)(curY) + 18, 10, 2); g.fillRect((int)(curX) + 8, (int)(curY) + 24, 14, 2); g.setColor(Color.BLACK); g.fillRect((int)(curX) + 10, (int)(curY) + 24, 10, 2); g.fillRect((int)(curX) + 10, (int)(curY) + 28, 2, 2); g.fillRect((int)(curX) + 18, (int)(curY) + 28, 2, 2); g.fillRect((int)(curX) + 12 - add, (int)(curY) + 18, 2, 2); g.fillRect((int)(curX) + 18 - add, (int)(curY) + 18, 2, 2); g.setColor(Color.YELLOW); g.fillRect((int)(curX) + 14 - add, (int)(curY) + 24, 4, 2); g.setColor(Color.WHITE); g.fillRect((int)(curX) + 10 - add, (int)(curY) + 20, 12, 2); g.fillRect((int)(curX) + 12 - add, (int)(curY) + 22, 8, 2); g.fillRect((int)(curX) + 10, (int)(curY) + 16, 10, 2); g.fillRect((int)(curX) + 12 + add, (int)(curY) + 2, 4, 4); } } } } } g.setColor(new Color(40, 40, 80)); String s = "ApoImp4k"; int w = g.getFontMetrics().stringWidth(s); g.drawString(s, 240 - w/2, 25); g.setFont(g.getFont().deriveFont(15f).deriveFont(1)); if (p[2] > 0) { s = "Congratulation!"; g.drawString(s, 240 - g.getFontMetrics().stringWidth(s)/2, changeY + 480 + 20); s = "Press any key to start the next level"; g.drawString(s, 240 - g.getFontMetrics().stringWidth(s)/2, changeY + 480 + 42); } else { s = "Press r to restart the level"; g.drawString(s, 240 - g.getFontMetrics().stringWidth(s)/2, changeY + 480 + 31); } g.drawString("level: "+String.valueOf(p[0]+1)+" / "+levels.length, 10, 25); // Render das Ganze auf den Bildschirm appletGraphics.drawImage(screen, 0, 0, null); try { Thread.sleep(5); } catch (Exception e) { /** nicht schön aber selten */ }; if (!isActive()) { return; } } } @Override public void processEvent(AWTEvent e) { if (e.getID() == MouseEvent.MOUSE_RELEASED) { MouseEvent event = (MouseEvent)e; if (event.getButton() == 3) { pressed[KeyEvent.VK_SPACE] = true; } else { p[3] = event.getX(); p[4] = event.getY(); } } if (e.getID() == KeyEvent.KEY_PRESSED) { KeyEvent event = (KeyEvent) e; if (event.getKeyCode() < 256) { pressed[event.getKeyCode()] = true; // if ((pressed[KeyEvent.VK_N]) || (pressed[KeyEvent.VK_P]) || (pressed[KeyEvent.VK_R]) || (p[5] > 1000)) pressed[event.getKeyCode()] = true; } } if (e.getID() == KeyEvent.KEY_RELEASED) { KeyEvent event = (KeyEvent) e; if (event.getKeyCode() < 256) { pressed[event.getKeyCode()] = false; } } } }