Lab 8
Grid Game is now networked!
We can play multi-player games over the internet.
- Create a directory for this lab, say "lab8"
-
Download to the new directory:
NetGGFramework.zip (V2.0)
V2.0 fixes background loading
Plugins.zip
Now a separate download.
- Unzip the zipfile into the new directory.
- A sample application is provided, called "TTT". Run it by typing:
bin/client.sh TTT
- Enter a player name when prompted.
- Enter the IP address of the server provided in lab by the
instructor
- Click "New Game" and find an opponent.
- Play the game!
Activity
-
Modify TTT to use a background. Here is a sample:
night_stars.jpg
When the game starts, all the cells will be empty.
Display an empty cell as an inverse video plus sign.
-
Invent some logic that allows someone to win,
such as the first person to click in the
lower right hand square. Show "You Win"
or "You Lose" dialog appropriately.
-
Put winner name and date in high scores text file.
- Modify the game rules so that each cell has
a point value. For example,
1 2 3
4 5 6
7 8 9
Modify the status message to show "Score X:Y. Your Turn"
where X is your score and Y is the opponent's score.
(The opponent's score should be obtained from the
opponent via event messages).
- Can you modify the plugin so that the player who
starts a new game gets to choose the board size from
the Preferences dialog, and then that size
board is used by BOTH players?
Resources
NetworkConnection.java (V1.0)
To start a server:
bin/server.sh
To compile and run your plugin,
cd plugins
javac ..:. *.java
cd ..
bin/client.sh
To connect to your local server, select
the default host "localhost".
Then open another terminal window, and start a second client
running with a different username.
Submission
Demonstrate your completed program to the instructor.
Create a zip file containing the plugins folder and the TTT folder.
Submit the zip file via handin
to the "Lab8" folder.
If you have time, you can begin the next activity, which is to
implement an AI client for TicTacToe.