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.



565
566
567
# File 'motion-game', line 565

def x
  @x
end

- (Float) y

Returns the y coordinate of the point.

Returns:

  • (Float)

    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.

Parameters:

Returns:

  • (Point)

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

Parameters:

Returns:

  • (Point)

    A new Point object.



583
# File 'motion-game', line 583

def -(point); end