aboutsummaryrefslogtreecommitdiff
path: root/client/gui/menus/main/background.gd
diff options
context:
space:
mode:
Diffstat (limited to 'client/gui/menus/main/background.gd')
-rw-r--r--client/gui/menus/main/background.gd50
1 files changed, 50 insertions, 0 deletions
diff --git a/client/gui/menus/main/background.gd b/client/gui/menus/main/background.gd
new file mode 100644
index 00000000..4abb84b4
--- /dev/null
+++ b/client/gui/menus/main/background.gd
@@ -0,0 +1,50 @@
+# Hurry Curry! - a game about cooking
+# Copyright (C) 2025 Hurry Curry! contributors
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, version 3 of the License only.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+#
+extends Node3D
+
+const CRATES = ["tomato-crate", "steak-crate", "cheese-crate", "lettuce-crate", "flour-crate", "coconut-crate"]
+const TOOLS = ["stove", "stove", "stove", "sink", "cuttingboard", "sink", "cuttingboard", "oven", "freezer"]
+
+@onready var environment: WorldEnvironment = $Environment
+@onready var map: Map = $Map
+
+func _ready():
+ if !Global.on_vulkan():
+ environment.environment.tonemap_exposure = 0.25
+
+ var tiles = {}
+ for x in range(-10, 11):
+ for y in range(-10, 11):
+ var w = exp(-sqrt(x * x + y * y) * 0.15)
+ var k = randf() * w
+ var tn = null
+ if k > 0.25: tn = "floor"
+ if k > 0.4: tn = choose(CRATES) if randf() > 0.3 else "counter"
+ if k > 0.6: tn = choose(TOOLS)
+ if tn != null: tiles[str(Vector2i(x,y))] = [tn,[x,y]]
+
+ var gt = func (cs):
+ var t = tiles.get(str(Vector2i(cs[0],cs[1])))
+ return null if t == null else t[0]
+ for pk in tiles.keys():
+ var x = tiles[pk][1][0]
+ var y = tiles[pk][1][1]
+ var t = gt.call([x,y])
+ if t != null: map.set_tile(Vector2i(x,y), t, [[x,y-1],[x-1,y],[x,y+1],[x+1,y]].map(gt))
+
+ map.flush()
+
+func choose(a): return a[floor(a.size() * randf())]