j2me: tic tac toe

13
J2ME: Tic Tac Toe By Jud Porter and John Tat

Upload: quanda

Post on 05-Jan-2016

76 views

Category:

Documents


1 download

DESCRIPTION

J2ME: 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 - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: J2ME: Tic Tac Toe

J2ME: Tic Tac ToeJ2ME: Tic Tac Toe

By Jud Porter and John TatBy Jud Porter and John Tat

Page 2: J2ME: Tic Tac Toe

Goals for ProjectGoals for Project

Design and implement multiplayer game Network connectivity between mobile

devices Keep scoring for the game Implement a cursor to select positions

Design and implement multiplayer game Network connectivity between mobile

devices Keep scoring for the game Implement a cursor to select positions

Page 3: J2ME: Tic Tac Toe

Why Tic Tac Toe?Why Tic Tac Toe?

Simple game to implement Framework can be used to implement more

complex game Designed and implemented in J2ME

Java Micro Edition Wireless Toolkit 2.2

Generic toolkit instead of vendor specific Better chance of working on a variety of devices

Simple game to implement Framework can be used to implement more

complex game Designed and implemented in J2ME

Java Micro Edition Wireless Toolkit 2.2

Generic toolkit instead of vendor specific Better chance of working on a variety of devices

Page 4: J2ME: Tic Tac Toe

J2ME and Wireless ToolkitJ2ME 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

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

Page 5: J2ME: Tic Tac Toe

Tic Tac Toe ClassesTic Tac Toe Classes

TacTacToeMidlet First class that runs Allows the user to select between Client and Server

Creates a new instance of Client or Server depending on choice

TicTacToeCanvas Drawing of the board Key Pressed Check for winner Keeps track of scores Updates opponents pieces

TacTacToeMidlet First class that runs Allows the user to select between Client and Server

Creates a new instance of Client or Server depending on choice

TicTacToeCanvas Drawing of the board Key Pressed Check for winner Keeps track of scores Updates opponents pieces

Page 6: J2ME: Tic Tac Toe

Tic Tac Toe Classes Cont’dTic Tac Toe Classes Cont’d

TicTacToeServer Creates instance of TicTacToeCanvas 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

TicTacToeClient Creates instance of TicTacToeCanvas class Communication scheme with server Wait for server to move

receives the integer and places a piece accordingly onto the board

TicTacToeServer Creates instance of TicTacToeCanvas 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

TicTacToeClient Creates instance of TicTacToeCanvas class Communication scheme with server Wait for server to move

receives the integer and places a piece accordingly onto the board

Page 7: J2ME: Tic Tac Toe

Game StructureGame Structure

Page 8: J2ME: Tic Tac Toe

Communication SchemeCommunication 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 InputStream and OutputStream are opened when server

discovers the client or client finds server Two way 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 InputStream and OutputStream are opened when server

discovers the client or client finds server Two way communication scheme

Page 9: J2ME: Tic Tac Toe

Communication SchemeCommunication 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

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

Page 10: J2ME: Tic Tac Toe

TicTacToeCanvasTicTacToeCanvas Paint

Draws board Draws pieces Draws cursor

SetPiece Stores client/server moves Change turns

keyPressed Moves the cursor on the screen Selects the board position and sends it to the client/server

CheckWinner Checks for a winner

Reset Resets the board for both client and server

Paint Draws board Draws pieces Draws cursor

SetPiece Stores client/server moves Change turns

keyPressed Moves the cursor on the screen Selects the board position and sends it to the client/server

CheckWinner Checks for a winner

Reset Resets the board for both client and server

Page 11: J2ME: Tic Tac Toe

Server/Client ScreenshotsServer/Client Screenshots

Page 12: J2ME: Tic Tac Toe

Game ScreenshotsGame Screenshots

Page 13: J2ME: Tic Tac Toe

Winner ScreenshotsWinner Screenshots