63 lines
1.1 KiB
C++
63 lines
1.1 KiB
C++
/*
|
|
* Level.cpp
|
|
*
|
|
* Created on: Nov 11, 2016
|
|
* Author: tibi
|
|
*/
|
|
|
|
#include "Level.h"
|
|
#include <cassert>
|
|
|
|
namespace farmlands {
|
|
namespace model {
|
|
|
|
Level::Level(size_t layerCount, size_t rowCount, size_t columnCount)
|
|
: m_cellWidth(0),
|
|
m_cellHeight(0),
|
|
m_cells(new Cell[layerCount * rowCount * columnCount]),
|
|
m_textures(new int[layerCount]),
|
|
m_layers(layerCount),
|
|
m_rows(rowCount),
|
|
m_columns(columnCount)
|
|
{
|
|
}
|
|
|
|
Level::~Level()
|
|
{
|
|
delete[] m_cells;
|
|
delete[] m_textures;
|
|
}
|
|
|
|
|
|
Cell Level::cell(size_t layer, size_t row, size_t col) const
|
|
{
|
|
assert(layer < m_layers);
|
|
assert(row < m_rows);
|
|
assert(col < m_columns);
|
|
|
|
return m_cells[layer * m_rows * m_columns + row * m_columns + col];
|
|
}
|
|
|
|
void Level::setCell(size_t layer, size_t row, size_t col, Cell value)
|
|
{
|
|
assert(layer < m_layers);
|
|
assert(row < m_rows);
|
|
assert(col < m_columns);
|
|
|
|
m_cells[layer * m_rows * m_columns + row * m_columns + col] = value;
|
|
}
|
|
|
|
int Level::texture(size_t layer) const
|
|
{
|
|
return m_textures[layer];
|
|
}
|
|
|
|
void Level::setTexture(size_t layer, int textureId) const
|
|
{
|
|
m_textures[layer] = textureId;
|
|
}
|
|
|
|
} /* namespace model */
|
|
} /* namespace farmlands */
|
|
|