Title: MVC-gameNet High Level
Course: CPS 261: Advanced Java Concepts ~ DL & MM MASTER

MVC-gameNet High Level

Model View Controller(MVC) is an implementation strategy well worth knowing. Your textbook discusses the idea but his examples are lame.

In MVC, we attempt to do the following:

- Model - Create a "Model" class(es)/module(s) that encapsulates the concept of our problem, but doesn't know anything about GUI components, painting the screen, mouse or keyboard inputs.
- User Inputs Controller - Any place we receive inputs such as from a mouse or keyboard should be kept as ignorant as possible about the Model. Any User Inputs should be minimally processed and sent to update the Model.
- Update View - Any User viewables should only concern themselves with creating the output side of the GUI.
- MyUserInterface - In our case, we will have the "User Inputs Controller" and the "Update View" incorporated in the same class. We will call it "MyUserInterface".
- MVC is considered a desireable quality in almost all cases, however, in our case we can only make a networked game if we follow an approach like this.
- I have seen many times where MVC has been a great approach for design.

gameNet Package

We have covered enough concepts to make MVC work for us in a Networking environment. I am providing a "gameNet" package to you for you to experience MVC and create your Networked Game project.

The key concepts needed to implement the gameNet I am providing you are: Threads, Server/Client socket programming, ObjectInputStream/ObjectOutputStreams

Key classes:

- MyGameInput - A class you define which contains the user inputs to be sent to the Game.
- MyGameOuput - A class you define which contains the information sent from the Game for the User Interface to present to the user.
- MyGame - Your Model class
- MyUserInterface - This class will contain the MVC "User Inputs Controller" and "Update View" code
- MyMain - this class contains "main" and is responsible for connecting up all of the pieces.

gameNet examples:

The gameNet package will let you do almost anything you could imagine in a game. The game can have any number of users and the rules of the game are completely written by you. I will show 3 quick demo's of gameNet to give you the range of what you can do. We will look at the code for the first 2 examples later.

Most of the Networked Program Examples can be found in the following link:
Networked Game Collection

- Note that the way I run gameNet, the Server part ends up running on the computer of the first player to initiate the game. It is possible for gameNet to run the Server code on a separate host if we desired, however, the current approach was taken for simplicity.
- guiChat - There is very little code to make this work because guiChat has very few rules and mostly just uses raw gameNet functionality
- TicTacToe - This is closest to the kind of game you might consider doing for your project. The Model encapsulates TicTacToe and implements the concept of 2 players alternating in the game.
- MaizeAndShoot - This is way beyond what I expect out of anyone in this class. This video was made back when I taught in a live class and you can see the various students getting involved in this game. The link below gives you a copy of the ZIP file for the project for this program. The version of gameNet in this project is old and out of date, but still works.
MaizeAndShootZipFile
- The code for all of the examples will be provided, however, the gameNet in MaizeAndShoot is older and out of date.

July 22, 2014 9:43 PM