Guest User

Untitled

a guest
Mar 23rd, 2023
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. # Drag and drop input
  2.  
  3. var lh_selected = false
  4. var rh_selected = false
  5.  
  6. func lh_movement():
  7. if lh_selected == true:
  8. $Table/Player/LeftHand.position = get_global_mouse_position()
  9. else:
  10. $Table/Player/LeftHand.position = $Table/Player/LeftHand/OriginalPos.position
  11.  
  12.  
  13. func rh_movement():
  14. if rh_selected == true:
  15. $Table/Player/RightHand.position = get_global_mouse_position()
  16. else:
  17. $Table/Player/RightHand.position = $Table/Player/RightHand/OriginalPos.position
  18.  
  19.  
  20. func _on_playerlh_area_2d_input_event(viewport, event, shape_idx):
  21. if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
  22. if event.pressed:
  23. # Mouse clicked
  24. lh_selected = true
  25. else:
  26. # Mouse released
  27. lh_selected = false
  28.  
  29.  
  30. func _on_playerrh_area_2d_input_event(viewport, event, shape_idx):
  31. if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
  32. if event.pressed:
  33. # Mouse clicked
  34. rh_selected = true
  35. else:
  36. # Mouse released
  37. rh_selected = false
  38.  
  39. # --------------------------------------------------------------------------------------------------------------------
  40.  
  41. # Finger adding
  42.  
  43. var oppo_rh = 1
  44. var oppo_lh = 1
  45. var play_rh = 1
  46. var play_lh = 1
  47.  
  48. func _on_opponent_rh_area_2d_area_entered(area):
  49. var touched_hand = area.get_parent()
  50. if touched_hand.get_name() == "LeftHand" and touched_hand.get_parent().get_name() == "Player":
  51. oppo_rh += play_lh
  52. elif touched_hand.get_name() == "RightHand" and touched_hand.get_parent().get_name() == "Player":
  53. oppo_rh += play_rh
  54. elif touched_hand.get_name() == "LeftHand" and touched_hand.get_parent().get_name() == "Opponent":
  55. oppo_rh += oppo_lh
  56. elif touched_hand.get_name() == "RightHand" and touched_hand.get_parent().get_name() == "Opponent":
  57. oppo_rh += oppo_rh
  58. else:
  59. print("Error.")
  60.  
  61.  
  62. func _on_player_lh_area_2d_area_entered(area):
  63. var touched_hand = area.get_parent()
  64. if touched_hand.get_name() == "LeftHand" and touched_hand.get_parent().get_name() == "Player":
  65. play_lh += play_lh
  66. elif touched_hand.get_name() == "RightHand" and touched_hand.get_parent().get_name() == "Player":
  67. play_lh += play_rh
  68. elif touched_hand.get_name() == "LeftHand" and touched_hand.get_parent().get_name() == "Opponent":
  69. play_lh += oppo_lh
  70. elif touched_hand.get_name() == "RightHand" and touched_hand.get_parent().get_name() == "Opponent":
  71. play_lh += oppo_rh
  72. else:
  73. print("Error.")
  74.  
  75.  
  76. func _on_player_rh_area_2d_area_entered(area):
  77. var touched_hand = area.get_parent()
  78. if touched_hand.get_name() == "LeftHand" and touched_hand.get_parent().get_name() == "Player":
  79. play_rh += play_lh
  80. elif touched_hand.get_name() == "RightHand" and touched_hand.get_parent().get_name() == "Player":
  81. play_rh += play_rh
  82. elif touched_hand.get_name() == "LeftHand" and touched_hand.get_parent().get_name() == "Opponent":
  83. play_rh += oppo_lh
  84. elif touched_hand.get_name() == "RightHand" and touched_hand.get_parent().get_name() == "Opponent":
  85. play_rh += oppo_rh
  86. else:
  87. print("Error.")
Advertisement
Add Comment
Please, Sign In to add comment