- Main Page
- Classes
- Files

- File List
- File Members

# C:/Users/Public/AGS Final Folder/BFLETCHER D4010283/Source/Game/Source/BreakoutLocationArray.cpp

Go to the documentation of this file.

    00001 #include "BreakoutLocationArray.h"
    00002
    00003 BreakoutLocationArray::BreakoutLocationArray(const AABBi &boxArea, const Vector2i &boxSize, int padding /* = 1 */)
    00004 : m_pLocationArray(0), m_width(0), m_height(0)
    00005 {
    00006         int boxPaddedWidth = (boxSize.x + (padding * 2));
    00007         int areaWidth = boxArea.Right - boxArea.Left;
    00008         m_width = areaWidth / boxPaddedWidth; //Pad either side of the box.
    00009
    00010         int boxPaddedHeight = (boxSize.y + (padding * 2));
    00011         int areaHeight = boxArea.Top - boxArea.Bottom;
    00012         m_height = areaHeight / boxPaddedHeight;
    00013         if(m_height < 0)
    00014                 m_height = -m_height;
    00015
    00016         m_pLocationArray = new Vector2i[m_width * m_height];
    00017         for(int x = 0; x < m_width; x++)
    00018         {
    00019                 for(int y = 0; y < m_height; y++)
    00020                 {
    00021                         int idx = (y * m_width) + x;
    00022                         m_pLocationArray[idx].x = boxArea.Left + (x * boxPaddedWidth) + padding;
    00023                         m_pLocationArray[idx].y = boxArea.Bottom + (y * boxPaddedHeight) + padding;
    00024                 }
    00025         }
    00026 }
    00027
    00028 BreakoutLocationArray::~BreakoutLocationArray()
    00029 {
    00030         if(m_pLocationArray)
    00031                 delete[] m_pLocationArray;
    00032 }