| Modifier and Type | Field | Description |
|---|---|---|
boolean |
alive |
|
java.lang.String |
assetImagePath |
|
int |
deathTimer |
|
int |
dx |
|
int |
dy |
|
int |
lives |
|
int |
playerNum |
|
int |
reqdx |
|
int |
reqdy |
|
int |
speed |
|
int |
startX |
|
int |
startY |
|
int |
x |
|
int |
y |
| Constructor | Description |
|---|---|
Character(int x,
int y) |
Constructor for Character class
|
Character(int x,
int y,
int playerNum) |
Constructor for Character class
|
| Modifier and Type | Method | Description |
|---|---|---|
abstract void |
death() |
Handles character's death
|
abstract void |
draw(java.awt.Graphics2D g,
javax.swing.JComponent canvas) |
draws the character onto the screen
|
abstract java.awt.Image |
getLifeImage() |
Returns the image used for displaying remaining lives
|
abstract void |
keyPressed(int key) |
Handles key presses for game controls
|
abstract void |
keyReleased(int key) |
Handles key releases for game controls
|
abstract void |
loadImages() |
Load game sprites from images folder
|
void |
move() |
Moves character's current position
|
abstract void |
move(Grid grid) |
Moves character's current position with the board's collision
|
static boolean |
moveable(int dx,
int dy,
short grid) |
Check if the direction has no wall and moveable
|
abstract void |
moveAI(Grid grid,
Character[] c) |
Moves character's current position with the board's collision
|
void |
reset() |
Restores the character's default values.
|
void |
resetPos() |
Restores the character's default position
|
void |
setSpeed(int speed) |
sets the speed of the character
|
void |
setX(int x) |
sets the x-coordiante of the character on the screen
|
void |
setY(int y) |
sets the y-coordinate of the character on the screen
|
public boolean alive
public java.lang.String assetImagePath
public int playerNum
public int lives
public int deathTimer
public int startX
public int startY
public int speed
public int x
public int y
public int dx
public int dy
public int reqdx
public int reqdy
public Character(int x,
int y)
x - the starting x coordinate of pacmany - the starting y coordinate of pacmanpublic Character(int x,
int y,
int playerNum)
x - the starting x coordinate of pacmany - the starting y coordinate of pacmanplayerNum - int representing who the player is controllingpublic void reset()
public void resetPos()
public abstract void draw(java.awt.Graphics2D g,
javax.swing.JComponent canvas)
g - a Graphics2D objectcanvas - A JComponent object to be drawn onpublic abstract void loadImages()
public abstract void death()
public abstract java.awt.Image getLifeImage()
public abstract void keyPressed(int key)
key - Integer representing the key pressedpublic abstract void keyReleased(int key)
key - Integer representing the key releasedpublic abstract void move(Grid grid)
grid - The Grid to be used for collisionpublic abstract void moveAI(Grid grid, Character[] c)
grid - The Grid to be used for collisionc - Array of target Characterspublic void move()
public void setX(int x)
public void setY(int y)
public void setSpeed(int speed)
public static boolean moveable(int dx,
int dy,
short grid)
dx - x-direction movedy - y-direction movegrid - grid data