diff options
author | Henrique Alves <henriquelalves@gmail.com> | 2022-07-16 00:46:36 -0300 |
---|---|---|
committer | Henrique Alves <henriquelalves@gmail.com> | 2022-07-16 00:46:36 -0300 |
commit | 88e693070db521a930b1ca7dff225e0c5b5cdec8 (patch) | |
tree | 97407d2caef5f05f6a4b16e0027da5c3c88abee9 | |
parent | c679cf2d5d20c50dbf1c9e6fd7ac302af0c9d859 (diff) | |
parent | d415ef0ed7bcab15f41e03083cb286b03870b414 (diff) | |
download | gamejam-gmtk-2022-88e693070db521a930b1ca7dff225e0c5b5cdec8.tar.gz gamejam-gmtk-2022-88e693070db521a930b1ca7dff225e0c5b5cdec8.tar.bz2 gamejam-gmtk-2022-88e693070db521a930b1ca7dff225e0c5b5cdec8.zip |
Merge remote-tracking branch 'origin/main'
-rw-r--r-- | Scenes/Dungeon.gd | 3 | ||||
-rw-r--r-- | Scenes/Player.gd | 22 |
2 files changed, 22 insertions, 3 deletions
diff --git a/Scenes/Dungeon.gd b/Scenes/Dungeon.gd index 2e95fd7..0092c6a 100644 --- a/Scenes/Dungeon.gd +++ b/Scenes/Dungeon.gd @@ -112,6 +112,7 @@ func move_player(dir : Vector2): var new_tile = cur_tile + dir if tiles_entities.has(new_tile): + player.add_action("cor_shake", [0.2]) return tiles_entities.erase(cur_tile) @@ -119,7 +120,7 @@ func move_player(dir : Vector2): #player_check_attack(new_tile) - player.add_action("cor_move", [tile_to_pos(new_tile)]) + player.add_action("cor_move", [tile_to_pos(new_tile), 0.2]) player.roll(dir) func tile_to_pos(tile : Vector2): diff --git a/Scenes/Player.gd b/Scenes/Player.gd index b94afa6..145af4f 100644 --- a/Scenes/Player.gd +++ b/Scenes/Player.gd @@ -65,7 +65,7 @@ func get_cardinal(direction: Vector2): func get_upper_face(): return get_top() -func cor_move(args : Array): # args = [Vector3] +func cor_move(args : Array): # args = [Vector3, float] var pos_a = translation var pos_b = args[0] @@ -74,7 +74,7 @@ func cor_move(args : Array): # args = [Vector3] 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 duration = args[1] var time = 0 while true: @@ -89,3 +89,21 @@ func cor_move(args : Array): # args = [Vector3] break yield(get_tree(), "idle_frame") + +func cor_shake(args : Array): + var duration = args[0] + var time = 0 + + var zero = Vector3(0, 0.5, 0) + var intensity = 0.02 + + while true: + time = min(time + get_process_delta_time(), duration) + + mesh.translation = zero + (2 * Vector3(randf(), randf(), randf()) - Vector3.ONE) * intensity + + if time >= duration: + mesh.translation = zero + break + + yield(get_tree(), "idle_frame") |