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.
565 566 567 |
# File 'motion-game', line 565 def x @x end |
- (Float) y
Returns the y coordinate of the point.
568 569 570 |
# File 'motion-game', line 568 def y @y end |
Instance Method Details
- (Point) +(point)
Adds the coordinates of the receiver with the coordinates of the given point object.
577 |
# File 'motion-game', line 577 def +(point); end |
- (Point) -(point)
Substracts the coordinates of the receiver with the coordinates of the given point object.
583 |
# File 'motion-game', line 583 def -(point); end |