|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--Mappy
Mappy Playback Library for Java Release 6
Based on MappyJV Release1 14/07/99 (C)1999 Robin
Burrows.
This class allows the playback of
Mappy .FMP files. Current limitations are:
setTransparentColour() before you
call a loadMap() method. It is also important that you set
the screen area that the Map is to be drawn into (via setScreenDimensions()
) before any drawing functions are called.drawForeground()),
therefore you must set the current Map layer before calling any Map layer
methods. .java) file to ease portability. For the
same reason, Mappy has been moved out of it's default package
of com.alienfactory.gaming. Future releases may well begin to
spread accross several classes (over 2000 lines, I mean, come on!).
setTransparentColour(int),
loadMap(File, Component),
setScreenDimensions(Rectangle),
Mappy.Block| Nested Class Summary | |
class |
Mappy.Block
Mappy Block v1.10 This class represents a Block as used by Mappy. |
| Constructor Summary | |
Mappy()
Constructs a new Mappy Playback Library. |
|
| Method Summary | |
void |
addX(int intIncX)
Increments the X coordinate of the current Map layer by the given amount (in pixels). |
void |
addY(int intIncY)
Increments the Y coordinate of the current Map layer by the given amount (in pixels). |
void |
animateBlocks()
Animates all the animation block structures. |
boolean |
collisionDetection(int intX,
int intY)
Performs a collision detection test at the given pixel coordinates using the Block's collision flags. |
void |
drawBackground(java.awt.Graphics gfx,
boolean blnTransparency)
Draws the Blocks' background of the current Map layer. |
void |
drawForeground(java.awt.Graphics gfx,
int intBlockLayer)
Draws the Blocks' foreground of the current Map layer. |
Mappy.Block |
getBlock(int intBlockX,
int intBlockY)
Returns the Block used at the given Block
coordinates, in the current Map layer. |
int |
getBlockHeight()
Returns the height of a Block, in pixels. |
int |
getBlockWidth()
Returns the width of a Block, in pixels. |
int |
getBlockX()
Returns the X coordinate of the current Map layer, in Blocks. |
int |
getBlockY()
Returns the Y coordinate of the current Map layer, in Blocks. |
int |
getCurrentMapLayer()
Returns the current Map layer. |
java.lang.String |
getMapDescription()
Returns a description of the Map. |
int |
getMapHeight()
Returns the total height of the Map, in pixels. |
int |
getMapHeightBlocks()
Returns the total height of the Map, in blocks. |
int |
getMapWidth()
Returns the total width of the Map, in pixels. |
int |
getMapWidthBlocks()
Returns the total width of the Map, in blocks. |
java.awt.Rectangle |
getScreenDimensions()
Returns the screen dimensions. |
int |
getTransparentColour()
Returns the transparent colour used for Block Images in RGB
format. |
int |
getX()
Returns the X coordinate of the current Map layer, in pixels. |
int |
getY()
Returns the Y coordinate of the current Map layer, in pixels. |
void |
loadMap(java.io.File file,
java.awt.Component component)
Loads a .FMP Map from a given File. |
void |
loadMap(java.io.InputStream stream,
java.awt.Component component)
Loads a .FMP Map from a given InputStream. |
void |
loadMap(java.lang.String strFileName,
java.awt.Component component)
Loads a .FMP Map from a given filename. |
void |
loadMAR(java.lang.String strFileName,
int marlyr)
Loads a .MAR map array file called strFileName. |
void |
setBlock(int intBlockX,
int intBlockY,
int intIndex)
Puts the block structure value in the map at the given block coords. |
void |
setCurrentMapLayer(int intMapLayer)
Sets the current Map layer. |
void |
setScreenDimensions(int intX,
int intY,
int intWidth,
int intHeight)
A helper method that sets the screen dimensions. |
void |
setScreenDimensions(java.awt.Rectangle rectangle)
Sets the screen dimensions. |
void |
setTransparentColour(int intNewTransparentColour)
Sets the transparent colour for Block Images. |
void |
setX(int intNewX)
Sets the X coordinate of the current Map layer, in pixels. |
void |
setY(int intNewY)
Sets the Y coordinate of the current Map layer, in pixels. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Mappy()
| Method Detail |
public void setTransparentColour(int intNewTransparentColour)
loadMap() method is
called. Color.black. loadMap().
intNewTransparentColour - the blocks transparent colour in RGB.getTransparentColour(),
loadMap(File, Component),
loadMap(String, Component)public int getTransparentColour()
RGB
format.
setTransparentColour(int)
public void loadMap(java.lang.String strFileName,
java.awt.Component component)
.FMP Map from a given filename. The Mappy class
is rather useless until you load a Map into it!
strFileName - the filename of the Mappy .FMP file.component - this is required to create a compatible image, it
can be a Window or an Applet or any
component really!loadMap(File, Component)
public void loadMap(java.io.File file,
java.awt.Component component)
.FMP Map from a given File. The Mappy
class is rather useless until you load a Map into it!
file - the file of the Mappy .FMP file.component - this is required to create a compatible image, it
can be a Window or an Applet or any
component really!loadMap(InputStream, Component)
public void loadMap(java.io.InputStream stream,
java.awt.Component component)
.FMP Map from a given InputStream. The
Mappy class is rather useless until you load a Map into it!
stream - the InputStream where the .FMP file can be found.component - this is required to create a compatible image, it
can be a Window or an Applet or any
component really!
public void loadMAR(java.lang.String strFileName,
int marlyr)
.MAR map array file called strFileName.
The corresponding FMP map must be loaded first.
strFileName - the name of the .MAR file to loadmarlyr - the number of the layer you want to load topublic java.lang.String getMapDescription()
ATHR chunk of the map, seperated by
new-line ("\n") characters.
public int getMapWidthBlocks()
getMapHeightBlocks()public int getMapHeightBlocks()
getMapWidthBlocks()public int getMapWidth()
getMapHeight()public int getMapHeight()
getMapWidth()public int getBlockWidth()
getBlockHeight()public int getBlockHeight()
getBlockWidth()public void setScreenDimensions(java.awt.Rectangle rectangle)
new Rectangle(0, 0, 640, 480)
.
rectangle - the new screen dimensions.getScreenDimensions()
public void setScreenDimensions(int intX,
int intY,
int intWidth,
int intHeight)
new Rectangle(0, 0, 640, 480)
.
intX - the X coordinate of the screen drawing areaintY - the Y coordinate of the screen drawing areaintWidth - the width of the screen drawing areaintHeight - the height of the screen drawing areagetScreenDimensions()public java.awt.Rectangle getScreenDimensions()
rectangle returned is an independant object, e.g.
altering the rectangle does not affect the Mappy class.
public void setCurrentMapLayer(int intMapLayer)
drawBackground()), so it is
important that this is set first.
intMapLayer - the new current Map layer.getCurrentMapLayer(),
setX(int),
addX(int),
getX(),
setY(int),
addY(int),
getY(),
getBlockX(),
getBlockY()public int getCurrentMapLayer()
drawBackground()), so it is
important that this is set first.
setCurrentMapLayer(int),
setX(int),
addX(int),
getX(),
setY(int),
addY(int),
getY(),
getBlockX(),
getBlockY()public void setX(int intNewX)
intNewX - the new X coordinate of the current Map layer in pixels.addX(int),
getX()public void addX(int intIncX)
setX() so the same
clipping rules apply.
intIncX - what to increment the X coordinate of the current Map
layer by, in pixels (may be negative).setX(int),
getX()public int getX()
getPixelX()
to be more in line with getBlockX().
addX(int),
setX(int),
getBlockX()public void setY(int intNewY)
intNewY - the new Y coordinate of the current Map layer in pixels.addY(int),
getY()public void addY(int intIncY)
setY() so the same
clipping rules apply.
intIncY - what to increment the Y coordinate of the current Map
layer by, in pixels (may be negative).setY(int),
getY()public int getY()
getPixelY()
to be more in line with getBlockY().
addY(int),
setY(int)public int getBlockX()
getX() / getBlockWidth().
getX(),
getBlockWidth(),
getBlock(int, int)public int getBlockY()
getY() / getBlockHeight().
getY(),
getBlockHeight(),
getBlock(int, int)public void animateBlocks()
public void drawBackground(java.awt.Graphics gfx,
boolean blnTransparency)
gfx - the Graphics object that the Map is to drawn on.blnTransparency - whether or not the background is to be drawn
with transparency or not.drawForeground(Graphics, int),
setCurrentMapLayer(int),
setScreenDimensions(Rectangle),
getX(),
getY()
public void drawForeground(java.awt.Graphics gfx,
int intBlockLayer)
intBlockLayer is unknown then an error is logged (not
thrown).
gfx - the Graphics object that the Map is to drawn on.intBlockLayer - the Block's foreground layer to be drawn.drawBackground(Graphics, boolean),
setCurrentMapLayer(int),
setScreenDimensions(Rectangle),
getX(),
getY()
public Mappy.Block getBlock(int intBlockX,
int intBlockY)
Block used at the given Block
coordinates, in the current Map layer. Block is not independant of the Map,
so any changes made to the block are immediatly reflected in the Map.
Also remember that there is not one Block for each given
coordinate but that each coordinate points to a Block.
i.e. Blocks are reused throughout the Map. Block coordinates given are out of range
then an error is logged (not thrown) and null returned.
Block used at the given coordinate.setCurrentMapLayer(int),
getBlockX(),
getBlockY()
public void setBlock(int intBlockX,
int intBlockY,
int intIndex)
public boolean collisionDetection(int intX,
int intY)
Block's collision flags. false is automatically returned.
intX - the pixel X coordinate.intY - the pixel Y coordinate.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||