Début TP2 + Handling des événements de touches de mouvement

This commit is contained in:
Marc-Eric Martel
2021-09-24 10:15:43 -04:00
parent 6d62a36bd3
commit 2f8e6dbb30
186 changed files with 26429 additions and 442 deletions

41
mcclone/blockarray3d.cpp Normal file
View File

@@ -0,0 +1,41 @@
#include "blockarray3d.h"
BlockArray3d::BlockArray3d(int x, int y, int z) : m_x(x), m_y(y), m_z(z)
{
m_blocks = new BlockType[m_x * m_y * m_z];
Reset(BTYPE_AIR);
}
BlockArray3d::~BlockArray3d()
{
delete [] m_blocks;
}
BlockArray3d::BlockArray3d(const BlockArray3d& array) : m_x(array.m_x), m_y(array.m_y), m_z(array.m_z)
{
m_blocks = new BlockType[m_x * m_y * m_z];
for(int i = 0; i < m_x * m_y * m_z; ++i)
m_blocks[i] = array.m_blocks[i];
}
void BlockArray3d::Set(int x, int y, int z, BlockType type)
{
m_blocks[To1dIndex(x, y, z)] = type;
}
BlockType BlockArray3d::Get(int x, int y, int z) const
{
return m_blocks[To1dIndex(x, y, z)];
}
void BlockArray3d::Reset(BlockType type)
{
for(int i = 0; i < m_x * m_y * m_z; ++i)
m_blocks[i] = type;
}
int BlockArray3d::To1dIndex(int x, int y, int z) const
{
return x + (z * m_x) + (y * m_z * m_x);
}