summaryrefslogtreecommitdiffstats
path: root/water/Wave.gd
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2022-09-14 03:50:09 -0400
committerMalfurious <m@lfurio.us>2022-09-14 03:50:09 -0400
commit38b247487309ca89bf2d94bb321f12059861db9d (patch)
tree619a3acc15ca7051d5011b2ebaf18284ca1fad72 /water/Wave.gd
parent0d930d5548e4f705cf80f9c2334b804ab1359538 (diff)
downloadgodot_wildjam_49-38b247487309ca89bf2d94bb321f12059861db9d.tar.gz
godot_wildjam_49-38b247487309ca89bf2d94bb321f12059861db9d.zip
Consolidate water-related assets
Stray files are moved into a new directory. The water MeshInstance is made into a new scene, as I will be adding components to it.
Diffstat (limited to 'water/Wave.gd')
-rw-r--r--water/Wave.gd48
1 files changed, 48 insertions, 0 deletions
diff --git a/water/Wave.gd b/water/Wave.gd
new file mode 100644
index 0000000..c876831
--- /dev/null
+++ b/water/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