Class: UT::Tile
- Inherits:
-
Object
- Object
- UT::Tile
- Defined in:
- lib/ut/tile.rb
Overview
A Tile stores all attributes required by a Viewport to draw it. ‘Tile.new` takes an `args` hash as its only parameter. The `args` hash respects three members:
* `:glyph`: The unicode character. _Defaults to `' '`._
* `:foreground`: The foreground color represented by a `Gosu::Color`
instance. _Defaults to `DEFAULT_FOREGROUND`._
* `:background`: The background color represented by a `Gosu::Color`
instance. _Defaults to `DEFAULT_BACKGROUND`._
Constant Summary collapse
- DEFAULT_FOREGROUND =
The default foreground color is white
Gosu::Color::WHITE
- DEFAULT_BACKGROUND =
the default background color is black
Gosu::Color::BLACK
- NULL =
An empty tile wih default fore- and background color
Tile.new
Instance Attribute Summary collapse
-
#background ⇒ Object
Foreground and background color of the Tile Colors are stored as an instance of ‘Gosu::Color`.
-
#foreground ⇒ Object
Foreground and background color of the Tile Colors are stored as an instance of ‘Gosu::Color`.
-
#glyph ⇒ Object
The unicode character.
Instance Method Summary collapse
-
#clone ⇒ Object
Clones the tile by copying all attributes to a new Tile.
-
#initialize(args = {}) ⇒ Tile
constructor
A new instance of Tile.
Constructor Details
#initialize(args = {}) ⇒ Tile
Returns a new instance of Tile.
27 28 29 30 31 |
# File 'lib/ut/tile.rb', line 27 def initialize args = {} self.glyph = args[:glyph] || " " self.foreground = args[:foreground] || DEFAULT_FOREGROUND self.background = args[:background] || DEFAULT_BACKGROUND end |
Instance Attribute Details
#background ⇒ Object
Foreground and background color of the Tile Colors are stored as an instance of ‘Gosu::Color`
18 19 20 |
# File 'lib/ut/tile.rb', line 18 def background @background end |
#foreground ⇒ Object
Foreground and background color of the Tile Colors are stored as an instance of ‘Gosu::Color`
18 19 20 |
# File 'lib/ut/tile.rb', line 18 def foreground @foreground end |
#glyph ⇒ Object
The unicode character
15 16 17 |
# File 'lib/ut/tile.rb', line 15 def glyph @glyph end |