public class RoguePanel extends JPanel
JPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
static Color |
black |
static Color |
blue |
static Color |
brown |
static Color |
cyan |
static Color |
gray |
static Color |
green |
static Color[] |
groundColor |
static Color |
magenta |
static Color |
red |
static Color |
white |
static Color |
yellow |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
RoguePanel()
Creates a grid of size 80 x 24 chars
|
RoguePanel(int width,
int height)
Creates a grid of a specified width and height
|
Modifier and Type | Method and Description |
---|---|
RoguePanel |
clear()
Clear the entire screen to whatever the default background color is.
|
RoguePanel |
clear(char character,
int x,
int y,
int width,
int height,
Color foreground,
Color background)
Clear the section of the screen with the specified character and whatever the specified foreground and background colors are.
|
RoguePanel |
clear(int x,
int y)
Clear the character at int x,y to whatever the default background color is.
|
void |
displayLosingScreen(int score,
int[] array)
displays the losing screen with player's score and HighScores
|
void |
displayWinningScreen()
displays the winning screen
|
void |
drawChar(int xPos,
int yPos)
Draw an "@" symbol at x,y using the RoguePanel's
write(string,int,int,color,color) method.
|
void |
drawHUD()
Draw HUD: text for information like the last read input, x and y coordinate of the character.
|
void |
drawItem(int xPosition,
int yPosition,
Item i) |
void |
emptySpace(int xPosition,
int yPosition,
int colorNum)
writes an empty space at the given position
|
Color[][] |
getBackgroundColors() |
int |
getCharHeight() |
char[][] |
getChars() |
int |
getCharWidth() |
Color |
getDefaultBackgroundColor() |
Color |
getDefaultForegroundColor() |
Color[][] |
getForegroundColors() |
int |
getGridHeight() |
int |
getGridWidth() |
boolean |
getInGame() |
Color[][] |
getOldBackgroundColors() |
char[][] |
getOldChars() |
Color[][] |
getOldForegroundColors() |
int |
getXcoord() |
int |
getYcoord() |
void |
monsterAttack()
display the you were hit flag
|
void |
moveHeroAnimated(int xPosition,
int yPosition,
int hp,
int ap,
int speed,
int level,
int score)
moves the player to position xPosition,yPosition and updates its hp using write
|
void |
moveMonster(int xPosition,
int yPosition,
GamePiece piece)
moves the monster to position xPosition,yPosition
Prints the x and y coordinates of the character.
|
void |
nextLevel()
display that the player has advanced to the next level
|
void |
paint(Graphics g) |
void |
recordShadows(int[][] shadow)
Covers the areas where the player has not discovered yet
|
void |
setBackgroundColors(Color[][] backgroundColors) |
void |
setCharHeight(int charHeight)
sets the height of a character.
|
void |
setChars(char[][] chars) |
void |
setCharWidth(int charWidth)
sets the width of a character.
|
void |
setCoords(int x,
int y)
sets the coordinates of where we want to draw of character
|
void |
setDefaultBackgroundColor(Color defaultBackgroundColor) |
void |
setDefaultForegroundColor(Color defaultForegroundColor) |
void |
setForegroundColors(Color[][] foregroundColors) |
void |
setGridHeight(int gridHeight)
set the height of the grid.
|
void |
setGridWidth(int gridWidth)
set the width of the grid.
|
void |
setInGame(boolean b) |
void |
setOldBackgroundColors(Color[][] oldBackgroundColors) |
void |
setOldChars(char[][] oldChars) |
void |
setOldForegroundColors(Color[][] oldForegroundColors) |
void |
setXcoord(int xcoord)
Sets the X coordinate for where the character is draw, must be within the size or the frame
|
void |
setYcoord(int ycoord)
Set the Y coordinate for where the character is to be drawn, must be within the size of the frame
|
void |
update(Graphics g) |
RoguePanel |
write(char character)
Write a character to the cursor's position.
|
RoguePanel |
write(char character,
int x,
int y,
Color foreground,
Color background)
Write a character to the specified position with the specified foreground and background colors.
|
RoguePanel |
write(String string,
int x,
int y,
Color foreground,
Color background)
Write a string to the specified position with the specified foreground and background colors.
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static Color white
public static Color black
public static Color red
public static Color blue
public static Color cyan
public static Color green
public static Color yellow
public static Color magenta
public static Color gray
public static Color brown
public static Color[] groundColor
public RoguePanel()
public RoguePanel(int width, int height)
width
- width of new gridheight
- height of new gridpublic char[][] getChars()
public void setChars(char[][] chars)
chars
- the chars to setpublic int getCharHeight()
public void setCharHeight(int charHeight)
charHeight
- the charHeight to setpublic int getCharWidth()
public void setCharWidth(int charWidth)
charWidth
- the charWidth to setpublic int getGridHeight()
public void setGridHeight(int gridHeight)
gridHeight
- the gridHeight to setpublic int getGridWidth()
public void setGridWidth(int gridWidth)
gridWidth
- the gridWidth to setpublic int getXcoord()
public void setXcoord(int xcoord)
xcoord
- the xcoord to setpublic int getYcoord()
public void setYcoord(int ycoord)
ycoord
- the ycoord to setpublic void setCoords(int x, int y)
x
- the x coordinatey
- the y coordinatepublic Color getDefaultBackgroundColor()
public void setDefaultBackgroundColor(Color defaultBackgroundColor)
defaultBackgroundColor
- the defaultBackgroundColor to setpublic Color getDefaultForegroundColor()
public void setDefaultForegroundColor(Color defaultForegroundColor)
defaultForegroundColor
- the defaultForegroundColor to setpublic Color[][] getBackgroundColors()
public void setBackgroundColors(Color[][] backgroundColors)
backgroundColors
- the backgroundColors to setpublic Color[][] getForegroundColors()
public void setForegroundColors(Color[][] foregroundColors)
foregroundColors
- the foregroundColors to setpublic char[][] getOldChars()
public void setOldChars(char[][] oldChars)
oldChars
- the oldChars to setpublic Color[][] getOldBackgroundColors()
public void setOldBackgroundColors(Color[][] oldBackgroundColors)
oldBackgroundColors
- the oldBackgroundColors to setpublic Color[][] getOldForegroundColors()
public void setOldForegroundColors(Color[][] oldForegroundColors)
oldForegroundColors
- the oldForegroundColors to setpublic boolean getInGame()
public void setInGame(boolean b)
b
- the boolean to setpublic void update(Graphics g)
update
in class JComponent
public void paint(Graphics g)
paint
in class JComponent
public RoguePanel clear()
public RoguePanel clear(int x, int y)
x
- the distance from the left of the position to be clearedy
- the distance from the top of the position to be clearedpublic RoguePanel clear(char character, int x, int y, int width, int height, Color foreground, Color background)
character
- the character to writex
- the distance from the left to begin writing fromy
- the distance from the top to begin writing fromwidth
- the height of the section to clearheight
- the width of the section to clearforeground
- the foreground color or null to use the defaultbackground
- the background color or null to use the defaultpublic RoguePanel write(char character)
character
- the character to writepublic RoguePanel write(String string, int x, int y, Color foreground, Color background)
string
- the string to writex
- the distance from the left to begin writing fromy
- the distance from the top to begin writing fromforeground
- the foreground color or null to use the defaultbackground
- the background color or null to use the defaultpublic RoguePanel write(char character, int x, int y, Color foreground, Color background)
character
- the character to writex
- the distance from the left to begin writing fromy
- the distance from the top to begin writing fromforeground
- the foreground color or null to use the defaultbackground
- the background color or null to use the defaultpublic void drawChar(int xPos, int yPos)
xPos
- x position of character to be drawnyPos
- y position of character to be drawnpublic void drawHUD()
public void moveHeroAnimated(int xPosition, int yPosition, int hp, int ap, int speed, int level, int score)
xPosition
- x position that the player will move toyPosition
- y position that the player will move tohp
- current hp of the playerap
- current attack power of the playerspeed
- current speed of the playerlevel
- current level the player is onscore
- current score of the playerpublic void drawItem(int xPosition, int yPosition, Item i)
public void moveMonster(int xPosition, int yPosition, GamePiece piece)
xPosition
- x position for monster to move toyPosition
- y position for monster to move topiece
- reference to the monster to be movedpublic void monsterAttack()
public void nextLevel()
public void displayLosingScreen(int score, int[] array)
score
- final score of the playerarray
- array of high scorespublic void displayWinningScreen()
public void emptySpace(int xPosition, int yPosition, int colorNum)
xPosition
- x position of empty spaceyPosition
- y position of empty spacecolorNum
- color of the current levelpublic void recordShadows(int[][] shadow)
shadow
- 2D array of places that the player has discovered