Skip to content
24 changes: 10 additions & 14 deletions game-03/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ The world is built with tilemap style.
The player is implemented with SimpleCharacter node. So, using W, A, D to jump
and move left & right.

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

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

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

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

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

## Limitations found

The float platforms should shake, then drop down after the player stands on it.
However, there is no way to trigger/access the play_shake method in of
AnimationPlayer's BlockCode node now.
When the player stands on the floating platform (the player enters a thin area
on top of the platform), it triggers shake platform animation and drops down.
160 changes: 43 additions & 117 deletions game-03/components/coin/coin.tscn
Original file line number Diff line number Diff line change
@@ -1,154 +1,80 @@
[gd_scene load_steps=27 format=3 uid="uid://daf24t18h3n5e"]
[gd_scene load_steps=17 format=3 uid="uid://daf24t18h3n5e"]

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

[sub_resource type="CircleShape2D" id="CircleShape2D_5w0o8"]
radius = 46.72

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

[sub_resource type="Resource" id="Resource_c7q65"]
script = ExtResource("4_whic5")
block_class = &"StatementBlock"
serialized_props = [["scope", ""], ["param_input_strings", {
"value": Color(1, 1, 0, 1)
}]]

[sub_resource type="Resource" id="Resource_1mye5"]
script = ExtResource("3_pg4k8")
name = &"CanvasItem_set_modulate"
position = Vector2(0, 0)
path_child_pairs = []
block_serialized_properties = SubResource("Resource_c7q65")

[sub_resource type="Resource" id="Resource_1h6wi"]
script = ExtResource("3_pg4k8")
name = &"ready"
position = Vector2(54, 47)
path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_1mye5")]]
block_serialized_properties = SubResource("Resource_b0aen")

[sub_resource type="Resource" id="Resource_gsl5x"]
script = ExtResource("4_whic5")
block_class = &"EntryBlock"
serialized_props = [["scope", ""], ["param_input_strings", {}]]

[sub_resource type="Resource" id="Resource_2gjjp"]
script = ExtResource("4_whic5")
block_class = &"ParameterBlock"
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):
"], ["block_format", "body"], ["statement", "body"], ["defaults", {}], ["variant_type", 24], ["param_input_strings", {}]]

[sub_resource type="Resource" id="Resource_6rxwa"]
script = ExtResource("3_pg4k8")
name = &"parameter_block"
position = Vector2(0, 0)
path_child_pairs = []
block_serialized_properties = SubResource("Resource_2gjjp")

[sub_resource type="Resource" id="Resource_4vfcy"]
script = ExtResource("4_whic5")
block_class = &"ControlBlock"
serialized_props = [["scope", ""], ["param_input_strings_array", [{
"condition": false
}]]]

[sub_resource type="Resource" id="Resource_gleaj"]
script = ExtResource("4_whic5")
block_class = &"ParameterBlock"
serialized_props = [["scope", ""], ["param_input_strings", {
[sub_resource type="Resource" id="Resource_o3cvg"]
script = ExtResource("5_8x8mf")
name = &"is_node_in_group"
arguments = {
"group": "player",
"node": ""
}]]

[sub_resource type="Resource" id="Resource_ltewg"]
script = ExtResource("4_whic5")
block_class = &"ParameterBlock"
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):
"], ["block_format", "body"], ["statement", "body"], ["defaults", {}], ["variant_type", 24], ["param_input_strings", {}]]
"node": SubResource("Resource_x8ax5")
}

[sub_resource type="Resource" id="Resource_t52a3"]
[sub_resource type="Resource" id="Resource_uxf3u"]
script = ExtResource("3_pg4k8")
name = &"parameter_block"
position = Vector2(0, 0)
path_child_pairs = []
block_serialized_properties = SubResource("Resource_ltewg")

[sub_resource type="Resource" id="Resource_e5t77"]
script = ExtResource("3_pg4k8")
name = &"is_node_in_group"
position = Vector2(0, 0)
path_child_pairs = [[NodePath("MarginContainer/HBoxContainer/ParameterInput0/SnapPoint"), SubResource("Resource_t52a3")]]
block_serialized_properties = SubResource("Resource_gleaj")

[sub_resource type="Resource" id="Resource_dksbq"]
script = ExtResource("4_whic5")
block_class = &"StatementBlock"
serialized_props = [["scope", ""], ["param_input_strings", {
name = &"call_method_group"
children = Array[ExtResource("3_pg4k8")]([])
arguments = {
"group": "HUD",
"method_name": "collect_a_coin"
}]]

[sub_resource type="Resource" id="Resource_05nt8"]
script = ExtResource("4_whic5")
block_class = &"StatementBlock"
serialized_props = [["scope", ""], ["param_input_strings", {}]]
}

[sub_resource type="Resource" id="Resource_68gnw"]
[sub_resource type="Resource" id="Resource_tfnlr"]
script = ExtResource("3_pg4k8")
name = &"queue_free"
position = Vector2(0, 0)
path_child_pairs = []
block_serialized_properties = SubResource("Resource_05nt8")

[sub_resource type="Resource" id="Resource_8hsyf"]
script = ExtResource("3_pg4k8")
name = &"call_method_group"
position = Vector2(20, 0)
path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_68gnw")]]
block_serialized_properties = SubResource("Resource_dksbq")
children = Array[ExtResource("3_pg4k8")]([])
arguments = {}

[sub_resource type="Resource" id="Resource_hj42p"]
[sub_resource type="Resource" id="Resource_wfm5k"]
script = ExtResource("3_pg4k8")
name = &"if"
position = Vector2(0, 0)
path_child_pairs = [[NodePath("VBoxContainer/MarginContainer/Rows/Row0/RowHBoxContainer/RowHBox/ParameterInput0/SnapPoint"), SubResource("Resource_e5t77")], [NodePath("VBoxContainer/MarginContainer/Rows/SnapContainer0/SnapPoint"), SubResource("Resource_8hsyf")]]
block_serialized_properties = SubResource("Resource_4vfcy")
children = Array[ExtResource("3_pg4k8")]([SubResource("Resource_uxf3u"), SubResource("Resource_tfnlr")])
arguments = {
"condition": SubResource("Resource_o3cvg")
}

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

[sub_resource type="Resource" id="Resource_mvgeb"]
[sub_resource type="Resource" id="Resource_dp0f8"]
script = ExtResource("3_wr1yg")
root = SubResource("Resource_rtfqn")
canvas_position = Vector2(75, 50)

[sub_resource type="Resource" id="Resource_qkyh5"]
script = ExtResource("5_rqou2")
script_inherits = "Area2D"
block_trees = Array[ExtResource("3_pg4k8")]([SubResource("Resource_1h6wi"), SubResource("Resource_plq1i")])
variables = Array[ExtResource("6_0sb4n")]([])
block_serialization_trees = Array[ExtResource("3_wr1yg")]([SubResource("Resource_dp0f8")])
variables = Array[ExtResource("7_0fb5d")]([])
generated_script = "extends Area2D


func _ready():
modulate = Color(1, 1, 0, 1)
func _init():
body_entered.connect(_on_body_entered)

func _on_body_entered(body: Node2D):
func _on_body_entered(something: Node2D):

if body.is_in_group('player'):
if ((something).is_in_group('player')):
get_tree().call_group('HUD', 'collect_a_coin')
queue_free()

func _init():
body_entered.connect(_on_body_entered)
"
version = 0

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

[node name="BlockCode" type="Node" parent="."]
script = ExtResource("2_dpb0t")
block_script = SubResource("Resource_mvgeb")
block_script = SubResource("Resource_qkyh5")
Loading