summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-05-07 16:59:50 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-05-07 16:59:50 (GMT)
commit51b17badf4c72270bb762ea795d05d51c8b355e3 (patch)
treeb66671e0496b68114c6e91eedb58bf783d5343c0 /src/game
parentfb111f42d00dd8a2041bae970c0913e096ac5101 (diff)
downloadpowder-51b17badf4c72270bb762ea795d05d51c8b355e3.zip
powder-51b17badf4c72270bb762ea795d05d51c8b355e3.tar.gz
A bit of refactoring (elements)
Diffstat (limited to 'src/game')
-rw-r--r--src/game/EllipseBrush.h3
-rw-r--r--src/game/GameController.cpp4
-rw-r--r--src/game/GameModel.cpp10
3 files changed, 9 insertions, 8 deletions
diff --git a/src/game/EllipseBrush.h b/src/game/EllipseBrush.h
index 26b3cf8..8a1dc9a 100644
--- a/src/game/EllipseBrush.h
+++ b/src/game/EllipseBrush.h
@@ -8,6 +8,7 @@
#ifndef ELIPSEBRUSH_H_
#define ELIPSEBRUSH_H_
+#include <cmath>
#include "Brush.h"
class EllipseBrush: public Brush
@@ -29,7 +30,7 @@ public:
{
for(int y = 0; y <= radius.Y*2; y++)
{
- if((pow(x-radius.X,2)*pow(ry,2)+pow(y-radius.Y,2)*pow(rx,2)<=pow(rx,2)*pow(ry,2)))
+ if((pow(x-radius.X,2.0f)*pow(ry,2.0f)+pow(y-radius.Y,2.0f)*pow(rx,2.0f)<=pow(rx,2.0f)*pow(ry,2.0f)))
{
bitmap[y*(size.X)+x] = 255;
}
diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp
index 4f94ab8..529137a 100644
--- a/src/game/GameController.cpp
+++ b/src/game/GameController.cpp
@@ -580,8 +580,8 @@ void GameController::ReloadSim()
std::string GameController::ElementResolve(int type)
{
- if(gameModel && gameModel->GetSimulation() && gameModel->GetSimulation()->ptypes && type >= 0 && type < PT_NUM)
- return std::string(gameModel->GetSimulation()->ptypes[type].name);
+ if(gameModel && gameModel->GetSimulation() && gameModel->GetSimulation()->elements && type >= 0 && type < PT_NUM)
+ return std::string(gameModel->GetSimulation()->elements[type].Name);
else
return "";
}
diff --git a/src/game/GameModel.cpp b/src/game/GameModel.cpp
index 4dd14ef..bb69479 100644
--- a/src/game/GameModel.cpp
+++ b/src/game/GameModel.cpp
@@ -71,10 +71,10 @@ GameModel::GameModel():
//Build menus from Simulation elements
for(int i = 0; i < PT_NUM; i++)
{
- if(sim->ptypes[i].menusection < 12 && sim->ptypes[i].enabled && sim->ptypes[i].menu)
+ if(sim->elements[i].MenuSection < 12 && sim->elements[i].Enabled && sim->elements[i].MenuVisible)
{
- Tool * tempTool = new ElementTool(i, sim->ptypes[i].name, PIXR(sim->ptypes[i].pcolors), PIXG(sim->ptypes[i].pcolors), PIXB(sim->ptypes[i].pcolors));
- menuList[sim->ptypes[i].menusection]->AddTool(tempTool);
+ Tool * tempTool = new ElementTool(i, sim->elements[i].Name, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour));
+ menuList[sim->elements[i].MenuSection]->AddTool(tempTool);
}
}
@@ -106,8 +106,8 @@ GameModel::GameModel():
brushList.push_back(new EllipseBrush(ui::Point(4, 4)));
//Set default tools
- activeTools[0] = menuList[SC_POWDERS]->GetToolList()[0];
- activeTools[1] = menuList[SC_SPECIAL]->GetToolList()[0];
+ //activeTools[0] = menuList[SC_POWDERS]->GetToolList()[0];
+ //activeTools[1] = menuList[SC_SPECIAL]->GetToolList()[0];
//Set default menu
activeMenu = menuList[SC_POWDERS];