void GameController::Update() { ui::Point pos = gameView->GetMousePosition(); gameModel->GetRenderer()->mousePos = PointTranslate(pos); if (pos.X < XRES && pos.Y < YRES) gameView->SetSample(gameModel->GetSimulation()->GetSample(PointTranslate(pos).X, PointTranslate(pos).Y)); else gameView->SetSample(gameModel->GetSimulation()->GetSample(pos.X, pos.Y)); Simulation * sim = gameModel->GetSimulation(); sim->update_particles(); //if either STKM or STK2 isn't out, reset it's selected element. Defaults to PT_DUST unless right selected is something else //This won't run if the stickmen dies in a frame, since it respawns instantly if (!sim->player.spwn || !sim->player2.spwn) { int rightSelected = PT_DUST; Tool * activeTool = gameModel->GetActiveTool(1); if (activeTool->GetIdentifier().find("DEFAULT_PT_") != activeTool->GetIdentifier().npos) { int sr = activeTool->GetToolID(); if ((sr>0 && sr<PT_NUM && sim->elements[sr].Enabled && sim->elements[sr].Falldown>0) || sr==SPC_AIR || sr == PT_NEUT || sr == PT_PHOT || sr == PT_LIGH) rightSelected = sr; } if (!sim->player.spwn) sim->player.elem = rightSelected; if (!sim->player2.spwn) sim->player2.elem = rightSelected; } if(renderOptions && renderOptions->HasExited) { delete renderOptions; renderOptions = NULL; } if(search && search->HasExited) { delete search; search = NULL; } if(activePreview && activePreview->HasExited) { delete activePreview; activePreview = NULL; } if(loginWindow && loginWindow->HasExited) { delete loginWindow; loginWindow = NULL; } if(localBrowser && localBrowser->HasDone) { delete localBrowser; localBrowser = NULL; } }
void SampleTool::Draw(Simulation * sim, Brush * brush, ui::Point position) { if(gameModel->GetColourSelectorVisibility()) { pixel colour = gameModel->GetRenderer()->sampleColor; gameModel->SetColourSelectorColour(ui::Colour(PIXR(colour), PIXG(colour), PIXB(colour), 255)); } else { int particleType = 0; int particleCtype = 0; if (sim->photons[position.Y][position.X]) { particleType = sim->parts[ID(sim->photons[position.Y][position.X])].type; particleCtype = sim->parts[ID(sim->pmap[position.Y][position.X])].ctype; } else if (sim->pmap[position.Y][position.X]) { particleType = sim->parts[ID(sim->pmap[position.Y][position.X])].type; particleCtype = sim->parts[ID(sim->pmap[position.Y][position.X])].ctype; } if(particleType) { if(particleType == PT_LIFE) { Menu * lifeMenu = gameModel->GetMenuList()[SC_LIFE]; std::vector<Tool*> elementTools = lifeMenu->GetToolList(); for(std::vector<Tool*>::iterator iter = elementTools.begin(), end = elementTools.end(); iter != end; ++iter) { Tool * elementTool = *iter; if(elementTool && ID(elementTool->GetToolID()) == particleCtype) gameModel->SetActiveTool(0, elementTool); } } else { Tool * elementTool = gameModel->GetElementTool(particleType); if(elementTool) gameModel->SetActiveTool(0, elementTool); } } } }
void GameController::Update() { ui::Point pos = gameView->GetMousePosition(); gameModel->GetRenderer()->mousePos = PointTranslate(pos); if (pos.X < XRES && pos.Y < YRES) gameView->SetSample(gameModel->GetSimulation()->GetSample(PointTranslate(pos).X, PointTranslate(pos).Y)); else gameView->SetSample(gameModel->GetSimulation()->GetSample(pos.X, pos.Y)); Simulation * sim = gameModel->GetSimulation(); sim->BeforeSim(); if (!sim->sys_pause || sim->framerender) { sim->UpdateParticles(0, NPART); sim->AfterSim(); } //if either STKM or STK2 isn't out, reset it's selected element. Defaults to PT_DUST unless right selected is something else //This won't run if the stickmen dies in a frame, since it respawns instantly if (!sim->player.spwn || !sim->player2.spwn) { int rightSelected = PT_DUST; Tool * activeTool = gameModel->GetActiveTool(1); if (activeTool->GetIdentifier().find("DEFAULT_PT_") != activeTool->GetIdentifier().npos) { int sr = activeTool->GetToolID(); if (sr && sim->IsValidElement(sr)) rightSelected = sr; } if (!sim->player.spwn) Element_STKM::STKM_set_element(sim, &sim->player, rightSelected); if (!sim->player2.spwn) Element_STKM::STKM_set_element(sim, &sim->player2, rightSelected); } if(renderOptions && renderOptions->HasExited) { delete renderOptions; renderOptions = NULL; } if(search && search->HasExited) { delete search; search = NULL; } if(activePreview && activePreview->HasExited) { delete activePreview; activePreview = NULL; } if(loginWindow && loginWindow->HasExited) { delete loginWindow; loginWindow = NULL; } if(localBrowser && localBrowser->HasDone) { delete localBrowser; localBrowser = NULL; } }