View Game: ApoSn4ke

ApoSn4ke (http://www.apo-games.de/apoSn4ke/)

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

ApoSn4ke is an awesome addictive puzzle game!

Eat with your snakes all coins. If a wall is
blocking you ... no problem if your snake has
another color you can eat and move through the wall.

You like the game?
Ten try the big version ( http://www.apo-games.de/apoSnake/ ) or the android version ( https://play.google.com/store/apps/details?id=net.apogames.aposnake )

Instructions

Play the game with the cursor keys.

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.RenderingHints; import java.awt.event.KeyEvent; import java.awt.image.BufferedImage; public class V extends Applet implements Runnable { /** * 0 = free * 1 = head red left * 2 = head red down * 3 = head red right * 4 = head red up * 5 = red coin * 6 = red wall * 7 = head blue left * 8 = head blue down * 9 = head blue right * a = head blue up * b = blue coin * c = blue wall * d = head green left * e = head green down * f = head green right * g = head green up * h = green coin * i = green wall * * 19 = rot Wand (ex Schlange) * 20 = blau Wand (ex Schlange) * 21 = grüne Wand (ex Schlange) */ private final String[] levels = new String[] { "de"+ "0000"+ "0660"+ "0650"+ "0666"+ "0001", // "de"+ // "5555"+ // "0666"+ // "5005"+ // "6660"+ // "3555", "ed"+ "56000"+ "56b65"+ "06060"+ "0h064", "gd"+ "5056b0b"+ "0606060"+ "0606660"+ "4650b6b", "ee"+ "50005"+ "06560"+ "05450"+ "06560"+ "50005", "cchi5c36b5b", "cf"+ "0bc"+ "0c0"+ "bab"+ "545"+ "060"+ "650", "ddebbb6ii656b5b65i", // "ge"+ // "00bcb0b"+ // "0ccccc0"+ // "00b666b"+ // "ccccbcb"+ // "000646a", "efcihiccccccbiiibbigibiiiiibbabb", "fhb000000ccccc0cbbbb0cbc2b0cbabb0cb6bb00ccc50cbbbb", "gg00c0c000hhhhh0chihihc0hhghh0chihihc0hhhhh000c0c00", "eg"+ "05450"+ "06660"+ "06060"+ "05550"+ "5ccc5"+ "66566"+ "06460", "ggh60006h60i0i0660ihi0650hgh0560ihi0660i0i06h60006h", "ee5i5cb6i6c6hi5c56i6c6hi5c4", "gghcbbbchhc666chhc646chhc666chhcbabchhccccchicbbbci", "hc"+ "06b60c5c"+ "b5456b0b"+ "06b60c5c", "ee5b5b6b5b6b5b6b566b5bg65b5", "dffh655h666655b6546666ihhh", "eeh25bhb6i659cbc7hi6ib5bhg5", "cjch15ch9bchc5cbd5ch3bchc5ch75ch", "edcccechcbchcc6h00h4i5", "eebh5b65666bc626hcb6hiabihi", "ggbhb5hbhh8iciebbciciihh66666bbcc6cchh6c4c6bbh555bh", "ic65chc5chi3c5bcb5cd6hc5chc5i", "hechb565hb566cbi61h5iib6c7bbbcbi6dh665hbbi", "ee05cb00hc50cc20b59c560ihih", "fe"+ "b555bc"+ "b565bc"+ "b455ac"+ "h666ch"+ "i6555i", "fd855558b6ii6b55cc555h665h", "ghibehicbbb656bhbiei6bib666bcbb666bcb0cac6hhb06bcbbcba0ci5", "ehc666i6bbb6hacb56bbb5hi6i56b6b4h626icb6bi", "fe"+ "c5c556"+ "cbbcii"+ "h6b6ie"+ "h4a5ii"+ "h655bb", }; /** * p[0] == aktuelles Level * p[1] == aktuelle Moveanzahl * p[2] == level geloest * p[3] == change X Levelsize * p[4] == change Y Levelsize * p[5] == left key * p[6] == down key * p[7] == right key * p[8] == up key * p[9] == some key pressed */ private final int[] p = new int[10]; private int[][] level; public void start() { enableEvents(AWTEvent.KEY_EVENT_MASK); new Thread(this).start(); } public void run() { // setSize(480, 480); // für den AppletViewer // Graphische Grundlagen für das Double Buffering BufferedImage screen = new BufferedImage(480,480,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 = new int[1][1]; level[0][0] = -1; int[][] players = new int[3][50]; int schlange = 0; // 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] < 0) { p[0] = levels.length - 1; } if (p[0] >= levels.length) { p[0] = 0; } String l = levels[p[0]]; int width = l.substring(0, 1).charAt(0) - 96; int height = l.substring(1, 2).charAt(0) - 96; level = new int[height][width]; p[2] = 0; p[1] = 0; // count the snakes in the level int count = 0; for (int y = 0; y < level.length; y++) { for (int x = 0; x < level[0].length; x++) { int value = l.charAt(y * level[0].length + x + 2); if (value < 60) { value -= 48; } else { value -= 87; } if ((value >= 1) && (value <= 4)) { } else if ((value >= 7) && (value <= 10)) { value -= 6; } else if ((value >= 13) && (value <= 16)) { value -= 12; } if ((value >= 1) && (value <= 4)) { count += 1; } } } players = new int[count][100]; schlange = 0; for (int y = 0; y < level.length; y++) { for (int x = 0; x < level[0].length; x++) { int value = l.charAt(y * level[0].length + x + 2); if (value < 60) { value -= 48; } else { value -= 87; } int w = 0; if ((value >= 1) && (value <= 4)) { } else if ((value >= 7) && (value <= 10)) { w = 1; value -= 6; } else if ((value >= 13) && (value <= 16)) { w = 2; value -= 12; } else { level[y][x] = value; } if ((value >= 1) && (value <= 4)) { String add = String.valueOf(value) + String.valueOf(w); if (x < 10) { add += "0"; } add += x; if (y < 10) { add += "0"; } add += y; // System.out.println("Schlange: "+schlange+" "+add); players[schlange][0] = Integer.valueOf(add); schlange += 1; } } } p[3] = (480 - level[0].length * 30)/2; p[4] = (480 - level.length * 30)/2; } else if ((p[2] > 0) && (p[9] > 0)) { p[0] += 1; level[0][0] = -1; think += 10000000L; } else { int addJump = 0; boolean[] bPlayerJump = new boolean[players.length]; if ((p[5] > 0) || (p[6] > 0) || (p[7] > 0) || (p[8] > 0)) { for (int z = 0; z < 2; z++) { for (int i = 0; i < players.length; i++) { if (bPlayerJump[i]) { continue; } if (i >= schlange) { continue; } int value = players[i][0]; String s = String.valueOf(value); value = Integer.valueOf(s.substring(0, 1)); int color = Integer.valueOf(s.substring(1, 2)); int x = Integer.valueOf(s.substring(2, 4)); int y = Integer.valueOf(s.substring(4, 6)); int checkX = x; int checkY = y; if (p[5] > 0) { checkX = x - 1; } else if (p[7] > 0) { checkX = x + 1; } else if (p[6] > 0) { checkY = y + 1; } else if (p[8] > 0) { checkY = y - 1; } if ((value == 1) && (p[7] > 0)) { continue; } if ((value == 2) && (p[8] > 0)) { continue; } if ((value == 3) && (p[5] > 0)) { continue; } if ((value == 4) && (p[6] > 0)) { continue; } boolean bJump = false; int add = 1; while ((checkX >= 0) && (checkY >= 0) && (checkX < level[0].length) && (checkY < level.length)) { boolean bBreak = false; boolean bIsThere = false; for (int l = 0; l < players.length; l++) { if (l < schlange) { String os = String.valueOf(players[l][0]); int otherX = Integer.valueOf(os.substring(2, 4)); int otherY = Integer.valueOf(os.substring(4, 6)); if (l != i) { if ((otherX == checkX) && (otherY == checkY)) { bBreak = true; bJump = false; break; } } int otherColor = Integer.valueOf(os.substring(1, 2)); for (int k = 1; k < players[l].length; k++) { if (players[l][k] == 0) break; os = String.valueOf(players[l][k]); otherX = Integer.valueOf(os.substring(2, 4)); otherY = Integer.valueOf(os.substring(4, 6)); if ((otherX == checkX) && (otherY == checkY)) { if (otherColor == color) { bBreak = true; break; } else { bIsThere = true; break; } } } } } if (bBreak) { break; } if (bIsThere) { } else if ((level[checkY][checkX] == 0) || (level[checkY][checkX] == 5) || (level[checkY][checkX] == 11) || (level[checkY][checkX] == 17)) { bJump = true; if (level[checkY][checkX] == 5) { color = 0; } else if (level[checkY][checkX] == 11) { color = 1; } else if (level[checkY][checkX] == 17) { color = 2; } if (level[checkY][checkX] == 0) { add = 0; } break; } else if (color == 0) { if ((level[checkY][checkX] == 6) || (level[checkY][checkX] == 19)) { break; } } else if (color == 1) { if ((level[checkY][checkX] == 12) || (level[checkY][checkX] == 20)) { break; } } else if (color == 2) { if ((level[checkY][checkX] == 18) || (level[checkY][checkX] == 21)) { break; } } if (p[5] > 0) { checkX -= 1; } else if (p[7] > 0) { checkX += 1; } else if (p[6] > 0) { checkY += 1; } else if (p[8] > 0) { checkY -= 1; } } if (bJump) { bPlayerJump[i] = true; addJump = 1; String newValue = "5" + String.valueOf(players[i][0]).substring(1); players[i][0] = Integer.valueOf(newValue); if (checkX < x) { for (int k = x - 1; k >= checkX; k--) { int v = 5; if (k == checkX) { v = 1; } a(k, y, players, String.valueOf(v) + String.valueOf(color), i); } } if (checkX > x) { for (int k = x + 1; k <= checkX; k++) { int v = 5; if (k == checkX) { v = 3; } a(k, y, players, String.valueOf(v) + String.valueOf(color), i); } } if (checkY < y) { for (int k = y - 1; k >= checkY; k--) { int v = 5; if (k == checkY) { v = 4; } a(x, k, players, String.valueOf(v) + String.valueOf(color), i); } } if (checkY > y) { for (int k = y + 1; k <= checkY; k++) { int v = 5; if (k == checkY) { v = 2; } a(x, k, players, String.valueOf(v) + String.valueOf(color), i); } } int max = 0; for (int t = 1; t < players[i].length - 1; t++) { if (players[i][t] <= 0) { break; } max = t; String curS = String.valueOf(players[i][t]); players[i][t] = Integer.valueOf(curS.substring(0, 1) + String.valueOf(color) + curS.substring(2)); } if (add <= 0) { players[i][max] = 0; } boolean bWin = true; for (y = 0; y < level.length; y++) { for (x = 0; x < level[0].length; x++) { if ((level[y][x] == 5) || (level[y][x] == 11) || (level[y][x] == 17)) { bWin = false; break; } } if (!bWin) { break; } } if (bWin) { p[2] = 1; } } } } p[1] += addJump; } } for (int i = 5; i < 10; i++) { p[i] = 0; } } lastTime = now; // Renderabschnitt // Hintergrund malen g.setColor(Color.LIGHT_GRAY); g.fillRect(0,0,480,480); int changeX = p[3]; int changeY = p[4]; for (int y = 0; y < level.length; y++) { for (int x = 0; x < level[0].length; x++) { g.setColor(new Color(215, 215, 215)); g.fillRect(changeX + x * 30, changeY + y * 30, 30, 30); if ((level[y][x] == 5) || (level[y][x] == 11) || (level[y][x] == 17)) { g.setColor(Color.RED); if (level[y][x] == 11) { g.setColor(Color.BLUE); } else if (level[y][x] == 17) { g.setColor(Color.GREEN); } g.fillOval(changeX + 10 + x * 30, changeY + 10 + y * 30, 10, 10); g.setColor(Color.BLACK); g.drawOval(changeX + 10 + x * 30, changeY + 10 + y * 30, 10, 10); } if ((level[y][x] == 6) || (level[y][x] == 12) || (level[y][x] == 18)) { g.setColor(Color.RED.darker()); if (level[y][x] == 12) { g.setColor(Color.BLUE.darker()); } else if (level[y][x] == 18) { g.setColor(Color.GREEN.darker()); } g.fillRect(changeX + 4 + x * 30, changeY + 4 + y * 30, 22, 22); g.setColor(g.getColor().darker()); g.fillRect(changeX + 8 + x * 30, changeY + 8 + y * 30, 15, 15); g.setColor(Color.BLACK); g.drawRect(changeX + 4 + x * 30, changeY + 4 + y * 30, 22, 22); } if ((level[y][x] == 19) || (level[y][x] == 20) || (level[y][x] == 21)) { Color c = Color.RED.brighter().brighter(); if (level[y][x] == 20) { c = Color.BLUE.brighter().brighter(); } if (level[y][x] == 21) { c = Color.GREEN.brighter().brighter(); } g.setColor(c); g.fillOval(changeX + x * 30 + 2, changeY + y * 30 + 2, 25, 25); g.setColor(Color.BLACK); g.drawOval(changeX + x * 30 + 2, changeY + y * 30 + 2, 25, 25); } } } for (int i = 0; i < players.length; i++) { for (int p = players[i].length - 1; p >= 0; p--) { if (players[i][p] <= 0) continue; String s = String.valueOf(players[i][p]); int w = Integer.valueOf(s.substring(1, 2)); int x = Integer.valueOf(s.substring(2, 4)); int y = Integer.valueOf(s.substring(4, 6)); int nextX = -1; int nextY = -1; if (p > 0) { s = String.valueOf(players[i][p - 1]); if (s.length() >= 6) { nextX = Integer.valueOf(s.substring(2, 4)); nextY = Integer.valueOf(s.substring(4, 6)); } } Color c = new Color(255, 90, 90); if (w == 1) { c = Color.BLUE.brighter(); } if (w == 2) { c = Color.GREEN.brighter(); } if (p == 0) { g.setColor(c); } else { g.setColor(c.brighter()); } if (nextX >= 0) { if (nextX < x) { g.fillOval(changeX + nextX * 30 + 21, changeY + nextY * 30 + 6, 18, 18); } if (nextX > x) { g.fillOval(changeX + nextX * 30 - 9, changeY + nextY * 30 + 6, 18, 18); } if (nextY < y) { g.fillOval(changeX + nextX * 30 + 6, changeY + nextY * 30 + 21, 18, 18); } if (nextY > y) { g.fillOval(changeX + nextX * 30 + 6, changeY + nextY * 30 - 9, 18, 18); } } g.setColor(Color.BLACK); if (nextX >= 0) { if (nextX < x) { g.drawOval(changeX + nextX * 30 + 21, changeY + nextY * 30 + 6, 18, 18); } if (nextX > x) { g.drawOval(changeX + nextX * 30 - 9, changeY + nextY * 30 + 6, 18, 18); } if (nextY < y) { g.drawOval(changeX + nextX * 30 + 6, changeY + nextY * 30 + 21, 18, 18); } if (nextY > y) { g.drawOval(changeX + nextX * 30 + 6, changeY + nextY * 30 - 9, 18, 18); } } } } for (int i = 0; i < players.length; i++) { for (int p = players[i].length - 1; p >= 0; p--) { if (players[i][p] <= 0) continue; Color c = Color.BLACK; String s = String.valueOf(players[i][p]); int value = Integer.valueOf(s.substring(0, 1)); int w = Integer.valueOf(s.substring(1, 2)); int x = Integer.valueOf(s.substring(2, 4)); int y = Integer.valueOf(s.substring(4, 6)); c = Color.RED.brighter(); if (w == 1) { c = new Color(0, 90, 255); } if (w == 2) { c = new Color(90, 255, 0); } if (p == 0) { g.setColor(c); } else { g.setColor(c.brighter()); } g.fillOval(changeX + x * 30 + 2, changeY + y * 30 + 2, 25, 25); g.setColor(Color.BLACK); g.drawOval(changeX + x * 30 + 2, changeY + y * 30 + 2, 25, 25); if (value == 1) { g.fillRect(changeX + x * 30 + 2, changeY + y * 30 + 11, 9, 3); g.fillRect(changeX + x * 30 + 2, changeY + y * 30 + 16, 9, 3); } if (value == 3) { g.fillRect(changeX + (x + 1) * 30 - 11, changeY + y * 30 + 11, 9, 3); g.fillRect(changeX + (x + 1) * 30 - 11, changeY + y * 30 + 16, 9, 3); } if (value == 2) { g.fillRect(changeX + (x) * 30 + 11, changeY + (y + 1) * 30 - 11, 3, 9); g.fillRect(changeX + (x) * 30 + 16, changeY + (y + 1) * 30 - 11, 3, 9); } if (value == 4) { g.fillRect(changeX + (x) * 30 + 11, changeY + (y) * 30 + 2, 3, 9); g.fillRect(changeX + (x) * 30 + 16, changeY + (y) * 30 + 2, 3, 9); } } } g.setColor(Color.GRAY); g.fillRect(0,0,480,25); g.fillRect(0,455,480,25); g.setFont(g.getFont().deriveFont(18.0f).deriveFont(1)); g.setColor(Color.black); g.drawRect(changeX, changeY, level[0].length * 30, level.length * 30); String s = "ApoSn4ke"; g.drawString(s, 240 - g.getFontMetrics().stringWidth(s)/2 + 1, 20); g.setColor(Color.white); g.drawString(s, 240 - g.getFontMetrics().stringWidth(s)/2, 18); s = "Level "+(p[0] + 1)+" / "+levels.length; g.setColor(Color.black); g.drawString(s, 5 + 1, 20); g.setColor(Color.white); g.drawString(s, 5, 18); s = "Moves: "+p[1]; g.setColor(Color.black); g.drawString(s, (475-g.getFontMetrics().stringWidth(s)) + 1, 20); g.setColor(Color.white); g.drawString(s, (475-g.getFontMetrics().stringWidth(s)), 18); s = "(R)estart"; g.setColor(Color.black); g.drawString(s, (475-g.getFontMetrics().stringWidth(s)) + 1, 475); g.setColor(Color.white); g.drawString(s, (475-g.getFontMetrics().stringWidth(s)), 473); s = "(N)ext"; g.setColor(Color.black); g.drawString(s, 5, 475); g.setColor(Color.white); g.drawString(s, 5, 473); if (p[2] > 0) { g.setFont(g.getFont().deriveFont(35.0f)); s = "Congratulation!"; g.setColor(Color.black); g.drawString(s, (480 - g.getFontMetrics().stringWidth(s)) / 2 + 1, 113); g.setColor(Color.white); g.drawString(s, (480 - g.getFontMetrics().stringWidth(s)) / 2, 111); s = "Press any key to continue"; g.setColor(Color.black); g.drawString(s, (480 - g.getFontMetrics().stringWidth(s)) / 2 + 1, 383); g.setColor(Color.white); g.drawString(s, (480 - g.getFontMetrics().stringWidth(s)) / 2, 381); } // else { // s = ""; // if (p[0] == 0) { // s = "Eat all coins to solve the level"; // } else if (p[0] == 1) { // s = "You are what you eat!"; // } else if (p[0] == 2) { // s = "You can eat what you aren't!"; // } else if (p[0] == 3) { // s = "Press 'r' to restart a level!"; // } else if (p[0] == 5) { // s = "You control all snakes at once!"; // } else if (p[0] == 9) { // s = "You can eat parts of a snake if the color is different!"; // } // if (s.length() > 0) { // g.setColor(Color.GRAY); // int x = (480 - g.getFontMetrics().stringWidth(s)) / 2; // g.fillRect(x - 10,420,g.getFontMetrics().stringWidth(s) + 20,30); // // g.setColor(Color.black); // g.drawString(s, x + 1, 443); // g.setColor(Color.white); // g.drawString(s, x, 441); // } // } // 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; } } } private final String a(int x, int y, int[][] players, String s, int i) { String newValue = ""; if (x < 10) { newValue += "0"; } newValue += x; if (y < 10) { newValue += "0"; } newValue += y; for (int j = 0; j < players.length; j++) { for (int l = 1; l < players[j].length; l++) { if (players[j][l] == 0) break; String os = String.valueOf(players[j][l]); int otherColor = Integer.valueOf(os.substring(1, 2)); int otherX = Integer.valueOf(os.substring(2, 4)); int otherY = Integer.valueOf(os.substring(4, 6)); if ((otherX == x) && (otherY == y)) { for (int f = players[j].length - 1; f >= l; f--) { if (players[j][f] == 0) continue; os = String.valueOf(players[j][f]); int removeX = Integer.valueOf(os.substring(2, 4)); int removeY = Integer.valueOf(os.substring(4, 6)); level[removeY][removeX] = 19 + otherColor; players[j][f] = 0; } break; } } } level[y][x] = 0; for (int t = players[i].length - 1; t > 0; t--) { if (players[i][t-1] > 0) { players[i][t] = players[i][t-1]; } } players[i][0] = Integer.valueOf(s + newValue); return newValue; } @Override public void processEvent(AWTEvent e) { if (e.getID() == KeyEvent.KEY_PRESSED) { KeyEvent event = (KeyEvent) e; if (event.getKeyCode() == KeyEvent.VK_LEFT) { p[5] = 1; } if (event.getKeyCode() == KeyEvent.VK_RIGHT) { p[7] = 1; } if (event.getKeyCode() == KeyEvent.VK_DOWN) { p[6] = 1; } if (event.getKeyCode() == KeyEvent.VK_UP) { p[8] = 1; } p[9] = 1; } if (e.getID() == KeyEvent.KEY_RELEASED) { KeyEvent event = (KeyEvent) e; if (event.getKeyCode() == KeyEvent.VK_N) { p[0] += 1; level[0][0] = -1; } if (event.getKeyCode() == KeyEvent.VK_P) { p[0] -= 1; level[0][0] = -1; } if (event.getKeyCode() == KeyEvent.VK_R) { level[0][0] = -1; } } } }