Skip to content
Franklin Webber edited this page Nov 25, 2012 · 5 revisions

Metro Units

Metro provides several basic units to use within your game. These common units are available without requiring any namespacing (e.g. You can use Point.at(x,y,z) and not Metro::Units::Point.at(x,y,z).

A point represents a traditional position on a coordinate space. While all games in Metro are two dimensional (x,y), an optional z-coordinate may be provided and can often act as the z-order for assisting in the determination of at what level an item should be rendered.

A representation of height and width.

Often times an item can have the scale of their x and the scale of their y altered. This is a representation of that factor_x and factor_y. Most Gosu drawable items allow you to specify and alter the scale of the item.

Metro monkey patches Numeric to provide units to assist with defining more clarity of the length of the interval.

These suffixes are predominately used with regard to the time interval when dealing with animations.

Expressing an animation that takes place roughly over 3 seconds:

class ExampleScene < GameScene
  draws :title

  animate :title, to: { x: 320, y: 444 }, interval: 3.seconds
end

Expressing an animation that takes place for exactly 23 game ticks:

class ExampleScene < GameScene
  draws :title

  animate :title, to: { x: 320, y: 444 }, interval: 23.ticks
end
Clone this wiki locally