Skip to content

Commit

Permalink
add ERASEALL wall from my mod (erases walls, particles, and signs)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob1 committed Aug 30, 2015
1 parent 12ef4ec commit 2ebc522
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
36 changes: 36 additions & 0 deletions src/graphics/Renderer.cpp
Expand Up @@ -627,6 +627,42 @@ VideoBuffer * Renderer::WallIcon(int wallID, int width, int height)
newTexture->SetPixel(-j+20, j, 0xFF, 0, 0, 255);
}
}
else if (wt == WL_ERASEALL)
{
for (int j = 0; j < height; j++)
{
int r = 100, g = 150, b = 50;
int rd = 1, gd = -1, bd = -1;
for (int i = 0; i < width; i++)
{
r += 15*rd;
g += 15*gd;
b += 15*bd;
if (r > 200) rd = -1;
if (g > 200) gd = -1;
if (b > 200) bd = -1;
if (r < 15) rd = 1;
if (g < 15) gd = 1;
if (b < 15) bd = 1;
int rc = std::min(150, std::max(0, r));
int gc = std::min(200, std::max(0, g));
int bc = std::min(200, std::max(0, b));
newTexture->SetPixel(i, j, rc, gc, bc, 255);
}
}
for (int j = 3; j < (width-4)/2; j++)
{
newTexture->SetPixel(j+0, j, 0xFF, 0, 0, 255);
newTexture->SetPixel(j+1, j, 0xFF, 0, 0, 255);
newTexture->SetPixel(-j+13, j, 0xFF, 0, 0, 255);
newTexture->SetPixel(-j+14, j, 0xFF, 0, 0, 255);

newTexture->SetPixel(j+11, j, 0xFF, 0, 0, 255);
newTexture->SetPixel(j+12, j, 0xFF, 0, 0, 255);
newTexture->SetPixel(-j+24, j, 0xFF, 0, 0, 255);
newTexture->SetPixel(-j+25, j, 0xFF, 0, 0, 255);
}
}
else if(wt == WL_STREAM)
{
for (j=0; j<height; j++)
Expand Down
18 changes: 16 additions & 2 deletions src/simulation/Simulation.cpp
Expand Up @@ -1123,7 +1123,21 @@ int Simulation::CreateWalls(int x, int y, int rx, int ry, int wall, Brush * cBru
}
if (wall == WL_GRAV || bmap[wallY][wallX] == WL_GRAV)
gravWallChanged = true;
bmap[wallY][wallX] = wall;

if (wall == WL_ERASEALL)
{
for (int i = 0; i < CELL; i++)
for (int j = 0; j < CELL; j++)
{
delete_part(wallX*CELL+i, wallY*CELL+j);
}
for (int i = signs.size()-1; i >= 0; i--)
if (signs[i].x >= wallX*CELL && signs[i].y >= wallY*CELL && signs[i].x <= (wallX+1)*CELL && signs[i].y <= (wallY+1)*CELL)
signs.erase(signs.begin()+i);
bmap[wallY][wallX] = 0;
}
else
bmap[wallY][wallX] = wall;
}
}
}
Expand Down Expand Up @@ -1208,7 +1222,7 @@ int Simulation::FloodWalls(int x, int y, int wall, int bm)
int x1, x2, dy = CELL;
if (bm==-1)
{
if (wall==WL_ERASE)
if (wall==WL_ERASE || wall==WL_ERASEALL)
{
bm = bmap[y/CELL][x/CELL];
if (!bm)
Expand Down
1 change: 1 addition & 0 deletions src/simulation/SimulationData.cpp
Expand Up @@ -131,6 +131,7 @@ wall_type * LoadWalls(int & wallCount)
{PIXPACK(0xFFEE00), PIXPACK(0xAA9900), 4, Renderer::WallIcon, "GRAVITY WALL", "Gravity wall. Newtonian Gravity has no effect inside a box drawn with this."},
{PIXPACK(0xFFAA00), PIXPACK(0xAA5500), 4, Renderer::WallIcon, "ENERGY WALL", "Allows energy particles, blocks all other particles."},
{PIXPACK(0xDCDCDC), PIXPACK(0x000000), 1, Renderer::WallIcon, "AIRBLOCK WALL", "Allows all particles, but blocks air."},
{PIXPACK(0x808080), PIXPACK(0x000000), 0, Renderer::WallIcon, "ERASEALL", "Erases walls, particles, and signs."},
};
wallCount = UI_WALLCOUNT;
wall_type * wtypesT = (wall_type*)malloc(UI_WALLCOUNT*sizeof(wall_type));
Expand Down
3 changes: 2 additions & 1 deletion src/simulation/SimulationData.h
Expand Up @@ -55,9 +55,10 @@
#define WL_GRAV 14
#define WL_ALLOWENERGY 15
#define WL_BLOCKAIR 16
#define WL_ERASEALL 17
#define WL_FLOODHELPER 255

#define UI_WALLCOUNT 17
#define UI_WALLCOUNT 18

#define OLD_SPC_AIR 236
#define SPC_AIR 256
Expand Down

0 comments on commit 2ebc522

Please sign in to comment.