moved bouncy card code to card
This commit is contained in:
parent
df9018ec9e
commit
7f542c3412
|
|
@ -35,7 +35,8 @@ var selected_card_for_assignment
|
|||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
|
||||
var test_arr = ["c_Joy","p_effort","c_backlash","c_body","c_hit","p_slut","p_worried_mother","p_cross_friend"]
|
||||
#var test_arr = ["c_Joy","p_effort","c_backlash","c_body","c_hit","p_slut","p_worried_mother","p_cross_friend"]
|
||||
var test_arr = ["c_Joy","c_body","c_hit"]
|
||||
|
||||
populate_board(test_arr)
|
||||
reorder_areas("dropzone_content")
|
||||
|
|
@ -83,7 +84,7 @@ func populate_board(card_names: Array):
|
|||
dropzone.add_child(new_card)
|
||||
new_card.set_owner(self)
|
||||
area_dict["dropzone_content"].push_back(new_card)
|
||||
new_card.global_position = Vector2(300, 200) # using hard-coded position because I'm lazy
|
||||
new_card.global_position = Vector2(500, 500) # using hard-coded position because I'm lazy
|
||||
new_card.is_dragable = true
|
||||
if "p_" in card_name: # spawning a post-it
|
||||
var new_postit = _find_area_by_string(all_postits, card_name).duplicate()
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ var on_stage = false
|
|||
@export var wiggle_strength: float = 0.2
|
||||
@export var wiggle_speed: float = 5
|
||||
@export_range(1, 2) var scale_bump: float = 1.05
|
||||
@export_range(1.0, 10.0) var bounce_speed: float = 5
|
||||
@export var highlighted: bool = false:
|
||||
set(highlight):
|
||||
if highlight != highlighted:
|
||||
|
|
@ -54,8 +55,14 @@ var on_stage = false
|
|||
|
||||
@export var voice_line: AudioStream = null
|
||||
@export var is_dragable: bool = false
|
||||
|
||||
@onready var diameter = $CollisionShape2D.shape.radius * 2
|
||||
|
||||
var is_dragged: bool = false
|
||||
|
||||
# for debugging
|
||||
var is_printed: bool = false
|
||||
|
||||
func _ready():
|
||||
|
||||
self.set_meta("type", "card") # set type information to find out if this node is a card
|
||||
|
|
@ -87,6 +94,15 @@ func _process(delta: float) -> void:
|
|||
if highlighted:
|
||||
_handle_wiggle(delta)
|
||||
|
||||
if get_overlapping_areas().size() > 0:
|
||||
if not is_printed:
|
||||
print_debug(self.name,": ",get_overlapping_areas())
|
||||
is_printed = true
|
||||
for area in get_overlapping_areas():
|
||||
if self != area:
|
||||
var diff:Vector2 = position - area.position
|
||||
position -= diff.normalized() * ((diff.length()-diameter)/diameter) * bounce_speed * (delta/(1.0/60))
|
||||
|
||||
_move_card()
|
||||
|
||||
func _handle_wiggle(delta):
|
||||
|
|
|
|||
Loading…
Reference in New Issue