Skip to content

Commit 9458b7c

Browse files
authored
Merge pull request #15 from endlessm/sync-block-coding
Rebase the platformer demo agaist the new plugin
2 parents 14c6f1b + 4971476 commit 9458b7c

File tree

11 files changed

+1840
-1370
lines changed

11 files changed

+1840
-1370
lines changed

game-03/README.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ The world is built with tilemap style.
1313
The player is implemented with SimpleCharacter node. So, using W, A, D to jump
1414
and move left & right.
1515

16-
The collected coins and the player's lives are implemented with a SimpleScoring
17-
node. Player 1's score represents as collected coins and player 2's score
18-
represents lives.
16+
Check the player is on floor and velocity to play walk, or jump animation in the
17+
AnimationPlayer.
1918

20-
The player enters a coin to collect the coin. It increase "Player 1"'s score and
21-
vanish the coin.
19+
The collected coins and the player's lives are implemented with SimpleScoring
20+
nodes.
2221

23-
When the player collects enough coins and enters the flag's area, shows "You
24-
Win!" label.
22+
The player enters a coin to collect the coin. It increases coins' score and
23+
vanish the coin. When the player collects enough coins and enters the flag's
24+
area, shows "You Win!" label.
2525

2626
The enemies walk back and forth by setting the enemy's terminal positions within
2727
AnimationPlayer's "move" animation and playing it automatically.
@@ -34,11 +34,7 @@ nodes in HUD group will invoke their own decrease_a_life method to decrease one
3434
life.
3535

3636
When the player enters an enemy's HitArea or drops down into the Dangerzone, the
37-
"Player 2"'s score decreases one. If there is no more life, shows "You Lose!"
38-
label.
37+
lives' score decreases one. If there is no more life, shows "You Lose!" label.
3938

40-
## Limitations found
41-
42-
The float platforms should shake, then drop down after the player stands on it.
43-
However, there is no way to trigger/access the play_shake method in of
44-
AnimationPlayer's BlockCode node now.
39+
When the player stands on the floating platform (the player enters a thin area
40+
on top of the platform), it triggers shake platform animation and drops down.

game-03/components/coin/coin.tscn

Lines changed: 43 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,154 +1,80 @@
1-
[gd_scene load_steps=27 format=3 uid="uid://daf24t18h3n5e"]
1+
[gd_scene load_steps=17 format=3 uid="uid://daf24t18h3n5e"]
22

33
[ext_resource type="Script" path="res://addons/block_code/block_code_node/block_code.gd" id="2_dpb0t"]
44
[ext_resource type="Texture2D" uid="uid://bjqboxowe07lw" path="res://game-03/assets/items/crystal.png" id="2_hpbor"]
55
[ext_resource type="Script" path="res://addons/block_code/serialization/block_serialization.gd" id="3_pg4k8"]
6-
[ext_resource type="Script" path="res://addons/block_code/serialization/block_serialized_properties.gd" id="4_whic5"]
6+
[ext_resource type="Script" path="res://addons/block_code/serialization/block_serialization_tree.gd" id="3_wr1yg"]
7+
[ext_resource type="Script" path="res://addons/block_code/serialization/value_block_serialization.gd" id="5_8x8mf"]
78
[ext_resource type="Script" path="res://addons/block_code/serialization/block_script_serialization.gd" id="5_rqou2"]
8-
[ext_resource type="Script" path="res://addons/block_code/ui/block_canvas/variable_resource.gd" id="6_0sb4n"]
9+
[ext_resource type="Script" path="res://addons/block_code/code_generation/variable_definition.gd" id="7_0fb5d"]
910

1011
[sub_resource type="CircleShape2D" id="CircleShape2D_5w0o8"]
1112
radius = 46.72
1213

13-
[sub_resource type="Resource" id="Resource_b0aen"]
14-
script = ExtResource("4_whic5")
15-
block_class = &"EntryBlock"
16-
serialized_props = [["scope", ""], ["param_input_strings", {}]]
14+
[sub_resource type="Resource" id="Resource_x8ax5"]
15+
script = ExtResource("5_8x8mf")
16+
name = &"area2d_on_entered:something"
17+
arguments = {}
1718

18-
[sub_resource type="Resource" id="Resource_c7q65"]
19-
script = ExtResource("4_whic5")
20-
block_class = &"StatementBlock"
21-
serialized_props = [["scope", ""], ["param_input_strings", {
22-
"value": Color(1, 1, 0, 1)
23-
}]]
24-
25-
[sub_resource type="Resource" id="Resource_1mye5"]
26-
script = ExtResource("3_pg4k8")
27-
name = &"CanvasItem_set_modulate"
28-
position = Vector2(0, 0)
29-
path_child_pairs = []
30-
block_serialized_properties = SubResource("Resource_c7q65")
31-
32-
[sub_resource type="Resource" id="Resource_1h6wi"]
33-
script = ExtResource("3_pg4k8")
34-
name = &"ready"
35-
position = Vector2(54, 47)
36-
path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_1mye5")]]
37-
block_serialized_properties = SubResource("Resource_b0aen")
38-
39-
[sub_resource type="Resource" id="Resource_gsl5x"]
40-
script = ExtResource("4_whic5")
41-
block_class = &"EntryBlock"
42-
serialized_props = [["scope", ""], ["param_input_strings", {}]]
43-
44-
[sub_resource type="Resource" id="Resource_2gjjp"]
45-
script = ExtResource("4_whic5")
46-
block_class = &"ParameterBlock"
47-
serialized_props = [["block_name", &"parameter_block"], ["label", "Param"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", "func _on_body_entered(body: Node2D):
48-
"], ["block_format", "body"], ["statement", "body"], ["defaults", {}], ["variant_type", 24], ["param_input_strings", {}]]
49-
50-
[sub_resource type="Resource" id="Resource_6rxwa"]
51-
script = ExtResource("3_pg4k8")
52-
name = &"parameter_block"
53-
position = Vector2(0, 0)
54-
path_child_pairs = []
55-
block_serialized_properties = SubResource("Resource_2gjjp")
56-
57-
[sub_resource type="Resource" id="Resource_4vfcy"]
58-
script = ExtResource("4_whic5")
59-
block_class = &"ControlBlock"
60-
serialized_props = [["scope", ""], ["param_input_strings_array", [{
61-
"condition": false
62-
}]]]
63-
64-
[sub_resource type="Resource" id="Resource_gleaj"]
65-
script = ExtResource("4_whic5")
66-
block_class = &"ParameterBlock"
67-
serialized_props = [["scope", ""], ["param_input_strings", {
19+
[sub_resource type="Resource" id="Resource_o3cvg"]
20+
script = ExtResource("5_8x8mf")
21+
name = &"is_node_in_group"
22+
arguments = {
6823
"group": "player",
69-
"node": ""
70-
}]]
71-
72-
[sub_resource type="Resource" id="Resource_ltewg"]
73-
script = ExtResource("4_whic5")
74-
block_class = &"ParameterBlock"
75-
serialized_props = [["block_name", &"parameter_block"], ["label", "Param"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", "func _on_body_entered(body: Node2D):
76-
"], ["block_format", "body"], ["statement", "body"], ["defaults", {}], ["variant_type", 24], ["param_input_strings", {}]]
24+
"node": SubResource("Resource_x8ax5")
25+
}
7726

78-
[sub_resource type="Resource" id="Resource_t52a3"]
27+
[sub_resource type="Resource" id="Resource_uxf3u"]
7928
script = ExtResource("3_pg4k8")
80-
name = &"parameter_block"
81-
position = Vector2(0, 0)
82-
path_child_pairs = []
83-
block_serialized_properties = SubResource("Resource_ltewg")
84-
85-
[sub_resource type="Resource" id="Resource_e5t77"]
86-
script = ExtResource("3_pg4k8")
87-
name = &"is_node_in_group"
88-
position = Vector2(0, 0)
89-
path_child_pairs = [[NodePath("MarginContainer/HBoxContainer/ParameterInput0/SnapPoint"), SubResource("Resource_t52a3")]]
90-
block_serialized_properties = SubResource("Resource_gleaj")
91-
92-
[sub_resource type="Resource" id="Resource_dksbq"]
93-
script = ExtResource("4_whic5")
94-
block_class = &"StatementBlock"
95-
serialized_props = [["scope", ""], ["param_input_strings", {
29+
name = &"call_method_group"
30+
children = Array[ExtResource("3_pg4k8")]([])
31+
arguments = {
9632
"group": "HUD",
9733
"method_name": "collect_a_coin"
98-
}]]
99-
100-
[sub_resource type="Resource" id="Resource_05nt8"]
101-
script = ExtResource("4_whic5")
102-
block_class = &"StatementBlock"
103-
serialized_props = [["scope", ""], ["param_input_strings", {}]]
34+
}
10435

105-
[sub_resource type="Resource" id="Resource_68gnw"]
36+
[sub_resource type="Resource" id="Resource_tfnlr"]
10637
script = ExtResource("3_pg4k8")
10738
name = &"queue_free"
108-
position = Vector2(0, 0)
109-
path_child_pairs = []
110-
block_serialized_properties = SubResource("Resource_05nt8")
111-
112-
[sub_resource type="Resource" id="Resource_8hsyf"]
113-
script = ExtResource("3_pg4k8")
114-
name = &"call_method_group"
115-
position = Vector2(20, 0)
116-
path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_68gnw")]]
117-
block_serialized_properties = SubResource("Resource_dksbq")
39+
children = Array[ExtResource("3_pg4k8")]([])
40+
arguments = {}
11841

119-
[sub_resource type="Resource" id="Resource_hj42p"]
42+
[sub_resource type="Resource" id="Resource_wfm5k"]
12043
script = ExtResource("3_pg4k8")
12144
name = &"if"
122-
position = Vector2(0, 0)
123-
path_child_pairs = [[NodePath("VBoxContainer/MarginContainer/Rows/Row0/RowHBoxContainer/RowHBox/ParameterInput0/SnapPoint"), SubResource("Resource_e5t77")], [NodePath("VBoxContainer/MarginContainer/Rows/SnapContainer0/SnapPoint"), SubResource("Resource_8hsyf")]]
124-
block_serialized_properties = SubResource("Resource_4vfcy")
45+
children = Array[ExtResource("3_pg4k8")]([SubResource("Resource_uxf3u"), SubResource("Resource_tfnlr")])
46+
arguments = {
47+
"condition": SubResource("Resource_o3cvg")
48+
}
12549

126-
[sub_resource type="Resource" id="Resource_plq1i"]
50+
[sub_resource type="Resource" id="Resource_rtfqn"]
12751
script = ExtResource("3_pg4k8")
12852
name = &"area2d_on_entered"
129-
position = Vector2(50, 200)
130-
path_child_pairs = [[NodePath("VBoxContainer/TopMarginContainer/MarginContainer/HBoxContainer/ParameterOutput0/SnapPoint"), SubResource("Resource_6rxwa")], [NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_hj42p")]]
131-
block_serialized_properties = SubResource("Resource_gsl5x")
53+
children = Array[ExtResource("3_pg4k8")]([SubResource("Resource_wfm5k")])
54+
arguments = {}
13255

133-
[sub_resource type="Resource" id="Resource_mvgeb"]
56+
[sub_resource type="Resource" id="Resource_dp0f8"]
57+
script = ExtResource("3_wr1yg")
58+
root = SubResource("Resource_rtfqn")
59+
canvas_position = Vector2(75, 50)
60+
61+
[sub_resource type="Resource" id="Resource_qkyh5"]
13462
script = ExtResource("5_rqou2")
13563
script_inherits = "Area2D"
136-
block_trees = Array[ExtResource("3_pg4k8")]([SubResource("Resource_1h6wi"), SubResource("Resource_plq1i")])
137-
variables = Array[ExtResource("6_0sb4n")]([])
64+
block_serialization_trees = Array[ExtResource("3_wr1yg")]([SubResource("Resource_dp0f8")])
65+
variables = Array[ExtResource("7_0fb5d")]([])
13866
generated_script = "extends Area2D
13967
14068
141-
func _ready():
142-
modulate = Color(1, 1, 0, 1)
69+
func _init():
70+
body_entered.connect(_on_body_entered)
14371
144-
func _on_body_entered(body: Node2D):
72+
func _on_body_entered(something: Node2D):
14573
146-
if body.is_in_group('player'):
74+
if ((something).is_in_group('player')):
14775
get_tree().call_group('HUD', 'collect_a_coin')
14876
queue_free()
14977
150-
func _init():
151-
body_entered.connect(_on_body_entered)
15278
"
15379
version = 0
15480

@@ -164,4 +90,4 @@ shape = SubResource("CircleShape2D_5w0o8")
16490

16591
[node name="BlockCode" type="Node" parent="."]
16692
script = ExtResource("2_dpb0t")
167-
block_script = SubResource("Resource_mvgeb")
93+
block_script = SubResource("Resource_qkyh5")

0 commit comments

Comments
 (0)