Results 1 to 3 of 3
 05112012, 07:50 PM #1Member
 Join Date
 Apr 2012
 Posts
 6
 Rep Power
 0
working on a pacman game need help
I'm working on a pacman game and I'm having some problems .
first of all when the enemy is passing the pacman nothing happens while it is supposed to less the lives of the pacman and sometimes it less the lives of the pacman but the enemy hasn't pass the pacman .
the second problem is this that in the easy mode the enemy should understand if the pacman is near it in four around places it works first that I just add it for one way but when I add it for all four possible ways it is not doing it .
in the medium mode the enemy should search the five next places in each possible way ( I mean right , left , up and down ) to see if the pacman is at those places follow it but it cannot do it .
OK . Let's take a look at my code :
this is the part that I'm trying to reduce from the lives of the pacman :
Java Code:if ( (en1.x == x && en1.y == y)  (en2.x == x && en2.y == y)  (en3.x == x && en3.y == y)) { lives; x = 15 ; y = 10 ; System.out.println("you die"); if ( lives == 0){ new GameOver() ; } }
Java Code:public class MidiumEnemy extends Thread{ int x ; int y ; int dir ; Random r = new Random() ; MidiumPanel p ; public MidiumEnemy (int x , int y ,MidiumPanel p) { this.x = x ; this.y = y ; this.p = p ; dir = 3 ; } public void run () { while (true) { if (dir == 3) { if (p.map[y1][x] != 1 && p.enemy[y1][x] == false) { for (int i = 1 ; i < 6 ; i++) { if (p.pacman[y][xi] == true) { if (x == 0) x = 19 ; dir = 1 ; } else if (p.pacman[y][x+i] == true) { if (x == 19) x = 0 ; dir = 2 ; } else if (p.pacman[y+1][x] == true) { if (y == 19) y = 0 ; dir = 4 ; // if (y == 19) y = 0 ; } else break ; }//end of for p.enemy[y][x] = false ; y; p.enemy[y][x] = true ; if (y == 0) y = 19 ; }//end of if (p.map) else dir = Math.abs(r.nextInt())%4+1; }// end of if dir ==3 if (dir == 4) { if (p.map[y+1][x] != 1 && p.enemy[y+1][x] == false) { for (int i = 1 ; i < 6 ; i++) { if (p.pacman[y][xi] == true) { if (x == 0) x = 19 ; dir = 1 ; } else if (p.pacman[y][x+1] == true) { if (x == 19) x = 0 ; dir = 2 ; } else if (p.pacman[y1][x] == true) { if (y == 0) y = 19 ; dir = 3 ; } else break ; }// end of for p.enemy[y][x] = false ; y++; p.enemy[y][x] = true ; if (y == 19) y = 0 ; }// end of if p.map else dir = Math.abs(r.nextInt())%4+1; }// end of if dir == 4 if (dir == 1) { if (p.map[y][x1] != 1 && p.enemy[y][x1] == false) { for (int i = 1 ; i < 6 ; i++) { if (p.pacman[y][x+i] == true) { if (x == 19) x = 0 ; dir = 2 ; } else if (p.pacman[yi][x] == true) { if (y == 0) y = 19 ; dir = 3 ; } else if (p.pacman[y+i][x] == true) { if (y == 19) y = 0 ; dir = 4 ; } else break ; }//end of for p.enemy[y][x] = false ; x; p.enemy[y][x] = true ; if (x == 0) x = 19 ; }// end of if p.map else dir = Math.abs(r.nextInt())%4+1; }//end of if dir ==1 if (dir == 2) { if (p.map[y][x + 1] != 1 && p.enemy[y][x+1] == false) { for ( int i = 1 ; i < 6 ; i++) { if (p.pacman[y][xi] == true) { if (x == 0) x = 19 ; dir = 1 ; } else if (p.pacman[yi][x] == true) { if (y == 0) y = 19 ; dir = 3 ; } else if (p.pacman[y+i][x] == true) { if (y == 19) y = 0 ; dir = 4 ; } else break ; }//end of for p.enemy[y][x] = false ; x++; p.enemy[y][x] = true ; if (x == 19) x = 0 ; }//end of if p.map else dir = Math.abs(r.nextInt())%4+1; }// end of if dir ==2 try { sleep(150) ; } catch (InterruptedException e) { // TODO Autogenerated catch block e.printStackTrace(); } }// end of while }// end of run }
 06032012, 05:45 PM #2Member
 Join Date
 Jan 2012
 Posts
 18
 Rep Power
 0
Re: working on a pacman game need help
Could you tell me what en1, 2 and 3 are? For example, is it a Rectangle,etc.?
 06042012, 11:04 AM #3Member
 Join Date
 Apr 2012
 Posts
 6
 Rep Power
 0
Similar Threads

Working on a Pacman game using threads but don't know how .
By paris72 in forum Java GamingReplies: 3Last Post: 05092012, 10:35 AM 
Pacman Game
By Hollowsoul in forum Java 2DReplies: 13Last Post: 07172011, 12:31 AM 
Making PacMan game, need help!
By Mondos in forum Java GamingReplies: 14Last Post: 06032011, 04:24 PM 
Huge problem. PacMan game.
By Bullfrog in forum New To JavaReplies: 3Last Post: 06012010, 03:39 PM 
need help with pacman game!!
By Newbie_Javaer in forum New To JavaReplies: 2Last Post: 10222009, 03:44 PM
Bookmarks