sevivon-prototype

[RADIOACTIVE] a concept version of sevivon
git clone git://git.figbert.com/sevivon-prototype.git
Log | Files | Refs | README | LICENSE

commit 5e2bc01c808f4d2d41b4ac2dc3cd1ed78af8d438
parent 85f3961aee3faf590df40d097e51312777adb402
Author: FIGBERT <figbert@figbert.com>
Date:   Sun,  3 Jan 2021 15:52:01 -0800

Separate sevivon spin code to a spin function

Diffstat:
Mgodot/scripts/sevivon.gd | 11+++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/godot/scripts/sevivon.gd b/godot/scripts/sevivon.gd @@ -10,7 +10,10 @@ var has_spun = false func _physics_process(_delta): var accel = Input.get_accelerometer() if accel.length() > ACCEL_THRESHOLD: - randomize() - angular_velocity = Vector3(rand_range(MIN_ANGLE, MAX_ANGLE), 0, rand_range(MIN_ANGLE, MAX_ANGLE)) - apply_torque_impulse(Vector3.UP * accel.length() * rand_range(MIN_FORCE, MAX_FORCE)) - has_spun = true + spin(accel) + +func spin(accel: Vector3): + randomize() + angular_velocity = Vector3(rand_range(MIN_ANGLE, MAX_ANGLE), 0, rand_range(MIN_ANGLE, MAX_ANGLE)) + apply_torque_impulse(Vector3.UP * accel.length() * rand_range(MIN_FORCE, MAX_FORCE)) + has_spun = true