Class: MG::Point
- Inherits:
-
Object
- Object
- MG::Point
- Defined in:
- motion-game
Overview
A point represents a location in a two-dimensional coordinate system using
x
and y
variables.
When calling a method that expects a Point
object, a 2-element
Array
can be passed instead, as a convenience shortcut. For
example,
node.location = [10, 20]
is the same as
point = MG::Point.new
point.x = 10
point.y = 20
node.location = point
Properties (collapse)
-
- (Float) x
The x coordinate of the point.
-
- (Float) y
The y coordinate of the point.
Helpers (collapse)
-
- (Point) +(point)
Adds the coordinates of the receiver with the coordinates of the given point object.
-
- (Point) -(point)
Substracts the coordinates of the receiver with the coordinates of the given point object.
Instance Attribute Details
- (Float) x
Returns the x coordinate of the point.
610 611 612 |
# File 'motion-game', line 610 def x @x end |
- (Float) y
Returns the y coordinate of the point.
613 614 615 |
# File 'motion-game', line 613 def y @y end |
Instance Method Details
- (Point) +(point)
Adds the coordinates of the receiver with the coordinates of the given point object.
622 |
# File 'motion-game', line 622 def +(point); end |
- (Point) -(point)
Substracts the coordinates of the receiver with the coordinates of the given point object.
628 |
# File 'motion-game', line 628 def -(point); end |