Class: MG::Point

Inherits:
Object
  • Object
show all
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)

Helpers (collapse)

Instance Attribute Details

- (Float) x

Returns the x coordinate of the point.

Returns:

  • (Float)

    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.

Returns:

  • (Float)

    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.

Parameters:

Returns:

  • (Point)

    A new 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.

Parameters:

Returns:

  • (Point)

    A new Point object.



628
# File 'motion-game', line 628

def -(point); end