Skip to content

michael-lemberger/Pacman-Gps-Game

Repository files navigation

Pacman Gps Game

This Github project is an educational example for using git & github as part of the Object Oriented Programming course in Ariel University. The main focus of this project is to allow an online suppoer of Ex2, Ex3, Ex4 which are all related to a GIS like system.

Project content:

1.GIS-

1.a: Game Class- Hold 2 lists of Objects, “Fruit”(1.b) and “Pacman”(1.c). Constructed by receiving a String of an csv file address or by adding objects manually. This class is the main class holding all the information about the game.

1.b: Pacman class- Holds info about a game’s Pacman. Objects: Point3D _p, int _id,double _speed,double _ radius,Path object,Image _img. _img- Image representing the pacman in the game. Path- the points that the pacman traveled on. (will be generated by the main algorithm).

1.c: Fruit class- Holds info about a game’s fruit. Objects: Point3D _p, int _id, Image _img. _img- Image representing the fruit in the game.

1.d: Path class- Hold’s List of “Point3D” object. That list represents the points that a pacman traveled on. Objects: ArrayList.

1.f: PointDis class- An object holding information related to a fruit. (Helpful while using the main algorithm) Objects: double time, Fruit, int pacman_id

1.g: Solution class- print’s score and other information related to a pacman in the midst of a game process. 1.k: Range class- This class represents a straight segment with minimum and maximum points. The class has the following functionality: • isIn function - check if a point is on the line. • dx function - calculates the length of the segment. • proportion function - compute the proportion of value on the range. • percentage - compute the percentage of value on the range. • getMax – get the maximum value on the segment. • getMin – get the minimum value on the segment.

1.l: Map class- This class represents a map of a game board. The map has dimensions of the frame. These dimensions are represented by an Range objects, each map have ranges of coordinates and ranges of image pixels.The class has the following functionality: • gpsToPixel function - converts two pixels to coordinates on the map. • pixelToGps function - converts two coordinates to pixels on the map.

2: Algorithm

2.a: ShortestPathAlgo class- The main algorithm. greedy algorithm, that computes the path every pacman should travel on. first we choose every pacman the closest fruit to him (we save this information inside a “PointDis” object). Next step is comparing the time that takes every pacman to get to his fruit (considering the time getting to the point he is at previous to eating the next fruit[calc_distance function inside “Path” class(1.d)]), the fastest one will eat his fruit. So a new Point is added to this Pacman’s “Path” object. Than we remove the fruit from the list of fruits. (Fruit list copied from “Game” class (1.a)) This process will occur recursively until the list of fruits is empty.

3: file_frormat:

3.a: CsvGameReader class- This class gets a path of a csv file in the computer, read it and convert it to an 2d array of strings using the csvmaker function. This array will be translated into a game with pacmans and fruits.

3.b: CsvGameWriter class- This class makes a csv file from a game object and saves it to the selected folder. If file with the same name is open the class throws exception. When the save done the class print a massage to the consul.

3.c: Path2Kml- This class export a game to a kml file. This file can be displayed on google earth and demonstrate the game movement. To do so this we used https://developers.google.com/kml/documentation/time#gps as a source of information.

4: GUI

4.a: MyFrame class- The graphic user interface(GUI):
shows the game on the screen. Gets a Game object that maintains sets of Pacman and Fruits and can open a saved game we have, saves a game as a CSV file, or as a KML file only if we already started the game; adds fruits by calling AddFruit method, adds pacmans by AddPacman; restarts the game and runs the game so the pacmans start eating the fruit. All the methods appear in the menu bar of the GUI.

4.b: MenuBar:

4.b.I: File- contains:

4.b.I.A: Open: import a CSV file to the Game object and restart a new game.

4.b.I.B: Save:

  1. Save a file as a csv by adding ".csv" to the file name's suffix.

2 . save as a KML file only if we already run the gam. Also by adding ".kml " to the suffix of the file

4.b.II: Game- contains:

4.b.II.A: Add pacman: adding new pacman to the screen, one click to change the location of the pacman two clicks to add it to the game. Once you add a pacman to the game you can't change is location.

4.b.II.B: Add Fruit : the as Add Pacman but on fruits.

4.b.II.C: New Game: cleans the screen from pacmans and fruits and nullify all the game's sets.

4.b.II.D: Run: starts the game by running a thread which runs a ShortestPathAlgo .

5: Threads

5.a: playThread class- runs a ShortestPathAlgo object and afterword calls multiple SinglePacmans threads

5.b: SinglePacmans class - shows the the path of any pacman on the screen in real time and delete any fruit that was eaten from the screen.

5.c: SimplePlayer – plays the background music

About

A Pacman Game with an dijakstra algorithm and Data Base.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages