summaryrefslogtreecommitdiffstats
path: root/water/Wave.gd
blob: c876831e687c2547fdebf7226ac3eb1c19c1d3a3 (plain) (blame)
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
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