Implementation
Implementation of the project includes two major section as decribed on the design section. The game play and the communication protocol. The user interaction and the logic for the game are included in the game play and the communication protocols including SMS and bluetooth are included in the communication section.
The game play
The central part of the game is a two diamentional array called the board. The board is a 7 by 6 array that contains the player number (either 0 or 1) or the empty valued (in our case 2). This array is used to keep track of which player is currently having the ball in the board. Initially the board is initialized to contain the empty value. When a user dorps a piece in to the board we the user number is set to indicate the piece currently on the board.
The Game Canvas
The major part of the user interface for the game is the GameUICanvas class. It extends the Canvas class in MIDP and implements the event handling and graphical painting functionalies of the game. The canvas class is also responsible for playing multimedia including wav files. The action performed by the game is determined using the protocol type used as communication part.
The SMS protocol
The communication protocol is based on string values. The player who wants to start the game sends invitation to the openent and when the other side recives the message he/she can start the game and send a move. when the invitor recives the move it will make a remote move and wait for the local move to made. The data exchanged contains two integer values spearated by semicollen. The first part identifies the remote palyer and the second part identifies the move made. for example 0;2 means player 0 (the first player ) droped the ball on column 2. This information is used to make a remote move.
The Bluetooth protocol
The game can also be played using bluetooth. The game starts with either server or client mode. If the game starts with server mode it will register a service and make itself discverable. if the game starts in client mode the device tries to find servers, and then look for services. When the service registered with the given UUID is found the client and the server will start stream based connection. Using the connection and using I/O streams we write the game data as described above.
Record Managment
When the users want to exit the game they will be asked to save the game. when the user wants to save the game game state data including player phone number, game board state, score state and other values will be writen to the record managment using byte array I/O. when the user wants to resume the game sms push message will be sent to the openent to start the game and then the users can then resume the game.
SMS push
We have implemented SMS push inorder to resume a game. the game state will be stored in the game record managment and when one of the game oponent wants to resume the game we send sms push to the other player to remotly start the other side's midlet.
Multimedia Implementation.
We have used the MMAPI to play different sounds when the user makes a move and starts a move. We have used the small wav files to play sound.
WURFL Website
We have developed simple php website to use the WURFL xml file along with some apis in php. We have managed to adapt the page to users according to the browser used to access the page. We also included a mechanism to select between the the different versions of the application to provide link to the jad file according to the specification of the device. The script bellow is used to check if the pag is being accessed from a mobile device or not.
<?php
require_once('./wurfl_config.php');
require_once(WURFL_CLASS_FILE);
$myDevice = new wurfl_class($wurfl, $wurfl_agents);
$myDevice->GetDeviceCapabilitiesFromAgent($_SERVER["HTTP_USER_AGENT"]);
if($myDevice->getDeviceCapability('is_wireless_device')){
?>
|