View Game: ApoChange4k

ApoChange4k (http://www.apo-games.de/apoChange4k/)

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

ApoChange4k is a two button puzzle game.
Your goal is to collect all yellow coins
and avoid the spikes.

The gameplay is adapted from the game "Ichi".

Instructions

With every left mouse click you
1.) change the red triangles clockwise
2.) switch the green triangles on/off

With every middle mouse click (or press 'alt') you
1.) change the red triangles counterclockwise
2.) switch the green triangles on/off

When you hold the right mouse button down
(or the spacebar) you can draw a line
which you can use as a new wall. After one
hit the drawn wall will be deleted.

The circles are beamers and beam you to the
next position.

The gray boxes will be destroyed after one hit.

Press 'r' - to restart the level
Press 'n' - to start the next level
Press 'p' - to start the previous 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.BasicStroke; 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 Z extends Applet implements Runnable { /** * 0 = free * 1 = wall * 2 = spike down * 3 = spike right * 4 = spike up * 5 = spike left * 6 = start down * 7 = start right * 8 = start up * 9 = start left * 10 = a = destructable block * 11 = b = triangle leftup * 12 = c = triangle rightup * 13 = d = triangle rightdown * 14 = e = triangle leftdown * 15 = f = triangle red move leftup * 16 = g = triangle red move rightup * 17 = h = triangle red move rightdown * 18 = i = triangle red move leftdown * 19 = j = triangle green visible leftup * 20 = k = triangle green visible rightup * 21 = l = triangle green visible rightdown * 22 = m = triangle green visible leftdown * 23 = n = triangle green NOT visible leftup * 24 = o = triangle green NOT visible rightup * 25 = p = triangle green NOT visible rightdown * 26 = q = triangle green NOT visible leftdown * 27 = r = beamer yellow * 28 = s = beamer brown * 29 = t = eat */ private final String[] levels = new String[] { "111111111111111" + "111111111111111"+ "111111111111111"+ "111100000001111"+ "111107000e01111"+ "111100000001111"+ "111100000001111"+ "11110t000i01111"+ "111100000001111"+ "111111111111111"+ "111111111111111", "111111111111111" + "111111111111111" + "111111111111111" + "111111111111111" + "111111111111111" + "111100000001111" + "111107000e01111" + "111100000001111" + "111100000000001" + "11110t000g00t05" + "111100000000001" + "111111111111111" + "111111111111111" + "111111111111111" + "111111111111111", "111111111111111" + "111111111111111" + "111111111111111" + "111111000111111" + "1111110t0111111" + "111111000111111" + "111000000000111" + "1130t00g0090111" + "111000000000111" + "111111000111111" + "1111110t0111111" + "111111000111111" + "111111111111111" + "111111111111111" + "111111111111111", "111111111111111" + "111111111111111"+ "100000000001111"+ "10600d0t0e01111"+ "100000000001111"+ "100000000000001"+ "10k0ti0t0h00l01"+ "100000000000001"+ "111100000000001"+ "11110o0t0f00t01"+ "111100000000001"+ "111111111111411", "111111111111111" + "111111111111111" + "111112111121111" + "110000000000001" + "110t0g0t00h0t01" + "110000000000001" + "111100011000111" + "111100011000111" + "110000000000001" + "13070f00t0i0t01" + "110000000000001" + "111114111141111" + "111111111111111" + "111111111111111" + "111111111111111", "111111111111111" + "111111111111111" + "111121111111111"+ "111000100000001"+ "111060100t00i01"+ "100000000000001"+ "1t00g0t00a00f01"+ "100000000000001"+ "1110a0111111111"+ "111000111111111"+ "1110t0111111111"+ "111141111111111", "111111111111111" + "111111111111111" + "111111111111111" + "110000000000011" + "110d0000t00g011" + "110000000000011" + "110000000000011" + "130h00a0t00a051" + "110000000000011" + "110001111100011" + "11080111110t011" + "110001111100011" + "111411111114111" + "111111111111111" + "111111111111111", "111111111111111" + "111211121112111" + "110001000100011" + "110t0106010a011" + "110001000100011" + "11000100010t011" + "110000000000011" + "110c0a0f000b011" + "110000000000011" + "111111000111111" + "1111110a0111111" + "111111000111111" + "111111141111111" + "111111111111111" + "111111111111111", "111111111111111" + "111111111111111" + "111111111111111"+ "111111111111111"+ "110000000000111"+ "130t00h00e00511"+ "110000000000111"+ "111110t00t00111"+ "111110000000111"+ "111110c00900111"+ "111110000000111"+ "111111111411111", "111111111111111" + "111111111111111" + "111111111111111" + "111111110001111" + "111000110r01111" + "1110t0110001111" + "100000110000011" + "30t0n0510g09051" + "100000110000011" + "1110r0110t01111" + "111000110001111" + "111111110a01111" + "111111110001111" + "111111111411111" + "111111111111111", "111111111111111" + "111122222222111" + "113000000000111" + "101001000100101" + "101000000000101" + "1t00h00100i00t1" + "141000010000141" + "1130g00t00f0511" + "113000141000511" + "113000513000511" + "1130805130t0511" + "111000111000111" + "111141111141111" + "111111111111111" + "111111111111111", "111111111111111" + "111111111111111" + "111111112111111" + "111111000000011" + "1112110p000g051" + "110000000000011" + "130r0t0j070r051" + "110000000000011" + "130h000t0114111" + "110000000111111" + "111114141111111", "111111111111111" + "111111121111111" + "111100000000011" + "11130t0h000e011" + "111100000000011" + "1111110r0100011" + "111111000100011" + "111111111108011" + "100011111100011" + "10r011111100011" + "100000000000011" + "10c00t00t00t051" + "100000000000011" + "111111111111111" + "111111111111111", "111111121111111"+ "100000000000001"+ "30a0t00700t0e01"+ "100000000000001"+ "111110000010001"+ "1000100t0010r01"+ "10r010000010001"+ "100010000011111"+ "100000000000001"+ "10f0t00m0000t05"+ "100000000000001"+ "111111111111111", "111111111111111" + "111111111111111" + "111111111111111" + "111112121211111" + "111100000001111" + "11130l0h0q05111" + "1111000t0001111" + "11130ht8tf05111" + "1111000t0001111" + "11130o0f0j05111" + "111100000001111" + "111114141411111" + "111111111111111" + "111111111111111" + "111111111111111", "111211111112111" + "110000000000011" + "1300000t0000051" + "130000000000051" + "130h000k000i051" + "130000000000051" + "1300000t0000051" + "130000000000051" + "130o0t000t0a051" + "130000000000051" + "110001444100011" + "11080111110t011" + "110001111100011" + "111411111114111" + "111111111111111", "111112112111211"+ "111100000000001"+ "11130h00i0t0a05"+ "111100000000001"+ "100000000000001"+ "30700k00t000i01"+ "100000000000001"+ "11111100t010001"+ "100000000000001"+ "30t00a00o0t0a05"+ "100000000000001"+ "111111114111111", "111111111211111"+ "111111110001111"+ "111111110a01111"+ "111111110001111"+ "111000000000001"+ "1130t00l0600r01"+ "111000000000001"+ "111111000000t01"+ "111111000000001"+ "1111110r0n00t01"+ "111111000000001"+ "111111111111411", "111112111111111"+ "100000000001111"+ "10d00h000r01111"+ "100000000001211"+ "10t00t000000001"+ "30a006000f00a05"+ "100000000000001"+ "114100000t00t01"+ "111100000000001"+ "11110r000000b01"+ "111100000000001"+ "111111111411111", "111111111111111"+ "111111000000001"+ "1111110n0k0ta05"+ "111111000000001"+ "110000000000001"+ "13000t070n0ta05"+ "110000000000001"+ "110000000001111"+ "130a0t0q0l01111"+ "110000000001111"+ "111111111111111", "112112111111111"+ "100000000000001"+ "10t00f0t0g00t05"+ "100000000000001"+ "100000010001111"+ "100000000000001"+ "30a00t0t0h00a05"+ "100000010000001"+ "10c00b010801111"+ "100000010001111"+ "111111111411111", "111112111111111"+ "111100011111111"+ "11110t011111111"+ "112100011111111"+ "100000000011111"+ "10000h00o011111"+ "100000000011111"+ "10t00000t011111"+ "100000000011111"+ "100008000000011"+ "100000000000011"+ "10q00j00000a051"+ "100000000000011"+ "111114114111111", "111111111111111" + "111111211121111" + "110000000000111" + "110d0000t0a0511" + "110000000000111" + "110000000000001" + "110c00g000i0t05" + "110000000000001" + "1111100010t0111" + "110000000000001" + "130a00t000g0905" + "110000000000001" + "111111411141111" + "111111111111111" + "111111111111111", "111112121111111"+ "100000000001111"+ "10r00t0f0e01111"+ "100000000001111"+ "111100000001111"+ "11130t0t0n00t05"+ "111100000000005"+ "100000000001111"+ "10700k0i0r01111"+ "100000000001111"+ "111111141111111", "111112121111111"+ "111100000001111"+ "1111060t0r01111"+ "111100000001111"+ "100000000000001"+ "10t00g000a00t05"+ "100000000000001"+ "111100000001111"+ "11110r0i0b01111"+ "111100000001111"+ "111111141111111", }; /** * p[0] == changeX * p[1] == changeY * p[2] == aktuelles Level * p[3] == aktuelle Moveanzahl * p[4] == Maus gedrückt * p[5] == Maus losgelassen * p[6] == Spiel gestartet * p[7] == Level geschafft Klick * p[8] == down/Leertaste gedrückt * p[9] == down/Leertaste losgelassen */ private final int[] p = new int[10]; private final int[][] level = new int[15][15]; public void start() { enableEvents(AWTEvent.KEY_EVENT_MASK); enableEvents(AWTEvent.MOUSE_EVENT_MASK); new Thread(this).start(); } public void run() { // setSize(400, 400); // für den AppletViewer // Graphische Grundlagen für das Double Buffering BufferedImage screen = new BufferedImage(470,520,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; level[0][0] = -1; /** * 0 == x-Wert * 1 == y-Wert * 2 == x-Vec * 3 == y-Vec */ p[0] = 10; p[1] = 30; int[] player = new int[8]; boolean bStart = false; // 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[2] < 0) { p[2] = levels.length - 1; } if (p[2] >= levels.length) { p[2] = 0; } p[6] = p[7] = p[3] = 0; bStart = false; String l = levels[p[2]]; for (int y = 0; y < level.length; y++) { for (int x = 0; x < level[0].length; x++) { if (l.length() <= y * level[0].length + x) { level[y][x] = 1; } else { int value = l.charAt(y * level[0].length + x); if (value < 60) { value -= 48; } else { value -= 87; } if ((value >= 6) && (value <= 9)) { level[y][x] = 0; player = new int[8]; player[0] = x * 30 + 10; player[1] = y * 30 + 10; if (value == 6) { player[3] = 1; } else if (value == 8) { player[3] = -1; } else if (value == 7) { player[2] = 1; } else { player[2] = -1; } } else { level[y][x] = value; } } } } } else if (p[6] <= 0) { if (p[5] > 0) { p[6] = 1; } } else if (p[7] > 0) { if (p[5] > 0) { p[2] += 1; level[0][0] = -1; think += 10000000L; } } else if (p[6] > 0) { if (p[5] > 0) { p[3] += 1; for (int y = 0; y < level.length; y++) { for (int x = 0; x < level[0].length; x++) { if ((level[y][x] >= 15) && (level[y][x] <= 18)) { if (p[5] == 2) { level[y][x] -= 1; } else { level[y][x] += 1; } if (level[y][x] < 15) { level[y][x] = 18; } if (level[y][x] > 18) { level[y][x] = 15; } } else if ((level[y][x] >= 19) && (level[y][x] <= 26)) { level[y][x] += 4; if (level[y][x] > 26) { level[y][x] -= 8; } } } } } if (p[8] > 0) { if (!bStart) { player[4] = player[6] = player[0] + 5; player[5] = player[7] = player[1] + 5; bStart = true; } else { if ((player[2] < 0) || (player[3] < 0)) { player[4] = player[0] + 5; player[5] = player[1] + 5; } else { player[6] = player[0] + 5; player[7] = player[1] + 5; } } } if (p[9] > 0) { p[8] = p[9] = 0; bStart = false; } int oldX = (player[0] + 5)/30; int oldY = (player[1] + 5)/30; player[0] = player[0] + player[2]; player[1] = player[1] + player[3]; int newX = (player[0] + 5)/30; int newY = (player[1] + 5)/30; if ((player[2] != 0) && (player[4] > 0) && (!bStart)) { if ((player[5] != player[7]) && (player[4] == player[0] + 5) && (player[5] < player[1]) && (player[1] < player[7])) { player[2] = -player[2]; player[4] = 0; } else if ((player[5] == player[7]) && (player[5] == player[1] + 5) && (player[4] < player[0] + 5) && (player[0] + 5 < player[6])) { player[4] = 0; } } if ((player[3] != 0) && (player[4] > 0) && (!bStart)) { if ((player[4] != player[6]) && (player[5] == player[1] + 5) && (player[4] < player[0]) && (player[0] < player[6])) { player[3] = -player[3]; player[4] = 0; } else if ((player[4] == player[6]) && (player[4] == player[0] + 5) && (player[5] < player[1] + 5) && (player[1] + 5 < player[7])) { player[4] = 0; } } if ((level[newY][newX] >= 11) && (level[newY][newX] <= 22)) { if (player[2] < 0) { if (((level[newY][newX] == 12) || (level[newY][newX] == 16) || (level[newY][newX] == 20)) && (newX * 30 + 15 == player[0] + 5)) { player[2] = 0; player[3] = -1; if (p[8] > 0) player[4] = 0; } if (((level[newY][newX] == 13) || (level[newY][newX] == 17) || (level[newY][newX] == 21)) && (newX * 30 + 15 == player[0] + 5)) { player[2] = 0; player[3] = 1; if (p[8] > 0) player[4] = 0; } if (((level[newY][newX] == 14) || (level[newY][newX] == 11) || (level[newY][newX] == 18) || (level[newY][newX] == 15) || (level[newY][newX] == 22) || (level[newY][newX] == 19)) && (newX * 30 + 15 <= player[0] + 5)) { player[2] = 1; player[3] = 0; if (p[8] > 0) player[4] = 0; } } else if (player[2] > 0) { if (((level[newY][newX] == 11) || (level[newY][newX] == 15) || (level[newY][newX] == 19)) && (newX * 30 + 15 == player[0] + 5)) { player[2] = 0; player[3] = -1; if (p[8] > 0) player[4] = 0; } if (((level[newY][newX] == 14) || (level[newY][newX] == 18) || (level[newY][newX] == 22)) && (newX * 30 + 15 == player[0] + 5)) { player[2] = 0; player[3] = 1; if (p[8] > 0) player[4] = 0; } if (((level[newY][newX] == 12) || (level[newY][newX] == 13) || (level[newY][newX] == 16) || (level[newY][newX] == 17) || (level[newY][newX] == 20) || (level[newY][newX] == 21)) && (newX * 30 + 15 >= player[0] + 5)) { player[2] = -1; player[3] = 0; if (p[8] > 0) player[4] = 0; } } else if (player[3] > 0) { if (((level[newY][newX] == 11) || (level[newY][newX] == 15) || (level[newY][newX] == 19)) && (newY * 30 + 15 == player[1] + 5)) { player[2] = -1; player[3] = 0; if (p[8] > 0) player[4] = 0; } if (((level[newY][newX] == 12) || (level[newY][newX] == 16) || (level[newY][newX] == 20)) && (newY * 30 + 15 == player[1] + 5)) { player[2] = 1; player[3] = 0; if (p[8] > 0) player[4] = 0; } if (((level[newY][newX] == 13) || (level[newY][newX] == 14) || (level[newY][newX] == 17) || (level[newY][newX] == 18) || (level[newY][newX] == 21) || (level[newY][newX] == 22)) && (newY * 30 + 15 >= player[1] + 5)) { player[2] = 0; player[3] = -1; if (p[8] > 0) player[4] = 0; } } else if (player[3] < 0) { if (((level[newY][newX] == 13) || (level[newY][newX] == 17) || (level[newY][newX] == 21)) && (newY * 30 + 15 == player[1] + 5)) { player[2] = 1; player[3] = 0; if (p[8] > 0) player[4] = 0; } if (((level[newY][newX] == 14) || (level[newY][newX] == 18) || (level[newY][newX] == 22)) && (newY * 30 + 15 == player[1] + 5)) { player[2] = -1; player[3] = 0; if (p[8] > 0) player[4] = 0; } if (((level[newY][newX] == 11) || (level[newY][newX] == 12) || (level[newY][newX] == 15) || (level[newY][newX] == 16) || (level[newY][newX] == 19) || (level[newY][newX] == 20)) && (newY * 30 + 15 <= player[1] + 5)) { player[2] = 0; player[3] = 1; if (p[8] > 0) player[4] = 0; } } } else if ((newX * 30 + 15 == player[0] + 5) && (newY * 30 + 15 == player[1] + 5)) { if (level[newY][newX] == 29) { level[newY][newX] = 0; } else if ((level[newY][newX] == 27) || (level[newY][newX] == 28)) { for (int y = 0; y < level.length; y++) { for (int x = 0; x < level[0].length; x++) { if ((x != newX) || (y != newY)) { if (level[newY][newX] == level[y][x]) { player[0] = x * 30 + 10; player[1] = y * 30 + 10; break; } } } } } } if ((oldX != newX) || (oldY != newY)) { if ((level[newY][newX] == 1) || (level[newY][newX] == 10)) { player[2] = -player[2]; player[3] = -player[3]; if (p[8] > 0) player[4] = 0; if (level[newY][newX] == 10) level[newY][newX] = 0; } if ((level[newY][newX] >= 2) && (level[newY][newX] <= 5)) { level[0][0] = -1; think += 10000000L; } /*else if (((level[newY][newX] >= 11) && (level[newY][newX] <= 22)) && (p[5] == 0)) { // if (p[8] > 0) player[4] = 0; // if (player[2] < 0) { // if ((level[newY][newX] == 11) || (level[newY][newX] == 14) || (level[newY][newX] == 15) || (level[newY][newX] == 18) || (level[newY][newX] == 19) || (level[newY][newX] == 22)) { // player[2] = -player[2]; // } // } // if (player[2] > 0) { // if ((level[newY][newX] == 12) || (level[newY][newX] == 13) || (level[newY][newX] == 16) || (level[newY][newX] == 17) || (level[newY][newX] == 20) || (level[newY][newX] == 21)) { // player[2] = -player[2]; // } // } // if (player[3] < 0) { // if ((level[newY][newX] == 11) || (level[newY][newX] == 12) || (level[newY][newX] == 15) || (level[newY][newX] == 16) || (level[newY][newX] == 19) || (level[newY][newX] == 20)) { // player[3] = -player[3]; // } // } // if (player[3] > 0) { // if ((level[newY][newX] == 13) || (level[newY][newX] == 14) || (level[newY][newX] == 17) || (level[newY][newX] == 18) || (level[newY][newX] == 21) || (level[newY][newX] == 22)) { // player[3] = -player[3]; // } // } }*/ } boolean bWin = true; for (int y = 0; y < level.length; y++) { for (int x = 0; x < level[0].length; x++) { if (level[y][x] == 29) { bWin = false; } } } if (bWin) { p[7] = 1; } } p[4] = p[5] = 0; } lastTime = now; // Renderabschnitt // Hintergrund malen g.setColor(Color.GRAY); g.fillRect(0, 30, 470, 490); g.setColor(Color.LIGHT_GRAY); g.fillRect(0, 0, 469, 30); g.setColor(Color.DARK_GRAY); g.drawRect(0, 0, 469, 30); g.setFont(g.getFont().deriveFont(20f).deriveFont(1)); String s = "ApoChange4k"; int w = g.getFontMetrics().stringWidth(s); g.drawString(s, 235 - w/2, 25); g.setFont(g.getFont().deriveFont(15f).deriveFont(1)); s = "level: "+String.valueOf(p[2] + 1)+" / "+String.valueOf(levels.length); g.drawString(s, 10, 25); s = "clicks: "+String.valueOf(p[3]); w = g.getFontMetrics().stringWidth(s); g.drawString(s, 460 - w, 25); if ((p[7] > 0) || (p[6] <= 0)) { g.setColor(Color.LIGHT_GRAY); g.fillRect(0, 479, 469, 40); g.setColor(Color.DARK_GRAY); g.drawRect(0, 479, 469, 40); if (p[7] > 0) { s = "Congratulation!"; w = g.getFontMetrics().stringWidth(s); g.drawString(s, 235 - w/2, 496); s = "Click to start the next level"; p[0] = 0; } else { s = "Click to start the level"; } w = g.getFontMetrics().stringWidth(s); g.drawString(s, 235 - w/2, 516 - p[0]); p[0] = 10; } else { s = ""; if (p[2] == 0) { s = "Click the mouse to rotate the red tile"; } else if (p[2] == 1) { s = "Avoid the spikes"; } else if (p[2] == 8) { s = "Press the right mousebutton to draw a line"; } if (s.length() > 0) { g.setColor(Color.LIGHT_GRAY); g.fillRect(0, 479, 469, 40); g.setColor(Color.DARK_GRAY); g.drawRect(0, 479, 469, 40); w = g.getFontMetrics().stringWidth(s); g.drawString(s, 235 - w/2, 516 - p[0]); } } g.setStroke(new BasicStroke(3)); for (int y = -level.length; y < level.length; y++) { for (int x = 0; x < level[0].length; x++) { if (y < 0) { if ((level[y + level.length][x] > 5) || (level[y + level.length][x] == 0)) { g.setColor(Color.LIGHT_GRAY); g.fillRect(x * 30 + p[0], (y + level.length) * 30 + p[1], 30, 30); } continue; } g.setColor(Color.DARK_GRAY); if (level[y][x] == 1) { if ((y - 1 >= 0) && ((level[y-1][x] < 1) || (level[y-1][x] >= 6))) { g.drawLine(x * 30 + p[0], y * 30 + p[1], (x + 1) * 30 + p[0], y * 30 + p[1]); } if ((y + 1 < level.length) && ((level[y+1][x] < 1) || (level[y+1][x] >= 6))) { g.drawLine(x * 30 + p[0], (y+1) * 30 + p[1], (x + 1) * 30 + p[0], (y+1) * 30 + p[1]); } if ((x - 1 >= 0) && ((level[y][x-1] < 1) || (level[y][x-1] >= 6))) { g.drawLine((x) * 30 + p[0], y * 30 + p[1], (x) * 30 + p[0], (y + 1) * 30 + p[1]); } if ((x + 1 < level[0].length) && ((level[y][x+1] < 1) || (level[y][x+1] >= 6))) { g.drawLine((x + 1) * 30 + p[0], y * 30 + p[1], (x + 1) * 30 + p[0], (y + 1) * 30 + p[1]); } } if (level[y][x] == 10) { g.setColor(Color.DARK_GRAY); g.fillRoundRect(x * 30 + p[0] + 2, y * 30 + p[1] + 2, 26, 26, 5, 5); g.setColor(Color.GRAY); g.drawRoundRect(x * 30 + p[0] + 2, y * 30 + p[1] + 2, 26, 26, 5, 5); } if (level[y][x] == 27) { g.setColor(Color.CYAN); g.fillOval(x * 30 + p[0] + 5, y * 30 + p[1] + 5, 20, 20); } if (level[y][x] == 29) { g.setColor(Color.YELLOW); g.drawOval(x * 30 + p[0] + 10, y * 30 + p[1] + 10, 10, 10); } if ((level[y][x] == 2) || (level[y][x] == 4)) { int change = 1; if (level[y][x] == 4) { change = 0; } g.drawLine(x * 30 + p[0], (y+change) * 30 + p[1], x * 30 + p[0] + 3, (y+change) * 30 + p[1]); g.drawLine(x * 30 + p[0] + 3, (y+change) * 30 + p[1], x * 30 + p[0] + 9, (y+change) * 30 + p[1] + 5); g.drawLine(x * 30 + p[0] + 17, (y+change) * 30 + p[1] - 5, x * 30 + p[0] + 9, (y+change) * 30 + p[1] + 5); g.drawLine(x * 30 + p[0] + 17, (y+change) * 30 + p[1] - 5, x * 30 + p[0] + 24, (y+change) * 30 + p[1] + 3); g.drawLine(x * 30 + p[0] + 27, (y+change) * 30 + p[1], x * 30 + p[0] + 24, (y+change) * 30 + p[1] + 3); g.drawLine(x * 30 + p[0] + 27, (y+change) * 30 + p[1], x * 30 + p[0] + 30, (y+change) * 30 + p[1]); } if ((level[y][x] == 3) || (level[y][x] == 5)) { int change = 1; if (level[y][x] == 5) { change = 0; } g.drawLine((x+change) * 30 + p[0], (y) * 30 + p[1], (x+change) * 30 + p[0], (y) * 30 + p[1] + 3); g.drawLine((x+change) * 30 + p[0] + 5, (y) * 30 + p[1] + 9, (x+change) * 30 + p[0], (y) * 30 + p[1] + 3); g.drawLine((x+change) * 30 + p[0] + 5, (y) * 30 + p[1] + 9, (x+change) * 30 + p[0] - 5, (y) * 30 + p[1] + 17); g.drawLine((x+change) * 30 + p[0], (y) * 30 + p[1] + 27, (x+change) * 30 + p[0] - 5, (y) * 30 + p[1] + 17); g.drawLine((x+change) * 30 + p[0], (y) * 30 + p[1] + 27, (x+change) * 30 + p[0], (y) * 30 + p[1] + 30); } if (level[y][x] >= 15) g.setColor(Color.RED); if (level[y][x] >= 19) g.setColor(new Color(37, 109, 29)); if (level[y][x] >= 23) g.setColor(new Color(37, 109, 29, 40)); if ((level[y][x] == 11) || (level[y][x] == 15) || (level[y][x] == 19) || (level[y][x] == 23)) { g.drawLine((x + 1) * 30 + p[0] - 5, y * 30 + p[1] + 5, (x + 1) * 30 + p[0] - 5, (y + 1) * 30 + p[1] - 5); g.drawLine(x * 30 + 5 + p[0], (y+1) * 30 + p[1] - 5, (x + 1) * 30 + p[0] - 5, (y+1) * 30 + p[1] - 5); g.drawLine(x * 30 + p[0] + 5, (y+1) * 30 + p[1] - 5, (x + 1) * 30 + p[0] - 5, (y) * 30 + p[1] + 5); } if ((level[y][x] == 12) || (level[y][x] == 16) || (level[y][x] == 20) || (level[y][x] == 24)) { g.drawLine((x) * 30 + p[0] + 5, y * 30 + p[1] + 5, (x) * 30 + p[0] + 5, (y + 1) * 30 + p[1] - 5); g.drawLine(x * 30 + 5 + p[0], (y+1) * 30 + p[1] - 5, (x + 1) * 30 + p[0] - 5, (y+1) * 30 + p[1] - 5); g.drawLine(x * 30 + p[0] + 5, (y) * 30 + p[1] + 5, (x + 1) * 30 + p[0] - 5, (y + 1) * 30 + p[1] - 5); } if ((level[y][x] == 13) || (level[y][x] == 17) || (level[y][x] == 21) || (level[y][x] == 25)) { g.drawLine((x) * 30 + p[0] + 5, y * 30 + p[1] + 5, (x) * 30 + p[0] + 5, (y + 1) * 30 + p[1] - 5); g.drawLine(x * 30 + 5 + p[0], (y) * 30 + p[1] + 5, (x + 1) * 30 + p[0] - 5, (y) * 30 + p[1] + 5); g.drawLine((x + 1) * 30 + p[0] - 5, (y) * 30 + p[1] + 5, (x) * 30 + p[0] + 5, (y + 1) * 30 + p[1] - 5); } if ((level[y][x] == 14) || (level[y][x] == 18) || (level[y][x] == 22) || (level[y][x] == 26)) { g.drawLine((x + 1) * 30 + p[0] - 5, y * 30 + p[1] + 5, (x + 1) * 30 + p[0] - 5, (y + 1) * 30 + p[1] - 5); g.drawLine(x * 30 + 5 + p[0], (y) * 30 + p[1] + 5, (x + 1) * 30 + p[0] - 5, (y) * 30 + p[1] + 5); g.drawLine((x) * 30 + p[0] + 5, (y) * 30 + p[1] + 5, (x + 1) * 30 + p[0] - 5, (y + 1) * 30 + p[1] - 5); } } } if (player[4] > 0) { g.drawLine(player[4] + p[0], player[5] + p[1], player[6] + p[0], player[7] + p[1]); } g.setStroke(new BasicStroke(1)); g.setColor(Color.YELLOW); g.fillOval(player[0] + p[0], player[1] + p[1], 10, 10); g.setColor(Color.DARK_GRAY); g.drawOval(player[0] + p[0], player[1] + p[1], 10, 10); if (p[6] == 0) { if (player[2] > 0) { g.drawLine(player[0] + p[0] + 10, player[1] + p[1] + 5, player[0] + p[0] + 20 + 5, player[1] + p[1] + 5); } else if (player[2] < 0) { g.drawLine(player[0] + p[0], player[1] + p[1] + 5, player[0] + p[0] - 20 + 5, player[1] + p[1] + 5); } else if (player[3] > 0) { g.drawLine(player[0] + p[0] + 5, player[1] + p[1] + 10, player[0] + p[0] + 5, player[1] + p[1] + 20 + 5); } else if (player[3] < 0) { g.drawLine(player[0] + p[0] + 5, player[1] + p[1], player[0] + p[0] + 5, player[1] + p[1] - 20 + 5); } } // 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) { if (e.getID() == KeyEvent.KEY_PRESSED) { KeyEvent event = (KeyEvent) e; if (event.getKeyCode() == KeyEvent.VK_SPACE) { p[8] = 1; } } if (e.getID() == KeyEvent.KEY_RELEASED) { KeyEvent event = (KeyEvent) e; if (event.getKeyCode() == KeyEvent.VK_SPACE) { p[9] = 1; } if (event.getKeyCode() == KeyEvent.VK_ALT) { p[5] = 2; } if (event.getKeyCode() == KeyEvent.VK_N) { p[2] += 1; level[0][0] = -1; } if (event.getKeyCode() == KeyEvent.VK_P) { p[2] -= 1; level[0][0] = -1; } if (event.getKeyCode() == KeyEvent.VK_R) { level[0][0] = -1; } } if (e.getID() == MouseEvent.MOUSE_MOVED) { MouseEvent event = (MouseEvent) e; p[0] = event.getX(); p[1] = event.getY(); } if (e.getID() == MouseEvent.MOUSE_PRESSED) { MouseEvent event = (MouseEvent) e; if ((event.getButton() == MouseEvent.BUTTON1) || (event.getButton() == MouseEvent.BUTTON2)) { p[4] = 1; p[5] = 0; } else { p[8] = 1; } } if (e.getID() == MouseEvent.MOUSE_RELEASED) { MouseEvent event = (MouseEvent) e; if (event.getButton() == MouseEvent.BUTTON1) { p[4] = 0; p[5] = 1; } else if (event.getButton() == MouseEvent.BUTTON2) { p[4] = 0; p[5] = 2; } else { p[9] = 1; } } } }