summaryrefslogtreecommitdiffstats
path: root/Wave.gd
diff options
context:
space:
mode:
authordusoleil <howcansocksbereal@gmail.com>2022-09-12 20:40:16 -0400
committerdusoleil <howcansocksbereal@gmail.com>2022-09-12 20:40:16 -0400
commit5dbc9c05c1ebd33e37315c096d2c9e1c6b96a8f2 (patch)
tree69d854f59caa94661eb621f274545170b4521d36 /Wave.gd
parent9a6b5ec01961c6ab3f13f72ff4ec4545c896d151 (diff)
downloadgame_jam49-5dbc9c05c1ebd33e37315c096d2c9e1c6b96a8f2.tar.gz
game_jam49-5dbc9c05c1ebd33e37315c096d2c9e1c6b96a8f2.zip
Add gertsner wave shader
Diffstat (limited to 'Wave.gd')
-rw-r--r--Wave.gd48
1 files changed, 48 insertions, 0 deletions
diff --git a/Wave.gd b/Wave.gd
new file mode 100644
index 0000000..c876831
--- /dev/null
+++ b/Wave.gd
@@ -0,0 +1,48 @@
+class_name Wave
+extends Resource
+
+export var steepness = 1.0 setget set_steepness
+export var wavelength = 1.0 setget set_wavelength
+export var direction = Vector2(1.0,0.0) setget set_direction
+
+var _k = 1.0 setget _set_k
+var _a = 1.0 setget _set_a
+var _c = 1.0 setget _set_c
+var _time = 0.0 setget _set_time
+var _t = 1.0 setget _set_t
+
+func _init(s, w, d, t):
+ self.steepness = s
+ self.wavelength = w
+ self.direction = d
+ self._time = t
+
+func set_steepness(val):
+ steepness = val
+ self._a = steepness / _k
+
+func set_wavelength(val):
+ wavelength = val
+ self._k = TAU / wavelength
+
+func set_direction(val):
+ direction = val
+
+func _set_k(val):
+ _k = val
+ self._a = steepness / _k
+ self._c = sqrt(9.8 / _k)
+
+func _set_a(val):
+ _a = val
+
+func _set_c(val):
+ _c = val
+ self._t = _c * _time
+
+func _set_time(val):
+ _time = val
+ self._t = _c * _time
+
+func _set_t(val):
+ _t = val