J 2 ME Tic Tac Toe By Jud
J 2 ME: Tic Tac Toe By Jud Porter and John Tat
Goals for Project § Design and implement multiplayer game § Network connectivity between mobile devices § Keep scoring for the game § Implement a cursor to select positions
Why Tic Tac Toe? § Simple game to implement § Framework can be used to implement more complex game § Designed and implemented in J 2 ME § Java Micro Edition § Wireless Toolkit 2. 2 § Generic toolkit instead of vendor specific § Better chance of working on a variety of devices
J 2 ME and Wireless Toolkit § Device that program is implemented on must be specified § Device implements profile § Profiles are built upon configuration § MIDP 2. 0 § Mobile Information Device Profile 2. 0 § CLDC 1. 1 § Connection Limited Device Configuration 1. 1
Tic Tac Toe Classes § Tac. Toe. Midlet § First class that runs § Allows the user to select between Client and Server § Creates a new instance of Client or Server depending on choice § Tic. Tac. Toe. Canvas § § § Drawing of the board Key Pressed Check for winner Keeps track of scores Updates opponents pieces
Tic Tac Toe Classes Cont’d § Tic. Tac. Toe. Server § Creates instance of Tic. Tac. Toe. Canvas class § Communication scheme with client § First to move § Sends an integer to client of grid selection § Waits to receive integer for client of grid selection § Tic. Tac. Toe. Client § Creates instance of Tic. Tac. Toe. Canvas class § Communication scheme with server § Wait for server to move § receives the integer and places a piece accordingly onto the board
Game Structure
Communication Scheme § Bluetooth § Protocol too difficult for scope of this project § Could not get simple application to work § Other Protocols: Datagram, Socket, COMM § Moved onto Socket Protocol § Endpoint for communication of two devices § Socket connection on port localhost 5000 § Input. Stream and Output. Stream are opened when server discovers the client or client finds server § Two way communication scheme
Communication Scheme § Server has first move § Client waits for server to move § On move (when Fire key is pressed) location of move encoded as integer is sent to other device § On receipt of location, other client now has control of board to send next move
Tic. Tac. Toe. Canvas § Paint § Draws board § Draws pieces § Draws cursor § Set. Piece § Stores client/server moves § Change turns § key. Pressed § Moves the cursor on the screen § Selects the board position and sends it to the client/server § Check. Winner § Checks for a winner § Resets the board for both client and server
Server/Client Screenshots
Game Screenshots
Winner Screenshots
- Slides: 13