Top Banner
Spong Bluetooth game Developed by: Erik Matzols Fredrik Lindberg
18

Spong Bluetooth game Developed by: Erik Matzols Fredrik Lindberg.

Dec 31, 2015

Download

Documents

Jody Small
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Spong Bluetooth game Developed by: Erik Matzols Fredrik Lindberg.

Spong Bluetooth game

Developed by:

Erik Matzols

Fredrik Lindberg

Page 2: Spong Bluetooth game Developed by: Erik Matzols Fredrik Lindberg.

Spong game

• Uses the J-82 API for bluetooth communication• Uses J4ME library to eliminate some

annoyances with the J2ME UI.• Each player controls a paddle and need to

prevent the ball from falling from the playing field• The winner is the one who has managed to

score most points. The point limit is decided by the one who host the game

Page 3: Spong Bluetooth game Developed by: Erik Matzols Fredrik Lindberg.

Supported Devices

• Need MIDP-2.0 and CLDC-1.1

• Screen resolution of 240x320.

• Game will run fine on other resolutions that support the other criterias but size of graphics content will affect gameplay.

Page 4: Spong Bluetooth game Developed by: Erik Matzols Fredrik Lindberg.

J4ME

• Able to set a theme for the entire application.

• Have some basic ”form” capability and able to have custom backgrounds.

• Only uses a small fraction of the library for automatic button placement and automatic scrolling of text on the instruction page.

• Check it out on http://code.google.com/p/j4me/

Page 5: Spong Bluetooth game Developed by: Erik Matzols Fredrik Lindberg.

Spong game: Main menu

The main menu has four selections.

• New game - will bring you to a new page for selection of hosting or joining a game.

• Options – Set your nickname,servername and the points limit when you act as server.

• Instruction – show a text with instruction how to play the game.

• Quit – Obvious.

Page 6: Spong Bluetooth game Developed by: Erik Matzols Fredrik Lindberg.

Spong game: Instructions

• Scrollbar to the left if text is larger than the screen height.

• Back button to return to main menu

Page 7: Spong Bluetooth game Developed by: Erik Matzols Fredrik Lindberg.

Spong game: Options

• Data is stored in a permanent record store

• Nickname is sent when establishing connection

Page 8: Spong Bluetooth game Developed by: Erik Matzols Fredrik Lindberg.

Spong game: Host/Join

Page 9: Spong Bluetooth game Developed by: Erik Matzols Fredrik Lindberg.

Spong Game: Selecting server

• Multiple servers to select from if multiple hosts exist

Page 10: Spong Bluetooth game Developed by: Erik Matzols Fredrik Lindberg.

Spong Game: Game session

• Client commands are sent to server and processed

• Server sends new state to client that the client renders

Page 11: Spong Bluetooth game Developed by: Erik Matzols Fredrik Lindberg.

The Code

• The game consists of 17 classes

• Spong, SpongModel, Menu, BluetoothClient, BluetoothServer, GameSession,Paddle, Ball .....

Page 12: Spong Bluetooth game Developed by: Erik Matzols Fredrik Lindberg.

Spong,SpongModel

• Spong - A public class extends MIDlet. Spong creates an instance of the class SpongModel when the method startApp() is called.

• SpongModel - A public class that contains the BluetoothClient,BluetoothServer Menu and GameSession instances. Its responsibility is to contain and communicate with the various objects such as the Menu, Bluetoothserver , BluetoothClient and the GameSession.

Page 13: Spong Bluetooth game Developed by: Erik Matzols Fredrik Lindberg.

Menu

• Menu – A public class that extends Dialog which is a J4ME class that implements some simple ”form” functionality. The Menu consists of several classes that implements the submenus.

• The buttons are a custom item that can change its color if it is selected. A variable in each menu keeps track of the current selected button.

Page 14: Spong Bluetooth game Developed by: Erik Matzols Fredrik Lindberg.

BluetoothServer,BluetoothClient

• BluetoothServer – A public class that implements Runnable. It will wait in a blocking thread until a connection has been accepted or the user presses the cancel button which will call the stop() method for the BluetoothServer thread.

• BluetoothClient – A public class that implements DiscoveryListener and Runnable. Implements the DiscoveryListener interface to be able to query other Bluetoothdevices and return a list of connectable devices to the user. The user can at any time press the canel button and terminate the search.

• Both BluetoothClient and BluetoothServer communicates with the SpongModel via callbacks.

Page 15: Spong Bluetooth game Developed by: Erik Matzols Fredrik Lindberg.

GameSession

GameSession• Implements Runnable and Canvas.• Created after a connection has been made. • Creates paddle and ball and draws all game graphics.• Determines who act as server based on a variable sent

to constructor.• Reads keypresses into a keyState.• Server has authority and simulates the ball and does

collision detection.• Client send its input to the server which in turn send a

new state for the paddles and balls to the client so it can render the new state.

Page 16: Spong Bluetooth game Developed by: Erik Matzols Fredrik Lindberg.

Paddle , Ball

• Paddle – Represents the paddle the user controls. Is a serializable object that can be sent over the bluetooth connection

• Ball – Represents the ball. Is a serializable object that can be sent over the bluetooth connection.

Page 17: Spong Bluetooth game Developed by: Erik Matzols Fredrik Lindberg.

The homepage

• Adapts to different screen sizes.

• OTA support for the game Spong.

• Uses WURFL to check if device is capable of running the game.

• A Flash Lite demo of the game

• Check it out http://www.nada.kth.se/~matzols/

Page 18: Spong Bluetooth game Developed by: Erik Matzols Fredrik Lindberg.

The End