Skip to content

Commit

Permalink
Added more frozen things, rainbow elements
Browse files Browse the repository at this point in the history
  • Loading branch information
kiwijuice56 committed Feb 11, 2024
1 parent 4e98c76 commit ad8979d
Show file tree
Hide file tree
Showing 25 changed files with 561 additions and 17 deletions.
Binary file modified .sconsign.dblite
Binary file not shown.
12 changes: 12 additions & 0 deletions extension/elements/all_elements.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@
#include "elements/basic/tempest_up.h"
#include "elements/basic/mine.h"
#include "elements/basic/megido.h"
#include "elements/life/alien.h"
#include "elements/basic/sprinkles.h"
#include "elements/basic/quartz.h"
#include "elements/space/freeze_ray.h"
#include "elements/chemical/frozen_acid.h"
#include "elements/chemical/frozen_ammonia.h"

class AllElements {
public:
Expand Down Expand Up @@ -313,6 +319,12 @@ class AllElements {
elements->at(147) = new TempestUp();
elements->at(148) = new Mine();
elements->at(149) = new Megido();
elements->at(150) = new Alien();
elements->at(151) = new Sprinkles();
elements->at(152) = new Quartz();
elements->at(153) = new FreezeRay();
elements->at(154) = new FrozenAcid();
elements->at(155) = new FrozenAmmonia();

for (int i = 2048; i <= 4096; i++) {
elements->at(i) = new CustomElementParticle();
Expand Down
36 changes: 36 additions & 0 deletions extension/elements/basic/quartz.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#ifndef QUARTZ_H
#define QUARTZ_H

#include "../element.h"

class Quartz: public Element {
public:
void process(SandSimulation *sim, int row, int col) override {
}

double get_density() override {
return 2.0;
}

double get_explode_resistance() override {
return 0.2;
}

double get_acid_resistance() override {
return 0.85;
}

int get_state() override {
return 0;
}

int get_temperature() override {
return 0;
}

int get_toxicity() override {
return 0;
}
};

#endif // QUARTZ_H
53 changes: 53 additions & 0 deletions extension/elements/basic/sprinkles.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#ifndef SPRINKLES_H
#define SPRINKLES_H

#include "../element.h"

class Sprinkles: public Element {
public:
const double FLAME = 1 / 64.0;
const double POWDER = 1 / 1.04;

void process(SandSimulation *sim, int row, int col) override {
if (sim->randf() >= POWDER)
return;
bool bot_left = sim->is_swappable(row, col, row + 1, col - 1);
bool bot = sim->is_swappable(row, col, row + 1, col);
bool bot_right = sim->is_swappable(row, col, row + 1, col + 1);
if (bot) {
sim->move_and_swap(row, col, row + 1, col);
} else if (bot_left && bot_right) {
sim->move_and_swap(row, col, row + 1, col + (sim->randf() < 0.5 ? 1 : -1));
} else if (bot_left) {
sim->move_and_swap(row, col, row + 1, col - 1);
} else if (bot_right) {
sim->move_and_swap(row, col, row + 1, col + 1);
}
}

double get_density() override {
return 2.0;
}

double get_explode_resistance() override {
return 0.05;
}

double get_acid_resistance() override {
return 0.2;
}

int get_state() override {
return 0;
}

int get_temperature() override {
return 0;
}

int get_toxicity() override {
return 0;
}
};

#endif // SPRINKLES_H
5 changes: 5 additions & 0 deletions extension/elements/chemical/acid.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ class Acid: public Element {
return;
}

if (sim->is_cold(row, col)) {
sim->set_cell(row, col, 154);
return;
}

// Evaporate into acid gas
if (sim->randf() < EVAPORATE && sim->is_on_fire(row, col)) {
sim->set_cell(row, col, 22);
Expand Down
5 changes: 5 additions & 0 deletions extension/elements/chemical/acid_water.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ class AcidWater: public Element {
return;
}

if (sim->is_cold(row, col)) {
sim->set_cell(row, col, 154);
return;
}

// Evaporate into acid gas
if (sim->randf() < EVAPORATE && sim->is_on_fire(row, col)) {
sim->set_cell(row, col, sim->randf() < 0.5 ? 22 : 58);
Expand Down
5 changes: 5 additions & 0 deletions extension/elements/chemical/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ class Base: public Element {
return;
}

if (sim->is_cold(row, col)) {
sim->set_cell(row, col, 155);
return;
}

sim->liquid_process(row, col, 2);

bool blocked = !sim->in_bounds(row + 1, col) || sim->get_cell(row + 1, col) == 3;
Expand Down
60 changes: 60 additions & 0 deletions extension/elements/chemical/frozen_acid.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#ifndef FROZEN_ACID_H
#define FROZEN_ACID_H

#include "../element.h"

class FrozenAcid: public Element {
public:
const double GROW = 1.0 / 256;
const double FLAME = 1.0 / 128;

void process(SandSimulation *sim, int row, int col) override {
// Melt
if (sim->randf() < FLAME && sim->is_on_fire(row, col)) {
sim->set_cell(row, col, 21);
return;
}

if (sim->randf() >= GROW) {
return;
}

// We need to empty this cell for ice branching checks
sim->set_cell(row, col, 0);
int dir = (int) (sim->randf() * 3) - 1;
if (dir != 0 && sim->cardinal_touch_count(row, col + dir, 154) == 0) {
sim->grow(row, col + dir, 21, 154);
sim->grow(row, col + dir, 59, 154);
} else if (sim->cardinal_touch_count(row + 1, col, 154) == 0) {
sim->grow(row + 1, col, 21, 154);
sim->grow(row + 1, col, 59, 154);
}
sim->set_cell(row, col, 154);
}

double get_density() override {
return 1.1;
}

double get_explode_resistance() override {
return 0.35;
}

double get_acid_resistance() override {
return 1.0;
}

int get_state() override {
return 0;
}

int get_temperature() override {
return 0;
}

int get_toxicity() override {
return 0;
}
};

#endif // FROZEN_ACID_H
58 changes: 58 additions & 0 deletions extension/elements/chemical/frozen_ammonia.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#ifndef FROZEN_AMMONIA_H
#define FROZEN_AMMONIA_H

#include "../element.h"

class FrozenAmmonia: public Element {
public:
const double GROW = 1.0 / 256;
const double FLAME = 1.0 / 128;

void process(SandSimulation *sim, int row, int col) override {
// Melt
if (sim->randf() < FLAME && sim->is_on_fire(row, col)) {
sim->set_cell(row, col, 136);
return;
}

if (sim->randf() >= GROW) {
return;
}

// We need to empty this cell for ice branching checks
sim->set_cell(row, col, 0);
int dir = (int) (sim->randf() * 3) - 1;
if (dir != 0 && sim->cardinal_touch_count(row, col + dir, 155) == 0) {
sim->grow(row, col + dir, 136, 155);
} else if (sim->cardinal_touch_count(row + 1, col, 155) == 0) {
sim->grow(row + 1, col, 136, 155);
}
sim->set_cell(row, col, 155);
}

double get_density() override {
return 1.1;
}

double get_explode_resistance() override {
return 0.35;
}

double get_acid_resistance() override {
return 1.0;
}

int get_state() override {
return 0;
}

int get_temperature() override {
return 0;
}

int get_toxicity() override {
return 0;
}
};

#endif // FROZEN_AMMONIA_H
43 changes: 43 additions & 0 deletions extension/elements/life/alien.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#ifndef ALIEN_H
#define ALIEN_H

#include "../element.h"

class Alien: public Element {
public:
const double GROWTH = 0.0049625;
const double DISSOLVE = 1.0 / 64;

void process(SandSimulation *sim, int row, int col) override {
sim->grow(row + 1, col, 0, 150);
sim->grow(row - 1, col, 0, 150);
sim->grow(row, col + 1, 0, 150);
sim->grow(row, col - 1, 0, 150);
}

double get_density() override {
return 1.25;
}

double get_explode_resistance() override {
return 0.55;
}

double get_acid_resistance() override {
return 0.85;
}

int get_state() override {
return 0;
}

int get_temperature() override {
return 0;
}

int get_toxicity() override {
return 0;
}
};

#endif // ALIEN_H
46 changes: 46 additions & 0 deletions extension/elements/space/freeze_ray.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#ifndef FREEZE_RAY_H
#define FREEZE_RAY_H

#include "../element.h"

class FreezeRay: public Element {
public:
const double DECAY = 1.0 / 1.5;
const double DESTROY = 1.0 / 24;
void process(SandSimulation *sim, int row, int col) override {
if (sim->randf() < DECAY && sim->in_bounds(row - 1, col) && sim->get_cell(row - 1, col) != 153) {
sim->set_cell(row, col, 89);
return;
}
if (sim->randf() < DESTROY) {
sim->grow(row + 1, col, -1, 153);
sim->grow(row + 2, col, -1, 153);
}
}

double get_density() override {
return 4.0;
}

double get_explode_resistance() override {
return 1.0;
}

double get_acid_resistance() override {
return 1.0;
}

int get_state() override {
return 0;
}

int get_temperature() override {
return -1;
}

int get_toxicity() override {
return 0;
}
};

#endif // FREEZE_RAY_H
Binary file modified extension/register_types.windows.template_debug.x86_64.obj
Binary file not shown.
Loading

0 comments on commit ad8979d

Please sign in to comment.