Class Sprite
java.lang.Object
|
+----Sprite
- public class Sprite
- extends Object
This class is the heart of this sprite based JAVA game engine.
The "eye" creatures and the "gun" object are derived from this class.
This class is taken directly from the book "Teach yourself
Internet Game Programming with Java in 21 days" by Michael Morrison.
See chapter 6 for details.
-
BA_BOUNCE
- Bounds actions
-
BA_DIE
- Bounds actions
-
BA_STOP
- Bounds actions
-
BA_WRAP
- Bounds actions
-
bounds
-
-
boundsAction
-
-
collision
-
-
component
-
-
frame
-
-
frameDelay
-
-
frameInc
-
-
frameTrigger
-
-
hidden
-
-
image
-
-
position
-
-
SA_ADDSPRITE
- Sprite action flags
-
SA_KILL
- Sprite action flags
-
SA_RESTOREPOS
- Sprite action flags
-
velocity
-
-
zOrder
-
-
Sprite(Component, Image, Point, Point, int, int)
- Sprite constructor method for a single image bitmap with
NO frame animation.
-
Sprite(Component, Image[], int, int, int, Point, Point, int, int)
- Sprite constructor method for an bitmap image that uses multiple
frame animation.
-
addSprite(BitSet)
- Add a Sprite - does nothing ?
-
draw(Graphics)
- Draw the bitmap Sprite image if not hidden
-
getBounds()
- Get the Sprite image collision bounds.
-
getCollision()
- Get the Sprite image collision coordinates.
-
getFrame()
- Get the current animation frame image.
-
getFrameInc()
- Get the current animation frame counter.
-
getImage()
- Get an image object of this class object.
-
getPosition()
- Get the current rectangular position of the Sprite image.
-
getVelocity()
- Get the current velocity of the Sprite image.
-
getZOrder()
- Get the Sprite image z-order position.
-
hide()
- Hide the Sprite from display.
-
incFrame()
- Increment the current animation frame.
-
isPointInside(Point)
- See if a point is inside the Sprite bounding box limits.
-
setBounds(Rectangle)
- Set the Sprite image collision bounds.
-
setCollision()
- Set the Sprite image collision coordinates.
-
setFrameInc(int)
- Set thje current animation frame counter.
-
setImage(Image[])
- Set this classes image object.
-
setPosition(Point)
- Move the current rectangular position of the Sprite image.
-
setPosition(Rectangle)
- Set the current rectangular position of the Sprite image.
-
setVelocity(Point)
- Set the current velocity of the Sprite image.
-
show()
- Set the Sprite to display.
-
testCollision(Sprite)
- Check for collision with another sprite.
-
update()
- This method is the main run-time method for the "Sprite"
class.
SA_KILL
public static final int SA_KILL
- Sprite action flags
SA_RESTOREPOS
public static final int SA_RESTOREPOS
- Sprite action flags
SA_ADDSPRITE
public static final int SA_ADDSPRITE
- Sprite action flags
BA_STOP
public static final int BA_STOP
- Bounds actions
BA_WRAP
public static final int BA_WRAP
- Bounds actions
BA_BOUNCE
public static final int BA_BOUNCE
- Bounds actions
BA_DIE
public static final int BA_DIE
- Bounds actions
component
protected Component component
image
protected Image image[]
frame
protected int frame
frameInc
protected int frameInc
frameDelay
protected int frameDelay
frameTrigger
protected int frameTrigger
position
protected Rectangle position
collision
protected Rectangle collision
zOrder
protected int zOrder
velocity
protected Point velocity
bounds
protected Rectangle bounds
boundsAction
protected int boundsAction
hidden
protected boolean hidden
Sprite
public Sprite(Component comp,
Image img,
Point pos,
Point vel,
int z,
int ba)
- Sprite constructor method for a single image bitmap with
NO frame animation.
Sprite
public Sprite(Component comp,
Image img[],
int f,
int fi,
int fd,
Point pos,
Point vel,
int z,
int ba)
- Sprite constructor method for an bitmap image that uses multiple
frame animation.
getImage
public Image[] getImage()
- Get an image object of this class object.
setImage
public void setImage(Image img[])
- Set this classes image object.
getFrameInc
public int getFrameInc()
- Get the current animation frame counter.
setFrameInc
public void setFrameInc(int fi)
- Set thje current animation frame counter.
getFrame
public int getFrame()
- Get the current animation frame image.
incFrame
protected void incFrame()
- Increment the current animation frame.
getPosition
public Rectangle getPosition()
- Get the current rectangular position of the Sprite image.
setPosition
void setPosition(Rectangle pos)
- Set the current rectangular position of the Sprite image.
setPosition
public void setPosition(Point pos)
- Move the current rectangular position of the Sprite image.
setCollision
protected void setCollision()
- Set the Sprite image collision coordinates.
getCollision
protected Rectangle getCollision()
- Get the Sprite image collision coordinates.
getZOrder
public int getZOrder()
- Get the Sprite image z-order position.
getVelocity
public Point getVelocity()
- Get the current velocity of the Sprite image.
setVelocity
public void setVelocity(Point vel)
- Set the current velocity of the Sprite image.
getBounds
public Rectangle getBounds()
- Get the Sprite image collision bounds.
setBounds
public void setBounds(Rectangle b)
- Set the Sprite image collision bounds.
show
public void show()
- Set the Sprite to display.
hide
public void hide()
- Hide the Sprite from display.
isPointInside
boolean isPointInside(Point pt)
- See if a point is inside the Sprite bounding box limits.
update
public BitSet update()
- This method is the main run-time method for the "Sprite"
class. Frame animation, position, and bounds checking
for the sprite image are done here.
draw
public void draw(Graphics g)
- Draw the bitmap Sprite image if not hidden
addSprite
protected Sprite addSprite(BitSet action)
- Add a Sprite - does nothing ?
testCollision
protected boolean testCollision(Sprite test)
- Check for collision with another sprite.