so I've written the basics of my map editor, got three different kinds of brushes (pencil, square and flood fill) all working great. However I'd like to know how I should handle the actions of those brushes.
My basic question is: Should the brush itself implement its action (draw single tile, draw square, flood fill) or should the using class do this? For now I've got a switch-statement in the update()-method of the tilemap-window, where the actions are implented. The brush class itself just holds certain parameters like starting point, selected tiles, etc.. . This is how, eg the pencil implentation looks like, in the Window_Tilemap->Update()-method:
switch((*m_ppEditorBrush)->GetType())
{
case 0:
if(Input::MouseClicked(0) || Input::MouseHold(0))
{
vector<int>* pSelected = (*m_ppEditorBrush)->GetSelected();
int i = 0;
Vector2 vStartPoint = ProjectPosition(this,0,Input::GetMousePos());
vStartPoint /= 32;
for(vector<int>::iterator ii = (*pSelected).begin();ii!=(*pSelected).end();++ii,i++)
{
m_pGameMap->ChangeTile(vStartPoint.x+i%(*m_ppEditorBrush)->GetWidth(),vStartPoint.y+i/(*m_ppEditorBrush)->GetWidth(),*ii);
}
m_bActive = true;
return true;
}
m_bActive = false;
return false;
}Not talking about how to make this code more readable, but is this basically the right way, or should I stuff that into the brush-class? Obviously my Window_Tilemap-code would become and easier to extend, but it would also mean my brush-class would need to know about the Game_Map-class, holding all the tiles, and isn't it better the less my classes know about other classes? Whats the right thing to do here?






