diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-08-17 12:40:10 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-08-17 12:40:10 (GMT) |
| commit | 6500923aa574bad86339f231382a7fcc11e64f96 (patch) | |
| tree | ea48ca236dc8fe543a4b6044dea9ce2e800b1de8 /src/game/SampleTool.cpp | |
| parent | be42cec4984d4af0dc35ff101d7323d1746cd5d5 (diff) | |
| download | powder-6500923aa574bad86339f231382a7fcc11e64f96.zip powder-6500923aa574bad86339f231382a7fcc11e64f96.tar.gz | |
Sample tool, fixes #122
Diffstat (limited to 'src/game/SampleTool.cpp')
| -rw-r--r-- | src/game/SampleTool.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/game/SampleTool.cpp b/src/game/SampleTool.cpp new file mode 100644 index 0000000..a8880b3 --- /dev/null +++ b/src/game/SampleTool.cpp @@ -0,0 +1,36 @@ +#include <iostream> +#include "graphics/Graphics.h" +#include "Tool.h" +#include "GameModel.h" + +VideoBuffer * SampleTool::GetIcon(int toolID, int width, int height) +{ + VideoBuffer * newTexture = new VideoBuffer(width, height); + for (int y=0; y<height; y++) + { + for (int x=0; x<width; x++) + { + pixel pc = x==0||x==width-1||y==0||y==height-1 ? PIXPACK(0xA0A0A0) : PIXPACK(0x000000); + newTexture->SetPixel(x, y, PIXR(pc), PIXG(pc), PIXB(pc), 255); + } + } + newTexture->SetCharacter((width/2)-5, (height/2)-5, 0xE6, 255, 255, 255, 255); + newTexture->BlendCharacter((width/2)-5, (height/2)-5, 0xE7, 100, 180, 255, 255); + return newTexture; +} + +void SampleTool::Draw(Simulation * sim, Brush * brush, ui::Point position) +{ + int particleType = 0; + if(sim->pmap[position.Y][position.X]) + particleType = sim->parts[sim->pmap[position.Y][position.X]>>8].type; + else if(sim->photons[position.Y][position.X]) + particleType = sim->parts[sim->photons[position.Y][position.X]>>8].type; + + if(particleType) + { + Tool * elementTool = gameModel->GetElementTool(particleType); + if(elementTool) + gameModel->SetActiveTool(0, elementTool); + } +} |
