initial commit
This commit is contained in:
28
src/Pieces/Rotation.h
Normal file
28
src/Pieces/Rotation.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
/**
|
||||
* Every type of rotation that can be applied to an object in a 2D grid
|
||||
*/
|
||||
enum Rotation {
|
||||
NONE,
|
||||
CLOCKWISE,
|
||||
DOUBLE,
|
||||
COUNTERCLOCKWISE
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Addition operator, returns a rotation corresponding to doing both rotations
|
||||
*/
|
||||
Rotation operator+(const Rotation& left, const Rotation& right) {
|
||||
return Rotation((left + right) % 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Additive assignation operator, rotate the left rotation by the right rotation
|
||||
*/
|
||||
Rotation& operator+=(Rotation& left, const Rotation& right) {
|
||||
left = left + right;
|
||||
return left;
|
||||
}
|
||||
Reference in New Issue
Block a user