change sauce und geister ki verändert
							parent
							
								
									b909505fb1
								
							
						
					
					
						commit
						76bb289115
					
				|  | @ -1,3 +1,10 @@ | |||
| /BigPoint.class | ||||
| /Brick.class | ||||
| /Game.class | ||||
| /Ghost.class | ||||
| /Lives.class | ||||
| /Main.class | ||||
| /Map.class | ||||
| /Picture.class | ||||
| /Player.class | ||||
| /Point.class | ||||
|  |  | |||
							
								
								
									
										
											BIN
										
									
								
								bin/Game.class
								
								
								
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/Game.class
								
								
								
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/Ghost.class
								
								
								
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/Ghost.class
								
								
								
								
							
										
											Binary file not shown.
										
									
								
							|  | @ -53,7 +53,6 @@ public class Game { | |||
| 		ImageIcon img = new ImageIcon("assets/Pacman_Right.png"); | ||||
| 		frame.setIconImage(img.getImage()); | ||||
| 
 | ||||
| 
 | ||||
| 		panel = new JPanel(); // darauf werden alle sichtbaren Elemente gespeichert
 | ||||
| 
 | ||||
| 		ghosts = new Ghost[4]; // 4 Geister
 | ||||
|  | @ -147,6 +146,7 @@ public class Game { | |||
| 				} else { | ||||
| 					for (int i = 0; i < ghosts.length; i++) { | ||||
| 						ghosts[i].feared = false; | ||||
| 						ghosts[i].ogSauce(); | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
|  | @ -320,6 +320,32 @@ public class Game { | |||
| 							for (i = 0; i < 4; i++) { | ||||
| 								ghosts[i].feared = true; | ||||
| 								Ghost.fearedTimer = 1000; | ||||
| 								ghosts[i].changeSauce("feared"); | ||||
| 								if (ghosts[i].left) { | ||||
| 									ghosts[i].right = true; | ||||
| 									ghosts[i].left = false; | ||||
| 									ghosts[i].down = false; | ||||
| 									ghosts[i].up = false; | ||||
| 
 | ||||
| 								} else if (ghosts[i].right) { | ||||
| 									ghosts[i].left = true; | ||||
| 									ghosts[i].right = false; | ||||
| 									ghosts[i].down = false; | ||||
| 									ghosts[i].up = false; | ||||
| 
 | ||||
| 								} else if (ghosts[i].down) { | ||||
| 									ghosts[i].up = true; | ||||
| 									ghosts[i].right = false; | ||||
| 									ghosts[i].left = false; | ||||
| 									ghosts[i].down = false; | ||||
| 
 | ||||
| 								} else if (ghosts[i].up) { | ||||
| 									ghosts[i].down = true; | ||||
| 									ghosts[i].right = false; | ||||
| 									ghosts[i].left = false; | ||||
| 									ghosts[i].up = false; | ||||
| 
 | ||||
| 								} | ||||
| 							} | ||||
| 
 | ||||
| 						} | ||||
|  | @ -361,41 +387,38 @@ public class Game { | |||
| 						player.left = false; | ||||
| 					} | ||||
| 			} | ||||
| 			 | ||||
| 		 | ||||
| 		fps = 1000000000 / dt; | ||||
| 
 | ||||
| 		// System.out.println("fps: " + fps);
 | ||||
| 			fps = 1000000000 / dt; | ||||
| 
 | ||||
| 		delay(delaytimer); // Ein delay zum Ende der Hauptschleife
 | ||||
| 			// System.out.println("fps: " + fps);
 | ||||
| 
 | ||||
| 		if (frames % 100 == 0) { | ||||
| 			boolean empty = true; | ||||
| 			for (int i = 0; i < 35; i++) { | ||||
| 				for (int j = 0; j < 35; j++) { | ||||
| 					if (Map.points[j][i] != null) { | ||||
| 						empty = false; | ||||
| 			delay(delaytimer); // Ein delay zum Ende der Hauptschleife
 | ||||
| 
 | ||||
| 			if (frames % 100 == 0) { | ||||
| 				boolean empty = true; | ||||
| 				for (int i = 0; i < 35; i++) { | ||||
| 					for (int j = 0; j < 35; j++) { | ||||
| 						if (Map.points[j][i] != null) { | ||||
| 							empty = false; | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			for (int i = 0; i < 35; i++) { | ||||
| 				for (int j = 0; j < 35; j++) { | ||||
| 					if (Map.bigpoints[j][i] != null) { | ||||
| 						empty = false; | ||||
| 				for (int i = 0; i < 35; i++) { | ||||
| 					for (int j = 0; j < 35; j++) { | ||||
| 						if (Map.bigpoints[j][i] != null) { | ||||
| 							empty = false; | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 				if (empty) { | ||||
| 					scoreLabel.setText("YOU WON"); | ||||
| 					delay(1000); | ||||
| 					System.exit(0); | ||||
| 				} | ||||
| 			} | ||||
| 			if (empty) { | ||||
| 				scoreLabel.setText("YOU WON"); | ||||
| 				delay(1000); | ||||
| 				System.exit(0); | ||||
| 			} | ||||
| 		} | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	 | ||||
| 
 | ||||
| 	// Methode zum verzögern (warten) in ms
 | ||||
| 	public void delay(int time) { | ||||
| 
 | ||||
|  |  | |||
|  | @ -11,26 +11,32 @@ public class Ghost extends Picture { // Die  | |||
| 	public boolean down; | ||||
| 	public boolean left; | ||||
| 	public boolean right; | ||||
| 	 | ||||
| 
 | ||||
| 	public boolean feared = false; | ||||
| 	public static int fearedTimer; | ||||
| 	private double HCost; | ||||
| 	private int type; | ||||
| 
 | ||||
| 	public Ghost(int type) { | ||||
| 		 | ||||
| 		 | ||||
| 
 | ||||
| 		super("Pinky"); // Aufrufen der übergeordneten Klasse
 | ||||
| 		this.type = type; | ||||
| 		// xPos = 150 + 40 * index;
 | ||||
| 
 | ||||
| 		this.ogSauce(); | ||||
| 	} | ||||
| 
 | ||||
| 	public void ogSauce() { | ||||
| 		if (type == 0) { | ||||
| 			this.changeSauce("Blinky"); | ||||
| 		} else if (type == 2) { | ||||
| 			this.changeSauce("Inky"); | ||||
| 		} else if (type == 3) { | ||||
| 			this.changeSauce("Clyde"); | ||||
| 		} else if (type == 1) { | ||||
| 			this.changeSauce("Pinky"); | ||||
| 		} | ||||
| 
 | ||||
| 		 | ||||
| 	} | ||||
| 
 | ||||
| 	public void setPos(char coordinate, int newPos) { | ||||
|  | @ -43,53 +49,53 @@ public class Ghost extends Picture { // Die  | |||
| 
 | ||||
| 	public int getHCost(Player player, int mod_x, int mod_y) { | ||||
| 		if (!feared) { | ||||
| 		if (type == 0) { | ||||
| 			if (type == 0) { | ||||
| 
 | ||||
| 			HCost = (int) Math.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((player.getPos('x', 0) - 10) / 20), 2) | ||||
| 					+ Math.pow((((yPos - 10) / 20) + mod_y) - ((player.getPos('y', 0) - 10) / 20), 2)); | ||||
| 		} else if (type == 1) { | ||||
| 			HCost = (int) Math.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((player.getPos('x', 0) - 10 + 80) / 20), 2) | ||||
| 					+ Math.pow((((yPos - 10) / 20) + mod_y) - ((player.getPos('y', 0) - 10) / 20), 2)); | ||||
| 		} else if (type == 2) { | ||||
| 			HCost = (int) Math.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((300 - 10 + 80) / 20), 2) | ||||
| 					+ Math.pow((((yPos - 10) / 20) + mod_y) - ((100 - 10) / 20), 2)); | ||||
| 		} else if (type == 3) { | ||||
| 			HCost = (int) Math.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((player.getPos('x', 0) - 10) / 20), 2) | ||||
| 					+ Math.pow((((yPos - 10) / 20) + mod_y) - ((player.getPos('y', 0) + 100 - 10) / 20), 2)); | ||||
| 		} | ||||
| 		 | ||||
| 	} | ||||
| 		else { | ||||
| 			HCost =  10 * (1 /  (Math.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((player.getPos('x', 0) - 10) / 20), 2) | ||||
| 				HCost = (int) Math.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((player.getPos('x', 0) - 10) / 20), 2) | ||||
| 						+ Math.pow((((yPos - 10) / 20) + mod_y) - ((player.getPos('y', 0) - 10) / 20), 2)); | ||||
| 			} else if (type == 1) { | ||||
| 				HCost = (int) Math | ||||
| 						.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((player.getPos('x', 0) - 10 + 80) / 20), 2) | ||||
| 								+ Math.pow((((yPos - 10) / 20) + mod_y) - ((player.getPos('y', 0) - 10) / 20), 2)); | ||||
| 			} else if (type == 2) { | ||||
| 				HCost = (int) Math.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((300 - 10 + 80) / 20), 2) | ||||
| 						+ Math.pow((((yPos - 10) / 20) + mod_y) - ((100 - 10) / 20), 2)); | ||||
| 			} else if (type == 3) { | ||||
| 				HCost = (int) Math.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((player.getPos('x', 0) - 10) / 20), 2) | ||||
| 						+ Math.pow((((yPos - 10) / 20) + mod_y) - ((player.getPos('y', 0) + 100 - 10) / 20), 2)); | ||||
| 			} | ||||
| 
 | ||||
| 		} else { | ||||
| 			HCost = 10 * (1 / (Math.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((player.getPos('x', 0) - 10) / 20), 2) | ||||
| 					+ Math.pow((((yPos - 10) / 20) + mod_y) - ((player.getPos('y', 0) - 10) / 20), 2)))); | ||||
| 		} | ||||
| 		 | ||||
| 		return (int) HCost;	 | ||||
| 	 | ||||
| 	 | ||||
| 
 | ||||
| 		return (int) HCost; | ||||
| 
 | ||||
| 	} | ||||
| 
 | ||||
| 	public int getPos(char coordinate, long dt) { // Hier kommt die zuvor erwähnte delta time ins Spiel
 | ||||
| 
 | ||||
| 		if (coordinate == 'x') { // Auslesen der 'x' - Koordinate:
 | ||||
| 			if (left && dt != 0 && Game.frames % 4 == 0) { | ||||
| 				 | ||||
| 					xPos -= 1; | ||||
| 				 | ||||
| 
 | ||||
| 				xPos -= 1; | ||||
| 
 | ||||
| 			} else if (right && dt != 0 && Game.frames % 4 == 0) { | ||||
| 				 | ||||
| 					xPos += 1; | ||||
| 				 | ||||
| 
 | ||||
| 				xPos += 1; | ||||
| 
 | ||||
| 			} | ||||
| 			return (int) xPos; | ||||
| 		} else if (coordinate == 'y') { // Auslesen der 'y' - Koordinate:
 | ||||
| 			if (down && dt != 0 && Game.frames % 4 == 0) { | ||||
| 				 | ||||
| 					yPos += 1; | ||||
| 				 | ||||
| 
 | ||||
| 				yPos += 1; | ||||
| 
 | ||||
| 			} else if (up && dt != 0 && Game.frames % 4 == 0) { | ||||
| 				 | ||||
| 					yPos -= 1; | ||||
| 				 | ||||
| 
 | ||||
| 				yPos -= 1; | ||||
| 
 | ||||
| 			} | ||||
| 			return (int) yPos; // (int)
 | ||||
| 		} else { | ||||
|  |  | |||
|  | @ -1,6 +1,9 @@ | |||
| 
 | ||||
| 
 | ||||
| public class Lives extends Picture{ | ||||
| 	 | ||||
| 	private static final long serialVersionUID = -4715442447789971450L; | ||||
| 
 | ||||
| 	public Lives() { | ||||
| 		super("heart"); | ||||
| 	} | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue