-
Notifications
You must be signed in to change notification settings - Fork 2
Screen
Screen is a class which extends JPanel and overrides its PaintComponent method in order to draw a scaled BufferedImage. (The BufferedImages used are private, so you only have to worry about placing "Tiles").
When setting the colours, the indices of what colour in the palette you want is used and although there's no real transparency (everything is strictly RGB), a transparent-like behaviour can be achieved by calling the useSameBackground(boolean)
and useSameForeground(boolean)
functions or giving an index value of -1 when setting the foreground or background colours. This will tell the screen whether or not to draw tiles using the foreground/background colours which were most recently used in a given position. The effect is independent between foreground and background and active as long as the current foreground or background colour index is not changed to anything other than -1.
- How much the image is scaled in order to display it
- The horizontal number of tiles on the screen.
- The vertical number of tiles on the screen.
- The Tileset to use.
- The palette to use.
- Takes the horizontal and vertical number of tiles, the image scale, a Tileset and a Palette.
- Colours the entire screen with the background colour.
- Sets the foreground colour.
- An index value of -1 is equivalent to calling
useSameForeground(true)
- Returns true if the colour was set successfully, false otherwise
- Sets the background colour.
- An index value of -1 is equivalent to calling
useSameBackground(true)
- Returns true if the colour was set successfully, false otherwise
- Sets whether or not to use the most recently used background colour for a tile position when drawing a tile instead of the currently defined one.
- Sets whether or not to use the most recently used foreground colour for a tile position when drawing a tile instead of the currently defined one.
- Sets the foreground and background colour.
- Returns true if the colour was set successfully, false otherwise (for both colours)
- Draws a tile at a position. A
char
can be provided in the place of a tileint
without any problem and with a standard ASCII tileset loaded,drawTile(x, y, 'f')
for example will draw an actual "f" on the screen. - Returns true if the tile was drawn, false if it was out of bounds.
- Draws a tile at a position. If
flipX
istrue
, the tile will be flipped horizontally, ifflipY
istrue
, the tile will be flipped vertically. - Returns true if the tile was drawn, false if it was out of bounds.
- Draws a (seeded) random tile at a position.
- Returns true if the tile was drawn, false if it was out of bounds.
- Draws a (seeded) garbage tile at a position by randomly mixing several tiles together.
- Returns true if the tile was drawn, false if it was out of bounds.
- Draws a string starting at a given position. The string will be "correct" as long as the Tileset being used holds standard ASCII values.
-
wrapX
wraps the string horizontally andwrapOnSpace
will attempt to wrap the string on spaces (' ')
- Draws a TileImage starting at the specified x and y positions on the screen.
- Draws a TileImage (flipped either horizontally, vertically or both) starting at the specified x and y positions on the screen.
- Draws the current Tileset.
- If flat is true, it wraps at the screen width, otherwise it wraps at 16.
- Draws the current Palette.
- If flat is true, it wraps at the screen width, otherwise it wraps at 16.