diff options
author | Henrique Alves <henriquelalves@gmail.com> | 2022-07-16 00:05:43 -0300 |
---|---|---|
committer | Henrique Alves <henriquelalves@gmail.com> | 2022-07-16 00:05:43 -0300 |
commit | ef33112d4c103b8d7ff7fb7a5773bf31075eb131 (patch) | |
tree | 4a8e7f2106b69d9505afdad197692a417d981315 | |
parent | 5bfa4635f3953dc3687712687b17b8f37b7df287 (diff) | |
parent | 49b8f91e74cd15c76c82a485b046493171e590ef (diff) | |
download | gamejam-gmtk-2022-ef33112d4c103b8d7ff7fb7a5773bf31075eb131.tar.gz gamejam-gmtk-2022-ef33112d4c103b8d7ff7fb7a5773bf31075eb131.tar.bz2 gamejam-gmtk-2022-ef33112d4c103b8d7ff7fb7a5773bf31075eb131.zip |
Merge remote-tracking branch 'origin/main'
-rw-r--r-- | Scenes/Player.gd | 29 | ||||
-rw-r--r-- | Scenes/Player.tscn | 4 |
2 files changed, 25 insertions, 8 deletions
diff --git a/Scenes/Player.gd b/Scenes/Player.gd index 057a198..b94afa6 100644 --- a/Scenes/Player.gd +++ b/Scenes/Player.gd @@ -30,11 +30,12 @@ const chart_spin = [ [0, 2, 3, 0], ] +onready var mesh = $Mesh + var symbols = ['1', '3', '5', '2', '4', '6'] var side = 0 var spin = 0 -var idle = true func get_top(): return symbols[side] @@ -65,8 +66,26 @@ func get_upper_face(): return get_top() func cor_move(args : Array): # args = [Vector3] - var new_pos = args[0] - var dir = Vector2(new_pos.x - translation.x, new_pos.z - translation.z) - $Mesh.roll(dir) + var pos_a = translation + var pos_b = args[0] + + var dir = pos_b - pos_a + + var basis_a = mesh.transform.basis + var basis_b = basis_a.rotated(Vector3(dir.z, 0, -dir.x), PI / 2) + + var duration = 0.2 + var time = 0 + + while true: + time = min(time + get_process_delta_time(), duration) + var weight = time / duration + + translation = pos_a + dir * weight + mesh.transform.basis = basis_a.slerp(basis_b, weight) + mesh.translation = Vector3(0, 0.5 + sin(weight * PI) / 4, 0) + + if time >= duration: + break - yield(.cor_move(args), "completed") + yield(get_tree(), "idle_frame") diff --git a/Scenes/Player.tscn b/Scenes/Player.tscn index 17684fe..a24398f 100644 --- a/Scenes/Player.tscn +++ b/Scenes/Player.tscn @@ -1,7 +1,6 @@ -[gd_scene load_steps=15 format=2] +[gd_scene load_steps=14 format=2] [ext_resource path="res://Scenes/Player.gd" type="Script" id=1] -[ext_resource path="res://Scenes/Mesh.gd" type="Script" id=2] [ext_resource path="res://Assets/5_dots.png" type="Texture" id=3] [ext_resource path="res://Assets/DiceFaceMaterial.tres" type="Material" id=4] [ext_resource path="res://Assets/3_dots.png" type="Texture" id=5] @@ -32,7 +31,6 @@ actionable = true [node name="Mesh" type="Spatial" parent="."] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0 ) -script = ExtResource( 2 ) [node name="FaceUp" type="MeshInstance" parent="Mesh"] transform = Transform( 1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0.5, 0 ) |