class MiniGL::Block
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.
Attributes
The height of the bounding box.
Whether a moving object can pass through this block when coming from below. This is a common feature of platforms in platform games.
The width of the bounding box.
The x-coordinate of the top left corner of the bounding box.
The y-coordinate of the top left corner of the bounding box.
Public Class Methods
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
.
# 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
Public Instance Methods
Returns the bounding box of this block as a Rectangle
.
# File lib/minigl/movement.rb, line 40 def bounds Rectangle.new @x, @y, @w, @h end
# File lib/minigl/movement.rb, line 44 def to_s "Block(#{@x}, #{@y}, #{@w}, #{@h}#{@passable ? ", passable" : ''})" end