-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ddcafe5
commit 3133549
Showing
12 changed files
with
336 additions
and
214 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,26 @@ | ||
# <p align="center">PacMan</p> | ||
|
||
<p align="center"> | ||
<img width="400" src="https://i.postimg.cc/bvYx7yWB/Capture.png"> | ||
<img width="400" src="https://i.postimg.cc/xT4kvKnd/Capture-Ds.png"> | ||
</p> | ||
|
||
### About | ||
|
||
The game was made using [Processing](https://processing.org). | ||
For ghosts I used A* algorithm. | ||
|
||
The rules are pretty straight forward : eat the food , don't be the food. | ||
The rules are pretty straight forward : eat the food , don't be the food. | ||
|
||
I think I finished this game. I kinda make this game harder to play than I thought... but it works. I tried to make it look very similar with the original game : the map, the ghosts behavior and I added the path each one is following. | ||
For more information about the original game check the credits below. | ||
|
||
### What's New? | ||
* A nice looking path | ||
* Ghost interaction with Pacman | ||
* Weak Mode for ghosts | ||
* Auto return to home when a ghost is eaten by Pacman | ||
* Few bugs fixed | ||
* New ghost | ||
* Ghosts behavior improved | ||
|
||
### Credits | ||
* [CodeBullet](https://www.youtube.com/channel/UC0e3QhIYukixgh5VVpKHH9Q) | ||
* [GeeksForGeeks](https://www.geeksforgeeks.org) | ||
* [Wikipedia](https://en.wikipedia.org/wiki/Pac-Man) | ||
* [DEV](https://dev.to/code2bits/pac-man-patterns--ghost-movement-strategy-pattern-1k1a) | ||
* [TodayIFoundOut](http://www.todayifoundout.com/index.php/2015/10/ghosts-pac-man-work/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// blinky alway chase pacman | ||
// TODO Cruise Elroy (speed increasing) | ||
class Blinky extends Ghost { | ||
Blinky(int i, int j){ | ||
super(i, j); | ||
super.currentCell = array.get(i).get(j); | ||
} | ||
|
||
public void search() { | ||
|
||
if(super.x % sc == 0 && super.y % sc == 0){ | ||
super.i = (int)super.y / sc; | ||
super.j = (int)super.x / sc; | ||
|
||
super.currentCell = array.get(super.i).get(super.j); | ||
|
||
// when is weak and can be eaten by pacman it choses a random cell | ||
if( (super.isWeak || super.isRecovering ) && super.isAffectedBy ){ | ||
|
||
if(super.searchingList.size() <= 2 ){ | ||
if(super.isWeak){ | ||
super.cellToFollow = super.getRandomCell(); | ||
} else if(super.isRecovering){ | ||
super.cellToFollow = super.getRandomCellFromHouse(); | ||
} | ||
} | ||
} | ||
else { | ||
// here is the specific behaviour | ||
super.cellToFollow = pacman.currentCell; | ||
} | ||
|
||
AStar( super.currentCell, super.cellToFollow ); | ||
super.searchingList = path; | ||
|
||
} | ||
super.update(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Clyde search for the tile 8 away from pacman | ||
class Clyde extends Ghost { | ||
private int newSearch = 10; | ||
Clyde(int i, int j){ | ||
super(i, j); | ||
super.currentCell = array.get(i).get(j); | ||
} | ||
|
||
public void search() { | ||
|
||
if(super.x % sc == 0 && super.y % sc == 0){ | ||
super.i = (int)super.y / sc; | ||
super.j = (int)super.x / sc; | ||
|
||
this.newSearch--; | ||
|
||
super.currentCell = array.get(super.i).get(super.j); | ||
|
||
// when is weak and can be eaten by pacman it choses a random cell | ||
if( (super.isWeak || super.isRecovering ) && super.isAffectedBy ){ | ||
this.newSearch = 1; | ||
if(super.searchingList.size() <= 2 ){ | ||
if(super.isWeak){ | ||
super.cellToFollow = super.getRandomCell(); | ||
} else if(super.isRecovering){ | ||
super.cellToFollow = super.getRandomCellFromHouse(); | ||
} | ||
} | ||
} | ||
else { | ||
// here is the specific behaviour | ||
if(this.newSearch == 0){ | ||
super.cellToFollow = super.getCellInFrontOf(12); | ||
this.newSearch = 10; | ||
} | ||
} | ||
|
||
AStar( super.currentCell, super.cellToFollow ); | ||
super.searchingList = path; | ||
|
||
} | ||
super.update(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Inky is dummy | ||
class Inky extends Ghost{ | ||
Inky(int x, int y){ | ||
super(x, y); | ||
} | ||
|
||
public void search() { | ||
|
||
if(super.x % sc == 0 && super.y % sc == 0){ | ||
super.i = (int)super.y / sc; | ||
super.j = (int)super.x / sc; | ||
|
||
super.currentCell = array.get(super.i).get(super.j); | ||
|
||
// when is weak and can be eaten by pacman it choses a random cell | ||
if( (super.isWeak || super.isRecovering ) && super.isAffectedBy ){ | ||
|
||
if(super.searchingList.size() <= 2 ){ | ||
if(super.isWeak){ | ||
super.cellToFollow = super.getRandomCell(); | ||
} else if(super.isRecovering){ | ||
super.cellToFollow = super.getRandomCellFromHouse(); | ||
} | ||
} | ||
} | ||
else { | ||
// here is the specific behaviour | ||
int possibleI = 2 * pacman.i - blinky.i; | ||
int possibleJ = 2 * pacman.j - blinky.j; | ||
// for the explanation of what he follows search it on Google | ||
try{ | ||
if( !array.get(possibleI).get(possibleJ).isWall ) | ||
super.cellToFollow = array.get(possibleI).get(possibleJ); | ||
} catch(Exception e){ | ||
if(super.searchingList.size() <= 2) | ||
super.cellToFollow = super.getRandomCell(); | ||
} | ||
} | ||
|
||
AStar( super.currentCell, super.cellToFollow ); | ||
super.searchingList = path; | ||
|
||
} | ||
super.update(); | ||
} | ||
} |
Oops, something went wrong.