aboutsummaryrefslogtreecommitdiff
path: root/client/gui/menus/main/background.gd
blob: 4abb84b456399d3472952ece183d8f17b39d669d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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())]