Game Development Reference
In-Depth Information
orientation parameter it is also useful to specify the pivot of the rectangle, this is the point
around which the rotation will be computed. The pivot point does not have to be a point
within the rectangle, a pivot outside of the rectangle will cause the rectangle to rotate with
an amount of translation defined by the distance from the pivot to the rectangle.
Some systems such as Unity actually represent the display using the bottom left corner,
thisapproachisconsistentwiththeCartesiancoordinatesysteminwhichtheorigin(0,0) is
located on the bottom left corner of the screen. In this topic, we will place the origin at the
top left corner of the rectangle, with the x axis moving to the right and the y axis moving
down.
Figure 28 - A rectangle represented by x, y and width, height.
The interface provided by a rectangle class should be versatile to allow rectangles to be
used in a wide variety of contexts.
class rectangle
{
public:
rectangle();
rectangle(float left, float top, float width, float height);
static rectangle MakeRectangle(float left, float top, float right, float bottom);
float Top() const { return m_top; }
float Left() const { return m_left; }
float Width() const { return m_width; }
float Height() const { return m_height; }
float& Top() { return m_top; }
float& Left() { return m_left; }
Search WWH ::




Custom Search