public int[] m_pacMenX;\r
public int[] m_pacMenY;\r
public int[] m_directions;\r
+ public int[] m_pacOriX;\r
+ public int[] m_pacOriY;\r
+ public int[] m_leftLives;\r
+ public int[] m_leftLevels;\r
public int[] m_desX;\r
public int[] m_desY;\r
public int m_paccount;\r
this.m_pacMenX = new int[this.m_nrofpacs];\r
this.m_pacMenY = new int[this.m_nrofpacs];\r
this.m_directions = new int[this.m_nrofpacs];\r
+ this.m_pacOriX = new int[this.m_nrofpacs];\r
+ this.m_pacOriY = new int[this.m_nrofpacs];\r
+ this.m_leftLives = new int[this.m_nrofpacs];\r
+ this.m_leftLevels = new int[this.m_nrofpacs];\r
this.m_desX = new int[this.m_nrofpacs];\r
this.m_desY = new int[this.m_nrofpacs];\r
this.m_paccount = 0;\r
//System.printString("step 2\n");\r
for(int i = 0; i < this.m_nrofpacs; i++) {\r
this.m_pacMenX[i] = this.m_pacMenY[i] = -1;\r
+ this.m_directions[i] = 0;\r
+ this.m_pacOriX[i] = this.m_pacOriY[i] = -1;\r
+ this.m_leftLives[i] = this.m_leftLevels[i] = 0;\r
this.m_desX[i] = this.m_desY[i] = -1;\r
this.m_pacmen[i] = null;\r
}\r
while((!death) && (i < this.m_ghostsX.length)) {\r
if((t.m_locX == this.m_ghostsX[i]) && (t.m_locY == this.m_ghostsY[i])) {\r
death = true;\r
+ t.m_death = true;\r
+ t.m_leftLives--;\r
+ //System.printString("Pacman " + t.m_index + " caught! " + t.m_leftLives + "\n");\r
}\r
i++;\r
}\r
// reach the destination\r
//System.printString("Hit destination!\n");\r
death = true;\r
+ t.m_success = true;\r
+ t.m_leftLevels--;\r
+ //System.printString("Pacman " + t.m_index + " hit, upgrade! " + t.m_leftLevels + "\n");\r
}\r
if(death) {\r
- // pacman caught by ghost\r
- // set pacman as death\r
- t.m_death = true;\r
- // kick it out\r
- //this.m_map[t.y * this.m_nrofblocks + t.x - 1] -= 16;\r
- this.m_deathcount++;\r
- this.m_pacMenX[t.m_index] = -1;\r
- this.m_pacMenY[t.m_index] = -1;\r
+ if(t.isFinish()) {\r
+ // pacman has no more lives or no more levels\r
+ // kick it out\r
+ this.m_deathcount++;\r
+ this.m_pacMenX[t.m_index] = -1;\r
+ this.m_pacMenY[t.m_index] = -1;\r
+ } else {\r
+ if(t.m_death) {\r
+ this.m_leftLives[t.m_index]--;\r
+ } else if(t.m_success) {\r
+ this.m_leftLevels[t.m_index]--;\r
+ }\r
+ t.reset();\r
+ this.m_pacMenX[t.m_index] = t.m_locX;\r
+ this.m_pacMenY[t.m_index] = t.m_locY;\r
+ this.m_directions[t.m_index] = 0;\r
+ //System.printString("Pacman " + t.m_index + " reset: (" + t.m_locX + ", " + t.m_locY + ")\n");\r
+ }\r
}\r
return death;\r
}\r