From 8e49efe906c1567b6c7f4d964f99c2b39c96b522 Mon Sep 17 00:00:00 2001 From: Sebastian Morr Date: Thu, 15 Oct 2020 15:02:43 +0200 Subject: [PATCH] Load sandbox level when starting, make cards scale up on hover --- card.gd | 23 +++++++++++++++++++++++ cardgame.gd | 1 + levels/experiments/sequence | 1 + main.gd | 2 +- main.tscn | 23 +++++++++++------------ 5 files changed, 37 insertions(+), 13 deletions(-) create mode 100644 levels/experiments/sequence diff --git a/card.gd b/card.gd index 97b4236..1ae4073 100644 --- a/card.gd +++ b/card.gd @@ -10,6 +10,7 @@ export var description = "" setget set_description var _first_argument = null var _home_position = null +var _home_rotation = null func _ready(): set_process_unhandled_input(true) @@ -18,6 +19,25 @@ func _process(delta): if dragged: var mousepos = get_viewport().get_mouse_position() global_position = mousepos - drag_offset + + var target_scale = 1 + + if hovered and not dragged: + target_scale = 1.5 + +# if hovered: +# rotation = 0 +# else: +# if _home_rotation: +# rotation_degrees = _home_rotation + + var speed = 5 + + scale = lerp(scale, Vector2(target_scale, target_scale), 10*delta) +# if scale.x < target_scale: +# scale += speed*delta*Vector2(1, 1) +# elif scale.x > target_scale: +# scale -= speed*delta*Vector2(1, 1) func _unhandled_input(event): if event is InputEventMouseButton: @@ -44,9 +64,11 @@ func _unhandled_input(event): func _mouse_entered(): hovered = true + z_index = 1 func _mouse_exited(): hovered = false + z_index = 0 func set_command(new_command): command = new_command @@ -58,6 +80,7 @@ func set_description(new_description): func move_back(): position = _home_position + rotation_degrees = _home_rotation func buuurn(): queue_free() diff --git a/cardgame.gd b/cardgame.gd index 1f148e4..fc9de58 100644 --- a/cardgame.gd +++ b/cardgame.gd @@ -71,6 +71,7 @@ func arrange_cards(): target_position += translation_vec current_angle += angle_between_cards card._home_position = target_position + card._home_rotation = target_rotation var tween = Tween.new() tween.interpolate_property(card, "position", card.position, target_position, 0.5, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT) diff --git a/levels/experiments/sequence b/levels/experiments/sequence new file mode 100644 index 0000000..b04600a --- /dev/null +++ b/levels/experiments/sequence @@ -0,0 +1 @@ +sandbox diff --git a/main.gd b/main.gd index c2e952e..25e1aec 100644 --- a/main.gd +++ b/main.gd @@ -27,7 +27,7 @@ func _ready(): helpers.crash("Could not change to sandbox scene") return - current_chapter = 2 + current_chapter = 1 current_level = 0 # Initialize level select. diff --git a/main.tscn b/main.tscn index a33f629..16cb6b1 100644 --- a/main.tscn +++ b/main.tscn @@ -57,7 +57,7 @@ __meta__ = { [node name="Columns" type="HSplitContainer" parent="Rows"] margin_right = 1904.0 -margin_bottom = 1064.0 +margin_bottom = 784.0 mouse_filter = 2 size_flags_vertical = 3 __meta__ = { @@ -66,7 +66,7 @@ __meta__ = { [node name="Repositories" type="HBoxContainer" parent="Rows/Columns"] margin_right = 1263.0 -margin_bottom = 1064.0 +margin_bottom = 784.0 mouse_filter = 2 size_flags_horizontal = 3 size_flags_stretch_ratio = 2.0 @@ -78,12 +78,12 @@ __meta__ = { [node name="RightSide" type="VSplitContainer" parent="Rows/Columns"] margin_left = 1275.0 margin_right = 1904.0 -margin_bottom = 1064.0 +margin_bottom = 784.0 size_flags_horizontal = 3 [node name="TopStuff" type="VBoxContainer" parent="Rows/Columns/RightSide"] margin_right = 629.0 -margin_bottom = 526.0 +margin_bottom = 386.0 size_flags_vertical = 3 [node name="Menu" type="HBoxContainer" parent="Rows/Columns/RightSide/TopStuff"] @@ -144,7 +144,7 @@ __meta__ = { [node name="LevelPanel" type="VBoxContainer" parent="Rows/Columns/RightSide/TopStuff"] margin_top = 40.0 margin_right = 629.0 -margin_bottom = 526.0 +margin_bottom = 386.0 size_flags_vertical = 3 [node name="LevelName" type="RichTextLabel" parent="Rows/Columns/RightSide/TopStuff/LevelPanel"] @@ -160,7 +160,7 @@ __meta__ = { [node name="Text" type="Control" parent="Rows/Columns/RightSide/TopStuff/LevelPanel"] margin_top = 65.0 margin_right = 629.0 -margin_bottom = 486.0 +margin_bottom = 346.0 size_flags_vertical = 3 [node name="LevelDescription" type="RichTextLabel" parent="Rows/Columns/RightSide/TopStuff/LevelPanel/Text"] @@ -189,18 +189,17 @@ __meta__ = { [node name="Terminal" parent="Rows/Columns/RightSide" instance=ExtResource( 1 )] anchor_right = 0.0 anchor_bottom = 0.0 -margin_top = 538.0 +margin_top = 398.0 margin_right = 629.0 -margin_bottom = 1064.0 +margin_bottom = 784.0 size_flags_vertical = 3 [node name="Cards" parent="Rows" instance=ExtResource( 3 )] -visible = false anchor_right = 0.0 anchor_bottom = 0.0 -margin_top = 801.0 -margin_right = 1920.0 -margin_bottom = 1080.0 +margin_top = 789.0 +margin_right = 1904.0 +margin_bottom = 1064.0 size_flags_vertical = 3 size_flags_stretch_ratio = 0.35