Class: MiniGL::Block
- Inherits:
-
Object
- Object
- MiniGL::Block
- Defined in:
- lib/minigl/movement.rb
Overview
Represents an object with a rectangular bounding box and the passable
property. It is the simplest structure that can be passed as an element of the obst
array parameter of the move
method.
Instance Attribute Summary collapse
-
#h ⇒ Object
readonly
The height of the bounding box.
-
#passable ⇒ Object
readonly
Whether a moving object can pass through this block when coming from below.
-
#w ⇒ Object
readonly
The width of the bounding box.
-
#x ⇒ Object
readonly
The x-coordinate of the top left corner of the bounding box.
-
#y ⇒ Object
readonly
The y-coordinate of the top left corner of the bounding box.
Instance Method Summary collapse
-
#bounds ⇒ Object
Returns the bounding box of this block as a Rectangle.
-
#initialize(x, y, w, h, passable = false) ⇒ Block
constructor
Creates a new block.
Constructor Details
#initialize(x, y, w, h, passable = false) ⇒ Block
Creates a new block.
Parameters:
- x
-
The x-coordinate of the top left corner of the bounding box.
- y
-
The y-coordinate of the top left corner of the bounding box.
- w
-
The width of the bounding box.
- h
-
The height of the bounding box.
- passable
-
Whether a moving object can pass through this block when
coming from below. This is a common feature of platforms in platform games. Default is false
.
34 35 36 37 |
# File 'lib/minigl/movement.rb', line 34 def initialize(x, y, w, h, passable = false) @x = x; @y = y; @w = w; @h = h @passable = passable end |
Instance Attribute Details
#h ⇒ Object (readonly)
The height of the bounding box.
18 19 20 |
# File 'lib/minigl/movement.rb', line 18 def h @h end |
#passable ⇒ Object (readonly)
Whether a moving object can pass through this block when coming from below. This is a common feature of platforms in platform games.
22 23 24 |
# File 'lib/minigl/movement.rb', line 22 def passable @passable end |
#w ⇒ Object (readonly)
The width of the bounding box.
15 16 17 |
# File 'lib/minigl/movement.rb', line 15 def w @w end |
#x ⇒ Object (readonly)
The x-coordinate of the top left corner of the bounding box.
9 10 11 |
# File 'lib/minigl/movement.rb', line 9 def x @x end |
#y ⇒ Object (readonly)
The y-coordinate of the top left corner of the bounding box.
12 13 14 |
# File 'lib/minigl/movement.rb', line 12 def y @y end |