MyGameGUI - Stav-Nof/The-Maze-of-Waze-part3 GitHub Wiki

This class represents the graphic interface of the Game.


MyGameGUI class methods:

  • getLevel- returns the level of this game.
  • setLevel- set the level of this game.
  • openWindow- Sets the size of the Window of the game.
  • drawGraph- This method draws the graph. In more details, this function draws the graph with certain scales that we defined in the function, gets the location of each Node , draws them and draws there edges on the Window. This method also sets colors and all what is linked to graphics and visualization of the graph.
  • drawFruit- This method gets each Fruit (the string , which is the path to a picture) and draws it on the graph by getting its location and its image.
  • drawrobots- This method gets each Robot (the string , which is the path to a picture) and draws it on the graph by getting its location and its image.
  • drawTime- This method make a visualization of the time while the game is running.
  • initGameServer - This method inits the Game from the server.

** In the MyGameGUI class, there is an inner class which is Game Server and those are its methods : **

  • manualGame- This method enables the user to choose which level he wants to play. Depending on the level, the graph will be loaded with its fruits and Robots. In this mode, the user can choose from where he wants to move the robots to. This method will use other methods in order to set everything in place.

  • automaticGame- Automatically runs the game by doing many different actions.The graphic interface gives the player to choose wich level he would like to play,all the rest is automatically decided by the server. We can see in this method that we call the server in order to move the robots and the fruits. Mostly, the game is ran by the help of the server.

  • addManualRobots- Like its name says, this method enables the user to add Robots manually. The function allow the user to place the robots on a specific node by giving it's key number.

  • levelSelect- Returns an integer and allows the user to select a specific level from the 24 levels existing.

  • startGameManual- This methods is used by the manualGame function above, it enables the user to select a destination node to go to.

  • startGameautomatic- This methods is used by the automaticGame function above, this function will start the game and every action is done automatically : how the robots move, how the fruits are set on the graph ,etc...

  • moveGame- This method is one of the components in order to refresh the screen while the game is Running.

  • nextNode- This method calculates to which node each robot has to go to.

  • runGame- Using the StdDraw class and sets the Graph, its timer , robots , fruits and at the end shows the Graphic interface with all its components.

  • end- When the game ends, this method will show on the screen a "game end message" and how much points were gained during the game.

  • addAutomaticlRobots- This method adds Robots automatically to the graph. It is used in the automaticGame method above. Depending on the location of each fruit on the graph, the robot will be set on the graph in order to get the highest score.

  • run- If the selected mode was "manual", the threads in charge will be in action to run the game in manual mode. If the selected mode was automatic, the game will run through different threads.

  • yourScore- This method displays on the graphic interface the level that the player is currently at, the function calls to the currentStage function (from score class) in order to get the stage. According to the id entered, the function will return the current level.

  • globalScore- This function shows, for each stage and according to the ID entered, the position of this player compared to the other players in the class.