mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-19 06:31:26 +02:00
Air invert and grid mode switching
This commit is contained in:
@@ -231,6 +231,20 @@ void GameController::Install()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameController::AdjustGridSize(int direction)
|
||||||
|
{
|
||||||
|
if(direction > 0)
|
||||||
|
gameModel->GetRenderer()->SetGridSize((gameModel->GetRenderer()->GetGridSize()+1)%10);
|
||||||
|
else
|
||||||
|
gameModel->GetRenderer()->SetGridSize((gameModel->GetRenderer()->GetGridSize()+9)%10);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameController::InvertAirSim()
|
||||||
|
{
|
||||||
|
gameModel->GetSimulation()->air->Invert();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GameController::AdjustBrushSize(int direction, bool logarithmic, bool xAxis, bool yAxis)
|
void GameController::AdjustBrushSize(int direction, bool logarithmic, bool xAxis, bool yAxis)
|
||||||
{
|
{
|
||||||
if(xAxis && yAxis)
|
if(xAxis && yAxis)
|
||||||
|
@@ -69,6 +69,8 @@ public:
|
|||||||
|
|
||||||
void Install();
|
void Install();
|
||||||
|
|
||||||
|
void AdjustGridSize(int direction);
|
||||||
|
void InvertAirSim();
|
||||||
void LoadRenderPreset(RenderPreset preset);
|
void LoadRenderPreset(RenderPreset preset);
|
||||||
void SetZoomEnabled(bool zoomEnable);
|
void SetZoomEnabled(bool zoomEnable);
|
||||||
void SetZoomPosition(ui::Point position);
|
void SetZoomPosition(ui::Point position);
|
||||||
|
@@ -1243,6 +1243,12 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
|||||||
case 'f':
|
case 'f':
|
||||||
c->FrameStep();
|
c->FrameStep();
|
||||||
break;
|
break;
|
||||||
|
case 'g':
|
||||||
|
if(shift)
|
||||||
|
c->AdjustGridSize(-1);
|
||||||
|
else
|
||||||
|
c->AdjustGridSize(1);
|
||||||
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
showDebug = !showDebug;
|
showDebug = !showDebug;
|
||||||
break;
|
break;
|
||||||
@@ -1345,6 +1351,8 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
|||||||
case 'i':
|
case 'i':
|
||||||
if(ctrl)
|
if(ctrl)
|
||||||
c->Install();
|
c->Install();
|
||||||
|
else
|
||||||
|
c->InvertAirSim();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1086,17 +1086,17 @@ void Renderer::render_parts()
|
|||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo);
|
||||||
glTranslated(0, MENUSIZE, 0);
|
glTranslated(0, MENUSIZE, 0);
|
||||||
#else
|
#else
|
||||||
/*if (GRID_MODE)//draws the grid
|
if (gridSize)//draws the grid
|
||||||
{
|
{
|
||||||
for (ny=0; ny<YRES; ny++)
|
for (ny=0; ny<YRES; ny++)
|
||||||
for (nx=0; nx<XRES; nx++)
|
for (nx=0; nx<XRES; nx++)
|
||||||
{
|
{
|
||||||
if (ny%(4*GRID_MODE)==0)
|
if (ny%(4*gridSize)==0)
|
||||||
blendpixel(nx, ny, 100, 100, 100, 80);
|
blendpixel(nx, ny, 100, 100, 100, 80);
|
||||||
if (nx%(4*GRID_MODE)==0)
|
if (nx%(4*gridSize)==0)
|
||||||
blendpixel(nx, ny, 100, 100, 100, 80);
|
blendpixel(nx, ny, 100, 100, 100, 80);
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
#endif
|
#endif
|
||||||
for(i = 0; i<=sim->parts_lastActiveIndex; i++) {
|
for(i = 0; i<=sim->parts_lastActiveIndex; i++) {
|
||||||
if (sim->parts[i].type) {
|
if (sim->parts[i].type) {
|
||||||
@@ -2284,7 +2284,8 @@ Renderer::Renderer(Graphics * g, Simulation * sim):
|
|||||||
mousePosY(-1),
|
mousePosY(-1),
|
||||||
display_mode(0),
|
display_mode(0),
|
||||||
render_mode(0),
|
render_mode(0),
|
||||||
colour_mode(0)
|
colour_mode(0),
|
||||||
|
gridSize(0)
|
||||||
{
|
{
|
||||||
this->g = g;
|
this->g = g;
|
||||||
this->sim = sim;
|
this->sim = sim;
|
||||||
|
@@ -131,12 +131,16 @@ public:
|
|||||||
void SetColourMode(unsigned int mode);
|
void SetColourMode(unsigned int mode);
|
||||||
unsigned int GetColourMode();
|
unsigned int GetColourMode();
|
||||||
|
|
||||||
|
int GetGridSize() { return gridSize; }
|
||||||
|
void SetGridSize(int value) { gridSize = value; }
|
||||||
|
|
||||||
static VideoBuffer * WallIcon(int wallID, int width, int height);
|
static VideoBuffer * WallIcon(int wallID, int width, int height);
|
||||||
|
|
||||||
Renderer(Graphics * g, Simulation * sim);
|
Renderer(Graphics * g, Simulation * sim);
|
||||||
~Renderer();
|
~Renderer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
int gridSize;
|
||||||
#ifdef OGLR
|
#ifdef OGLR
|
||||||
GLuint zoomTex, airBuf, fireAlpha, glowAlpha, blurAlpha, partsFboTex, partsFbo, partsTFX, partsTFY, airPV, airVY, airVX;
|
GLuint zoomTex, airBuf, fireAlpha, glowAlpha, blurAlpha, partsFboTex, partsFbo, partsTFX, partsTFY, airPV, airVY, airVX;
|
||||||
GLuint fireProg, airProg_Pressure, airProg_Velocity, airProg_Cracker, lensProg;
|
GLuint fireProg, airProg_Pressure, airProg_Velocity, airProg_Cracker, lensProg;
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <algorithm>
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "Air.h"
|
#include "Air.h"
|
||||||
//#include <powder.h>
|
//#include <powder.h>
|
||||||
@@ -295,6 +296,19 @@ void Air::update_air(void)
|
|||||||
memcpy(pv, opv, sizeof(pv));
|
memcpy(pv, opv, sizeof(pv));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Air::Invert()
|
||||||
|
{
|
||||||
|
int nx, ny;
|
||||||
|
for (nx = 0; nx<XRES/CELL; nx++)
|
||||||
|
for (ny = 0; ny<YRES/CELL; ny++)
|
||||||
|
{
|
||||||
|
pv[ny][nx] = -pv[ny][nx];
|
||||||
|
vx[ny][nx] = -vx[ny][nx];
|
||||||
|
vy[ny][nx] = -vy[ny][nx];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Air::Air():
|
Air::Air():
|
||||||
airMode(0)
|
airMode(0)
|
||||||
{
|
{
|
||||||
|
@@ -29,6 +29,7 @@ public:
|
|||||||
void update_airh(void);
|
void update_airh(void);
|
||||||
void update_air(void);
|
void update_air(void);
|
||||||
void Clear();
|
void Clear();
|
||||||
|
void Invert();
|
||||||
Air();
|
Air();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user