summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-01-11 22:59:45 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-01-11 22:59:45 (GMT)
commitfc2f52099c0bbb2412046252bf7b5e4113bbe8e4 (patch)
treeaa820daf182a845758c3ba2c649df54a228748d4 /src
parent2eb09c1daac8199532694167f418146fa57e7735 (diff)
downloadpowder-fc2f52099c0bbb2412046252bf7b5e4113bbe8e4.zip
powder-fc2f52099c0bbb2412046252bf7b5e4113bbe8e4.tar.gz
More stuff, started console
Diffstat (limited to 'src')
-rw-r--r--src/Console.cpp68
-rw-r--r--src/PowderToy.cpp4
-rw-r--r--src/Renderer.cpp15
-rw-r--r--src/Simulation.cpp2
-rw-r--r--src/interface/Sandbox.cpp23
-rw-r--r--src/interface/State.cpp15
6 files changed, 112 insertions, 15 deletions
diff --git a/src/Console.cpp b/src/Console.cpp
new file mode 100644
index 0000000..6bf8ce6
--- /dev/null
+++ b/src/Console.cpp
@@ -0,0 +1,68 @@
+
+#include <string>
+#include "Console.h"
+
+int Console::ParseType(std::string * type)
+{
+ char * txt = (char *)type->c_str();
+ int i = -1;
+ // alternative names for some elements
+ if (*type == "C4") i = PT_PLEX;
+ else if (*type == "C5") i = PT_C5;
+ else if (*type == "NONE") i = PT_NONE;
+ if (i>=0 && i<PT_NUM && sim->ptypes[i].enabled)
+ {
+ (*lastError) = "";
+ return i;
+ }
+ for (i=1; i<PT_NUM; i++) {
+ if (strcasecmp(txt, sim->ptypes[i].name)==0 && sim->ptypes[i].enabled)
+ {
+ (*lastError) = "";
+ return i;
+ }
+ }
+ (*lastError) = "Particle type not recognised";
+ return -1;
+}
+
+void Console::Tick(float * dt)
+{
+
+}
+
+void Console::ConsoleShown()
+{
+
+}
+
+void Console::ConsoleHidden()
+{
+
+}
+
+int Console::ProcessCommand(std::string * command)
+{
+
+}
+
+std::string * Console::GetLastError()
+{
+ return lastError;
+}
+
+std::vector<ConsoleCommand> * Console::GetPreviousCommands()
+{
+
+}
+
+Console::Console(ui::Sandbox * sandbox)
+{
+ this->sandbox = sandbox;
+ sim = sandbox->GetSimulation();
+}
+
+Console::~Console()
+{
+
+}
diff --git a/src/PowderToy.cpp b/src/PowderToy.cpp
index 973aaa3..49dac73 100644
--- a/src/PowderToy.cpp
+++ b/src/PowderToy.cpp
@@ -54,12 +54,12 @@ int main(int argc, char * argv[])
ui::Button * button = new ui::Button(100, 100, 100, 100, "poP");
window->Add(sandbox);
window->Add(button);
- window->Add(ControlFactory::MainMenu(gameSession, 0, 0, 200, 200));
+ //window->Add(ControlFactory::MainMenu(gameSession, 0, 0, 200, 200));
SDL_Event event;
while(!SDLPoll(&event))
{
- mouseButton = SDL_GetMouseState(&mouseX, &mouseY);
+ //mouseButton = SDL_GetMouseState(&mouseX, &mouseY);
switch(event.type)
{
case SDL_KEYDOWN:
diff --git a/src/Renderer.cpp b/src/Renderer.cpp
index c1bbf3c..67f9348 100644
--- a/src/Renderer.cpp
+++ b/src/Renderer.cpp
@@ -489,9 +489,14 @@ void Renderer::render_parts()
int deca, decr, decg, decb, cola, colr, colg, colb, firea, firer, fireg, fireb, pixel_mode, q, i, t, nx, ny, x, y, caddress;
int orbd[4] = {0, 0, 0, 0}, orbl[4] = {0, 0, 0, 0};
float gradv, flicker, fnx, fny;
- Particle * parts = sim->parts;
- part_transition *ptransitions = sim->ptransitions;
- part_type *ptypes = sim->ptypes;
+ Particle * parts;
+ part_transition *ptransitions;
+ part_type *ptypes;
+ if(!sim)
+ return;
+ parts = sim->parts;
+ ptransitions = sim->ptransitions;
+ ptypes = sim->ptypes;
#ifdef OGLR
int cfireV = 0, cfireC = 0, cfire = 0;
int csmokeV = 0, csmokeC = 0, csmoke = 0;
@@ -1670,7 +1675,9 @@ void Renderer::init_display_modes()
}
}
-Renderer::Renderer(Graphics * g, Simulation * sim)
+Renderer::Renderer(Graphics * g, Simulation * sim):
+ sim(NULL),
+ g(NULL)
{
this->g = g;
this->sim = sim;
diff --git a/src/Simulation.cpp b/src/Simulation.cpp
index 7ec5c4e..a1a785a 100644
--- a/src/Simulation.cpp
+++ b/src/Simulation.cpp
@@ -3119,6 +3119,8 @@ void Simulation::update_particles()//doesn't update the particles themselves, bu
pthread_t *InterThreads;
#endif
+ air->update_air();
+
memset(pmap, 0, sizeof(pmap));
memset(photons, 0, sizeof(photons));
NUM_PARTS = 0;
diff --git a/src/interface/Sandbox.cpp b/src/interface/Sandbox.cpp
index c33571a..5e29bae 100644
--- a/src/interface/Sandbox.cpp
+++ b/src/interface/Sandbox.cpp
@@ -5,35 +5,54 @@
* Author: Simon
*/
+#include <iostream>
+
#include "Config.h"
#include "interface/Sandbox.h"
#include "interface/Component.h"
#include "Renderer.h"
+#include "Simulation.h"
namespace ui {
Sandbox::Sandbox():
- Component(0, 0, XRES, YRES)
+ Component(0, 0, XRES, YRES),
+ ren(NULL),
+ isMouseDown(false),
+ activeElement(1)
{
sim = new Simulation();
}
+Simulation * Sandbox::GetSimulation()
+{
+ return sim;
+}
+
void Sandbox::OnMouseMovedInside(int localx, int localy, int dx, int dy)
{
if(isMouseDown)
{
- sim->create_parts(localx, localy, 20, 20, 1, 0);
+ sim->create_line(lastCoordX, lastCoordY, localx, localy, 2, 2, activeElement, 0);
+ lastCoordX = localx;
+ lastCoordY = localy;
}
}
void Sandbox::OnMouseDown(int localx, int localy, unsigned int button)
{
+ sim->create_line(localx, localy, localx, localy, 2, 2, activeElement, 0);
+ lastCoordX = localx;
+ lastCoordY = localy;
isMouseDown = true;
}
void Sandbox::OnMouseUp(int localx, int localy, unsigned int button)
{
+ sim->create_line(lastCoordX, lastCoordY, localx, localy, 2, 2, activeElement, 0);
+ lastCoordX = localx;
+ lastCoordY = localy;
isMouseDown = false;
}
diff --git a/src/interface/State.cpp b/src/interface/State.cpp
index e069e8f..2828751 100644
--- a/src/interface/State.cpp
+++ b/src/interface/State.cpp
@@ -13,13 +13,14 @@
namespace ui {
-State::State(int w, int h) :
- mouseX(0),
- mouseY(0),
- mouseXP(0),
- mouseYP(0),
- width(w),
- height(h)
+State::State(int w, int h):
+ mouseX(0),
+ mouseY(0),
+ mouseXP(0),
+ mouseYP(0),
+ width(w),
+ height(h),
+ Components()
{
}