tetris/Domain/Piece.cpp
2018-02-06 01:44:42 +02:00

46 lines
622 B
C++

/*
* Piece.cpp
*
* Created on: May 5, 2013
* Author: chibi_000
*/
#include "Piece.h"
// Constructors
Piece::Piece() : Array2(1, 1)
{
}
Piece::Piece(int w, int h) : Array2(w, h)
{
}
Piece::Piece(int w, int h, const int* vals) : Array2(w, h, vals)
{
}
Piece::Piece(const Piece& p) : Array2(p)
{
}
Piece::~Piece()
{
}
// Rotate
Piece Piece::rotate() const
{
// Create a new piece
Piece dest(getHeight(), getWidth());
// Rotate 90 degrees
for (int x = 0; x < getWidth(); x++)
for (int y = 0; y < getHeight(); y++)
dest.set(getHeight() - y - 1, x, get(x, y));
// Return new piece
return dest;
}