Class LevelCanvas

java.lang.Object
  |
  +--javax.microedition.lcdui.Displayable
        |
        +--javax.microedition.lcdui.Canvas
              |
              +--javax.microedition.lcdui.game.GameCanvas
                    |
                    +--LevelCanvas
All Implemented Interfaces:
java.lang.Runnable

public class LevelCanvas
extends javax.microedition.lcdui.game.GameCanvas
implements java.lang.Runnable

LevelCanvas manages the multiple layers of Sprites and TiledLayers, by controlling the LayerManager, while running the animation beat methods for them. it accepts the keyStates from the handset and also handels many aspects of game play/events

Title: Monkey Madness

Description: Player must run around field, destroying and avoiding bombs, droids and boss!

Copyright: Copyright (c) 2005

Company: Pistachio Monkey


Field Summary
 boolean bossOn
           
 boolean btGame
           
 int canvsBeat
           
 long gameDuration
           
 int level
           
 int levelDroids
           
 int lives
           
 int NumberOfDroids
           
 int points
           
 long startTime
           
 int wallNumber
           
 
Fields inherited from class javax.microedition.lcdui.game.GameCanvas
DOWN_PRESSED, FIRE_PRESSED, GAME_A_PRESSED, GAME_B_PRESSED, GAME_C_PRESSED, GAME_D_PRESSED, LEFT_PRESSED, RIGHT_PRESSED, UP_PRESSED
 
Fields inherited from class javax.microedition.lcdui.Canvas
DOWN, FIRE, GAME_A, GAME_B, GAME_C, GAME_D, KEY_NUM0, KEY_NUM1, KEY_NUM2, KEY_NUM3, KEY_NUM4, KEY_NUM5, KEY_NUM6, KEY_NUM7, KEY_NUM8, KEY_NUM9, KEY_POUND, KEY_STAR, LEFT, RIGHT, UP
 
Method Summary
 void bluetoothGame()
           
 void build()
          there are many items which constiute towards a level that are built upon a random generator, this method flushes and builds the TiledLayer's
 void buildBT()
          builds a bluetooth version of the game, maps and sprites
 boolean collisionPlayerDroid()
          returns true should a player & droid collide
 void draw()
          draws the game to the screen
 Bomb getBomb()
          retuns an instance of the bomb
 Boss getBoss()
          retuns an instance of the boss
 java.util.Vector getDroid()
          retuns an instance of the droid vector
 Field getField()
          retuns an instance of the field
 Player getPlayer()
          retuns an instance of the player
 Powerup getPowerup()
          retuns an instance of the powerup
 void init()
          initates the positions of all the sprites
 void invincible()
          if the player dies, we ant them to become invincible for a period to ensure their safe return to the gaming field. this method calls a timer task to handle this.
 void keyPressed(int keyCode)
          stops the game & returns the user back to the menu should they press a vlaue less than 0
 void kill()
          handels the event of the player being killed. it updates the statitics and readys the player for more action or deatch by passing the display to the GameOverScreen by calling the midlet
 void killTheUndead()
          frequently invisable instances of the Droid can be found during the game, by calling this method we remove all items found within the droid vector
 void layerConstruct()
          constructs all the layers in order
 void layerDroid()
          handels the multiple constructions of droid
 void layerPlayers()
          builds multiple players
 void newGame()
          creats a new game
 void nextLevel()
          prepares the game for the next level
 boolean overlapsBoss(javax.microedition.lcdui.game.Sprite sprite)
           
 boolean overlapsDroid(javax.microedition.lcdui.game.Sprite sprite)
          takse a sprtie droid and compares fowards it with an int of the number of droids
 boolean overlapsDroid(javax.microedition.lcdui.game.Sprite sprite, int count)
          checks to see if the sprite passed overlpas with any of the droids
 boolean overlapsOtherDroid(javax.microedition.lcdui.game.Sprite sprite)
          checks to see if one droid overlaps another
 boolean overlapsPlayer(javax.microedition.lcdui.game.Sprite sprite)
          returns true if the sprite passed collides with with the player sprite
 void playBang()
          Calls the midlet to play an explosion
 void quit()
          quits the game and returns the user to the menu using the midlet
 int random(int size)
          calls the midlet to return a random int limited by the int passed
 void removeLayer(javax.microedition.lcdui.game.Sprite s)
          removes a layer from the manager of the sprite passed
 void run()
          creats a current thread and handels produces a beat to handle the constant drawing and flushing
 void start()
          builds upon the animationThread, starts it and records the start time
 void stop()
          records the gameduration and stops the animationThread
 void vibrate(int millis)
          calls the midlet to vibrate for a passed int in milleseconds
 
Methods inherited from class javax.microedition.lcdui.game.GameCanvas
flushGraphics, flushGraphics, getGraphics, getKeyStates, paint
 
Methods inherited from class javax.microedition.lcdui.Canvas
getGameAction, getKeyCode, getKeyName, hasPointerEvents, hasPointerMotionEvents, hasRepeatEvents, hideNotify, isDoubleBuffered, keyReleased, keyRepeated, pointerDragged, pointerPressed, pointerReleased, repaint, repaint, serviceRepaints, setFullScreenMode, showNotify, sizeChanged
 
Methods inherited from class javax.microedition.lcdui.Displayable
addCommand, getHeight, getTicker, getTitle, getWidth, isShown, removeCommand, setCommandListener, setTicker, setTitle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NumberOfDroids

public int NumberOfDroids

startTime

public long startTime

gameDuration

public long gameDuration

level

public int level

lives

public int lives

points

public int points

wallNumber

public int wallNumber

levelDroids

public int levelDroids

canvsBeat

public int canvsBeat

bossOn

public boolean bossOn

btGame

public boolean btGame
Method Detail

layerConstruct

public void layerConstruct()
constructs all the layers in order


layerDroid

public void layerDroid()
handels the multiple constructions of droid


layerPlayers

public void layerPlayers()
builds multiple players


keyPressed

public void keyPressed(int keyCode)
stops the game & returns the user back to the menu should they press a vlaue less than 0

Overrides:
keyPressed in class javax.microedition.lcdui.Canvas
Parameters:
keyCode - key check for exception to quit, < 0

quit

public void quit()
quits the game and returns the user to the menu using the midlet


kill

public void kill()
handels the event of the player being killed. it updates the statitics and readys the player for more action or deatch by passing the display to the GameOverScreen by calling the midlet


invincible

public void invincible()
if the player dies, we ant them to become invincible for a period to ensure their safe return to the gaming field. this method calls a timer task to handle this.


build

public void build()
there are many items which constiute towards a level that are built upon a random generator, this method flushes and builds the TiledLayer's


buildBT

public void buildBT()
builds a bluetooth version of the game, maps and sprites


killTheUndead

public void killTheUndead()
frequently invisable instances of the Droid can be found during the game, by calling this method we remove all items found within the droid vector


nextLevel

public void nextLevel()
prepares the game for the next level


newGame

public void newGame()
creats a new game


bluetoothGame

public void bluetoothGame()

init

public void init()
initates the positions of all the sprites


overlapsPlayer

public boolean overlapsPlayer(javax.microedition.lcdui.game.Sprite sprite)
returns true if the sprite passed collides with with the player sprite

Parameters:
sprite - sprite object
Returns:
boolean

collisionPlayerDroid

public boolean collisionPlayerDroid()
returns true should a player & droid collide

Returns:
boolean

overlapsDroid

public boolean overlapsDroid(javax.microedition.lcdui.game.Sprite sprite)
takse a sprtie droid and compares fowards it with an int of the number of droids

Parameters:
sprite - a sprite object
Returns:
boolean

overlapsBoss

public boolean overlapsBoss(javax.microedition.lcdui.game.Sprite sprite)

overlapsDroid

public boolean overlapsDroid(javax.microedition.lcdui.game.Sprite sprite,
                             int count)
checks to see if the sprite passed overlpas with any of the droids

Parameters:
sprite - sprite object
count - the number of sprites to count through
Returns:
boolean

overlapsOtherDroid

public boolean overlapsOtherDroid(javax.microedition.lcdui.game.Sprite sprite)
checks to see if one droid overlaps another

Parameters:
sprite - sprite object
Returns:
boolean

start

public void start()
builds upon the animationThread, starts it and records the start time


stop

public void stop()
records the gameduration and stops the animationThread


run

public void run()
creats a current thread and handels produces a beat to handle the constant drawing and flushing

Specified by:
run in interface java.lang.Runnable

getField

public Field getField()
retuns an instance of the field

Returns:
field object

getPowerup

public Powerup getPowerup()
retuns an instance of the powerup

Returns:
powerup object

getBomb

public Bomb getBomb()
retuns an instance of the bomb

Returns:
bomb object

getPlayer

public Player getPlayer()
retuns an instance of the player

Returns:
player object

getBoss

public Boss getBoss()
retuns an instance of the boss

Returns:
boss object

getDroid

public java.util.Vector getDroid()
retuns an instance of the droid vector

Returns:
droid vector

vibrate

public void vibrate(int millis)
calls the midlet to vibrate for a passed int in milleseconds

Parameters:
millis - period of viobration millieseconds

playBang

public void playBang()
Calls the midlet to play an explosion


random

public int random(int size)
calls the midlet to return a random int limited by the int passed

Parameters:
size - limiter for the random generator
Returns:
int random

removeLayer

public void removeLayer(javax.microedition.lcdui.game.Sprite s)
removes a layer from the manager of the sprite passed

Parameters:
s - sprite object

draw

public void draw()
draws the game to the screen