Skip to content

Commit

Permalink
Added the glagglers
Browse files Browse the repository at this point in the history
  • Loading branch information
kiwijuice56 committed Feb 17, 2024
1 parent 0872680 commit 791a928
Show file tree
Hide file tree
Showing 14 changed files with 239 additions and 4 deletions.
Binary file modified .sconsign.dblite
Binary file not shown.
6 changes: 6 additions & 0 deletions extension/elements/all_elements.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@
#include "elements/life/mushroom_shell_c.h"
#include "elements/basic/bedrock.h"
#include "elements/space/missile.h"
#include "elements/basic/glaggler_seed.h"
#include "elements/basic/glaggler_eye.h"
#include "elements/basic/glaggler_face.h"

class AllElements {
public:
Expand Down Expand Up @@ -363,6 +366,9 @@ class AllElements {
elements->at(172) = new MushroomShellC();
elements->at(173) = new Bedrock();
elements->at(174) = new Missile();
elements->at(175) = new GlagglerSeed();
elements->at(176) = new GlagglerEye();
elements->at(177) = new GlagglerFace();


for (int i = 2048; i <= 4096; i++) {
Expand Down
41 changes: 41 additions & 0 deletions extension/elements/basic/glaggler_eye.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef GLAGGLER_H
#define GLAGGLER_H

#include "../element.h"

class GlagglerEye: public Element {
public:
const double DECAY = 1.0 / 2048;

void process(SandSimulation *sim, int row, int col) override {
if (sim->randf() < DECAY) {
sim->set_cell(row, col, 177);
}
}

double get_density() override {
return 129.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 1;
}
};

#endif // GLAGGLER_H
41 changes: 41 additions & 0 deletions extension/elements/basic/glaggler_face.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef GLAGGLER_FACE
#define GLAGGLER_FACE

#include "../element.h"

class GlagglerFace: public Element {
public:
const double DECAY = 1.0 / 2048;

void process(SandSimulation *sim, int row, int col) override {
if (sim->randf() < DECAY) {
sim->set_cell(row, col, 9);
}
}

double get_density() override {
return 129.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 1;
}
};

#endif // GLAGGLER_FACE
88 changes: 88 additions & 0 deletions extension/elements/basic/glaggler_seed.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#ifndef GLAGGLER_SEED_H
#define GLAGGLER_SEED_H

#include "../element.h"

class GlagglerSeed: public Element {
public:
const double FLAME = 1 / 64.0;
const double POWDER = 1 / 1.05;
const double AWAKEN = 1 / 2048.0;

void process(SandSimulation *sim, int row, int col) override {
if (sim->randf() >= POWDER)
return;
if (sim->randf() < FLAME && sim->is_on_fire(row, col)) {
sim->set_cell(row, col, 20);
return;
}
if (sim->randf() < AWAKEN) {
for (int i = -4; i <= 4; i++) {
for (int j = -3; j <= 4; j++) {
if (!sim->in_bounds(row + j, col + i)) {
continue;
}
if ((j == -3 || j == 4) && (i <= -3 || i >= 3)) {
continue;
}
if ((j == -2 || j == 3) && (i <= -4 || i >= 4)) {
continue;
}

if (j == -1 && (i == -1 || i == 1)) {
sim->set_cell(row + j, col + i, 176);
continue;
}
if (j == 1 && (i == -3 || i == 3)) {
sim->set_cell(row + j, col + i, 176);
continue;
}
if (j == 2 && (i >= -2 && i <= 2)) {
sim->set_cell(row + j, col + i, 176);
continue;
}
sim->set_cell(row + j, col + i, 177);
}
}
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.85;
}

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 // GLAGGLER_SEED_H
1 change: 0 additions & 1 deletion extension/elements/space/missile.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class Missile: public Element {
}
}
}
return;
}


Expand Down
Binary file modified extension/sand_simulation.windows.template_debug.x86_64.obj
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions game/main/element_manager/element_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ func create_new_element() -> void:
var new_element: CustomElement = CustomElement.new()
new_element.id = id
new_element.display_name = RandomName.NAMES.pick_random()
new_element.color_a = Color.from_hsv(randf(), randf(), randf())
new_element.color_a = Color.from_hsv(randf(), randf() * 0.5 + 0.5, randf() * 0.5 + 0.5)
if randf() < 0.5:
new_element.style = 0
new_element.color_b = new_element.color_a
new_element.color_c = new_element.color_a
else:
new_element.style = 1
new_element.color_b = Color.from_hsv(randf(), randf(), randf())
new_element.color_b = Color.from_hsv(randf(), randf() * 0.5 + 0.5, randf() * 0.5 + 0.5)
new_element.color_c = Color.from_hsv(randf(), randf(), randf())
new_element.state = randi() % 4
new_element.density = randf()
Expand Down
8 changes: 8 additions & 0 deletions game/main/element_manager/element_material/glaggler_core.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[gd_resource type="Resource" script_class="FlatColor" load_steps=2 format=3 uid="uid://ohoxfasxfhd0"]

[ext_resource type="Script" path="res://main/element_manager/element_material/types/flat_color.gd" id="1_o4fod"]

[resource]
script = ExtResource("1_o4fod")
color = Color(1, 0.180392, 0.0705882, 1)
id = 175
8 changes: 8 additions & 0 deletions game/main/element_manager/element_material/glaggler_eye.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[gd_resource type="Resource" script_class="FlatColor" load_steps=2 format=3 uid="uid://c87kkvoi5mt46"]

[ext_resource type="Script" path="res://main/element_manager/element_material/types/flat_color.gd" id="1_wir3g"]

[resource]
script = ExtResource("1_wir3g")
color = Color(0.0196078, 0.0196078, 0.0196078, 1)
id = 176
8 changes: 8 additions & 0 deletions game/main/element_manager/element_material/glaggler_face.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[gd_resource type="Resource" script_class="FlatColor" load_steps=2 format=3 uid="uid://cr12s2venmd83"]

[ext_resource type="Script" path="res://main/element_manager/element_material/types/flat_color.gd" id="1_8b4kr"]

[resource]
script = ExtResource("1_8b4kr")
color = Color(1, 0.94902, 0, 1)
id = 177
5 changes: 5 additions & 0 deletions game/main/painter/painter.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class_name Painter
# be registered in the Godot class database.
var is_powder: Dictionary = {}
var is_fluid: Dictionary = {}
var is_super_powder: Dictionary = {}

# Reference to the simulation from Main for less verbose access
var sim: SandSimulation
Expand All @@ -29,6 +30,8 @@ func _ready() -> void:
is_fluid[i] = true
for i in [1, 11, 12, 16, 42, 4, 8, 23, 31, 32, 33, 49, 63, 64, 45, 70, 72, 75, 85, 95, 98, 119, 128, 130, 162, 159, 157, 164, 168, 174]:
is_powder[i] = true
for i in [175]:
is_super_powder[i] = true
mouse_pressed.connect(_on_mouse_pressed)

func _process(_delta: float) -> void:
Expand Down Expand Up @@ -128,6 +131,8 @@ func draw_pixel(row: float, col: float) -> void:
# Powders must have some random noise in order to prevent stacking behavior
if selected_element in is_powder and randf() > 0.1:
return
if selected_element in is_super_powder and randf() > 0.01:
return

var y: int = roundi(row)
var x: int = roundi(col)
Expand Down
33 changes: 32 additions & 1 deletion game/main/ui/element_selector/ElementSelector.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=289 format=3 uid="uid://danjqv04qm3f6"]
[gd_scene load_steps=292 format=3 uid="uid://danjqv04qm3f6"]

[ext_resource type="Theme" uid="uid://co20v1mxv2dfm" path="res://main/ui/_theme/theme.tres" id="1_c5upu"]
[ext_resource type="Script" path="res://main/ui/element_selector/element_selector.gd" id="1_fxkbl"]
Expand Down Expand Up @@ -426,6 +426,15 @@ bg_color = Color(0.568627, 0.447059, 0.337255, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_aykbh"]
bg_color = Color(0.419608, 0.188235, 0.211765, 1)

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_p00hi"]
bg_color = Color(1, 0.94902, 0, 1)

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_5rqoh"]
bg_color = Color(1, 0.992157, 0.560784, 1)

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_fkrxu"]
bg_color = Color(0.670588, 0.392157, 0, 1)

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_crjli"]
bg_color = Color(0.0784314, 0.0156863, 0.345098, 1)

Expand Down Expand Up @@ -1772,6 +1781,28 @@ script = ExtResource("3_bfdgk")
id = 158
description = "A poor creature that attacks all other life."

[node name="Glaggler" type="Button" parent="basic/Basic"]
custom_minimum_size = Vector2(0, 48)
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
focus_mode = 0
mouse_filter = 1
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_colors/font_pressed_color = Color(0, 0, 0, 1)
theme_override_colors/font_hover_color = Color(0, 0, 0, 1)
theme_override_colors/font_focus_color = Color(0, 0, 0, 1)
theme_override_colors/font_hover_pressed_color = Color(0, 0, 0, 1)
theme_override_colors/font_disabled_color = Color(0, 0, 0, 1)
theme_override_font_sizes/font_size = 15
theme_override_styles/normal = SubResource("StyleBoxFlat_p00hi")
theme_override_styles/hover = SubResource("StyleBoxFlat_5rqoh")
theme_override_styles/pressed = SubResource("StyleBoxFlat_fkrxu")
text = "glaggler"
script = ExtResource("3_bfdgk")
id = 175
description = "Unpredictable, intelligent, and reclusive. Can only manifest itself for a brief moment."

[node name="Spiral" type="Button" parent="basic/Basic"]
custom_minimum_size = Vector2(0, 48)
layout_mode = 2
Expand Down

0 comments on commit 791a928

Please sign in to comment.