Commit 9991a5c7 authored by nappy's avatar nappy
Browse files

remove mirror operations in board

change cm conversion
parent 84d63381
#include "board.h"
namespace Board {
Vector2 sym(const Vector2& vec)
{
return Vector2(vec.x(),Ysize- vec.y())
}
Board::Board() {
//lots of :
// insert(new MyBoardElement(lots of params))
// insert(new MyBoardElement(lots of params))
}
BoardElement::BoardElement(const Vector2& position,std::string name) :
BoardElement::BoardElement(Vector2 position,std::string name) :
mName(name),mPosition(position) {
}
......@@ -20,48 +16,36 @@ namespace Board {
}
void Board::removeElement(BoardElement* e) {
if (e->mSymmetric)
e->mSymmetric->mSymmetric = nullptr;
mElements.erase(e);
}
Cylinder::Cylinder(const Vector2& position) :
Cylinder::Cylinder(Vector2 position) :
BoardElement(position){
}
//------------MonoCylinder---------
MonoCylinder::MonoCylinder(const Vector2& position,Color c) :
MonoCylinder::MonoCylinder(Vector2 position,Color c) :
Cylinder(position), mColor(c) {
}
MonoCylinder::BoardElement* createSymetric()
{
return new MonoCylinder(sym(mPosition),!mColor);
}
//------------BiCylinder---------
BiCylinder::BiCylinder(const Vector2& position,Angle side) :
BiCylinder::BiCylinder(Vector2 position,Angle side) :
Cylinder(position), mSide(side) {
}
BiCylinder::BoardElement* createSymetric()
{
return new BiMonoCylinder(sym(mPosition),mSide += 3.14); // I will do a clean Angle Class
}
Rocket::Rocket(const Vector2& position,
const std::vector<Cylinder*>& cyls) :
Rocket::Rocket(Vector2 position,
const std::vector<Cylinder*>& cyls) :
BoardElement(position),mCyls(cyls)
{
}
CylinderGoal::CylinderGoal(const Vector2& start,
const Vector2& end) :
CylinderGoal::CylinderGoal(Vector2 start,
Vector2 end) :
BoardElement((start + end)*0.5), mStart(start), mEnd(end)
{
}
};
......@@ -12,31 +12,23 @@ namespace Board {
typedef bool Color;
const bool Blue = false;
const bool Yellow = true;
const Distance Xsize = 2.0;
const Distance Ysize = 3.0;
const Distance Xsize = 2.0_m;
const Distance Ysize = 3.0_m;
/** \brief Generic class for Cylinders, Pool of Balls, initial tubes, ...*/
/** \brief Generic class for Cylinders, Pool of Balls, initial tubes, ...*/
class BoardElement {
public :
BoardElement(const Vector2& position, std::string name = "");
BoardElement(Vector2 position, std::string name = "");
virtual std::string getDebugType() = 0;
Vector2 mPosition;
/// In order to initialize both side at the same time
virtual BoardElement* createSymetric() = 0;
/// Maybe useful for smarter AI or just debug info.
//virtual int points() =0;
std::string getName();
BoardElement* mSymmetric;
private :
std::string mName;
};
......@@ -65,20 +57,18 @@ namespace Board {
//∕ \brief only for polymorphism of cylinders
class Cylinder : public BoardElement {
public:
Cylinder(const Vector2& position);
Cylinder(Vector2 position);
};
class MonoCylinder : public Cylinder {
public:
MonoCylinder(const Vector2& position,Color cl);
virtual BoardElement* createSymetric();
MonoCylinder(Vector2 position,Color cl);
Color mColor;
};
class BiCylinder : public Cylinder {
public:
BiCylinder(const Vector2& position,Angle side);
virtual BoardElement* createSymetric();
BiCylinder(Vector2 position,Angle side);
/** \brief The orientation of the cylinder.
The Angle point the direction of the color of our
......@@ -86,9 +76,10 @@ namespace Board {
*/
Angle mSide;
};
class Rocket : public BoardElement {
public:
Rocket(const Vector2& position,
Rocket(Vector2 position,
const std::vector<Cylinder* >& cyls);
std::vector<Cylinder*> mCyls;
......@@ -96,11 +87,10 @@ namespace Board {
class CylinderGoal : public BoardElement {
public:
CylinderGoal(const Vector2& start,const Vector2& end);
CylinderGoal(Vector2 start,Vector2 end);
Vector2 mStart,mEnd;
};
};
......@@ -52,7 +52,7 @@ inline bool operator==(Distance a, Distance b) {
}
constexpr Distance operator"" _cm(long double cm) {
return Distance(0.1d * cm);
return Distance(0.01d * cm);
}
constexpr Distance operator"" _m(long double m) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment