diff --git a/addons/block_code/examples/pong_game/pong_game.tscn b/addons/block_code/examples/pong_game/pong_game.tscn index 71f77d15..e551cf12 100644 --- a/addons/block_code/examples/pong_game/pong_game.tscn +++ b/addons/block_code/examples/pong_game/pong_game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=112 format=3 uid="uid://tf7b8c64ecc0"] +[gd_scene load_steps=125 format=3 uid="uid://tf7b8c64ecc0"] [ext_resource type="PackedScene" uid="uid://cg8ibi18um3vg" path="res://addons/block_code/examples/pong_game/space.tscn" id="1_y56ac"] [ext_resource type="Script" path="res://addons/block_code/block_code_node/block_code.gd" id="3_6jaq8"] @@ -9,7 +9,10 @@ [ext_resource type="Script" path="res://addons/block_code/ui/block_canvas/serialized_block_tree_node_array.gd" id="6_ppdc3"] [ext_resource type="Script" path="res://addons/block_code/block_script_data/block_script_data.gd" id="7_uuuue"] [ext_resource type="PackedScene" uid="uid://c7l70grmkauij" path="res://addons/block_code/examples/pong_game/ball.tscn" id="9_xrqll"] +[ext_resource type="AudioStream" uid="uid://jk0oapxjw354" path="res://addons/block_code/examples/pong_game/assets/paddle_hit.ogg" id="10_5astu"] +[ext_resource type="AudioStream" uid="uid://bc7jd3d8m5spt" path="res://addons/block_code/examples/pong_game/assets/wall_hit.ogg" id="11_nrwuh"] [ext_resource type="PackedScene" uid="uid://fhoapg3anjsu" path="res://addons/block_code/examples/pong_game/goal_area.tscn" id="12_nqmxu"] +[ext_resource type="AudioStream" uid="uid://kr166je3cyj7" path="res://addons/block_code/examples/pong_game/assets/score.ogg" id="12_ya5pa"] [ext_resource type="Script" path="res://addons/block_code/simple_nodes/simple_scoring/simple_scoring.gd" id="13_tg3yk"] [sub_resource type="Resource" id="Resource_k6jw1"] @@ -122,71 +125,127 @@ func _process(delta): " version = 0 -[sub_resource type="Resource" id="Resource_80onm"] +[sub_resource type="Resource" id="Resource_0t1ux"] script = ExtResource("5_wr38c") block_class = &"StatementBlock" -serialized_props = [["block_name", "statement_block"], ["label", "StatementBlock"], ["color", Color(0.890196, 0.0588235, 0.752941, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Load file {file_path: STRING} as sound {name: STRING}"], ["statement", " -var __sound = AudioStreamPlayer.new() -__sound.name = {name} -__sound.set_stream(load({file_path})) -add_child(__sound) -"], ["defaults", {}], ["param_input_strings", { -"file_path": "res://addons/block_code/examples/pong_game/assets/score.ogg", -"name": "score_sound" -}]] +serialized_props = [["block_name", "audiostreamplayer_play"], ["label", "StatementBlock"], ["color", Color(0.890196, 0.0588235, 0.752941, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Play"], ["statement", "play()"], ["defaults", {}], ["param_input_strings", {}]] -[sub_resource type="Resource" id="Resource_jfgyp"] +[sub_resource type="Resource" id="Resource_g7e16"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_80onm") +serialized_block = SubResource("Resource_0t1ux") path_child_pairs = [] -[sub_resource type="Resource" id="Resource_0qgyx"] +[sub_resource type="Resource" id="Resource_7jy7i"] +script = ExtResource("5_wr38c") +block_class = &"EntryBlock" +serialized_props = [["block_name", "define_method"], ["label", "EntryBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 1], ["position", Vector2(125, 100)], ["scope", ""], ["block_format", "Define method {method_name: NIL}"], ["statement", "func {method_name}():"], ["defaults", {}], ["param_input_strings", { +"method_name": "play_paddle_hit" +}], ["signal_name", ""]] + +[sub_resource type="Resource" id="Resource_m6c4q"] +script = ExtResource("4_qtggh") +serialized_block = SubResource("Resource_7jy7i") +path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_g7e16")]] + +[sub_resource type="Resource" id="Resource_bc43a"] +script = ExtResource("6_ppdc3") +array = Array[ExtResource("4_qtggh")]([SubResource("Resource_m6c4q")]) + +[sub_resource type="Resource" id="Resource_qcspn"] +script = ExtResource("7_uuuue") +script_inherits = "AudioStreamPlayer" +block_trees = SubResource("Resource_bc43a") +variables = Array[Resource("res://addons/block_code/ui/block_canvas/variable_resource.gd")]([]) +generated_script = "extends AudioStreamPlayer + + +func play_paddle_hit(): + play() + +" +version = 0 + +[sub_resource type="Resource" id="Resource_5c3em"] script = ExtResource("5_wr38c") block_class = &"StatementBlock" -serialized_props = [["block_name", "statement_block"], ["label", "StatementBlock"], ["color", Color(0.890196, 0.0588235, 0.752941, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Load file {file_path: STRING} as sound {name: STRING}"], ["statement", " -var __sound = AudioStreamPlayer.new() -__sound.name = {name} -__sound.set_stream(load({file_path})) -add_child(__sound) -"], ["defaults", {}], ["param_input_strings", { -"file_path": "res://addons/block_code/examples/pong_game/assets/wall_hit.ogg", -"name": "wall_hit" -}]] +serialized_props = [["block_name", "audiostreamplayer_play"], ["label", "StatementBlock"], ["color", Color(0.890196, 0.0588235, 0.752941, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Play"], ["statement", "play()"], ["defaults", {}], ["param_input_strings", {}]] + +[sub_resource type="Resource" id="Resource_32hvm"] +script = ExtResource("4_qtggh") +serialized_block = SubResource("Resource_5c3em") +path_child_pairs = [] + +[sub_resource type="Resource" id="Resource_b8wpx"] +script = ExtResource("5_wr38c") +block_class = &"EntryBlock" +serialized_props = [["block_name", "define_method"], ["label", "EntryBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 1], ["position", Vector2(100, 75)], ["scope", ""], ["block_format", "Define method {method_name: NIL}"], ["statement", "func {method_name}():"], ["defaults", {}], ["param_input_strings", { +"method_name": "play_wall_hit" +}], ["signal_name", ""]] -[sub_resource type="Resource" id="Resource_515lv"] +[sub_resource type="Resource" id="Resource_c35it"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_0qgyx") -path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_jfgyp")]] +serialized_block = SubResource("Resource_b8wpx") +path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_32hvm")]] + +[sub_resource type="Resource" id="Resource_uoudb"] +script = ExtResource("6_ppdc3") +array = Array[ExtResource("4_qtggh")]([SubResource("Resource_c35it")]) + +[sub_resource type="Resource" id="Resource_jqyr2"] +script = ExtResource("7_uuuue") +script_inherits = "AudioStreamPlayer" +block_trees = SubResource("Resource_uoudb") +variables = Array[Resource("res://addons/block_code/ui/block_canvas/variable_resource.gd")]([]) +generated_script = "extends AudioStreamPlayer + + +func play_wall_hit(): + play() + +" +version = 0 -[sub_resource type="Resource" id="Resource_na8wd"] +[sub_resource type="Resource" id="Resource_gkv1p"] script = ExtResource("5_wr38c") block_class = &"StatementBlock" -serialized_props = [["block_name", "statement_block"], ["label", "StatementBlock"], ["color", Color(0.890196, 0.0588235, 0.752941, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Load file {file_path: STRING} as sound {name: STRING}"], ["statement", " -var __sound = AudioStreamPlayer.new() -__sound.name = {name} -__sound.set_stream(load({file_path})) -add_child(__sound) -"], ["defaults", {}], ["param_input_strings", { -"file_path": "res://addons/block_code/examples/pong_game/assets/paddle_hit.ogg", -"name": "paddle_hit" -}]] +serialized_props = [["block_name", "audiostreamplayer_play"], ["label", "StatementBlock"], ["color", Color(0.890196, 0.0588235, 0.752941, 1)], ["block_type", 2], ["position", Vector2(-40, -8)], ["scope", ""], ["block_format", "Play"], ["statement", "play()"], ["defaults", {}], ["param_input_strings", {}]] -[sub_resource type="Resource" id="Resource_bku44"] +[sub_resource type="Resource" id="Resource_k2iga"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_na8wd") -path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_515lv")]] +serialized_block = SubResource("Resource_gkv1p") +path_child_pairs = [] -[sub_resource type="Resource" id="Resource_2m4ct"] +[sub_resource type="Resource" id="Resource_yyfqg"] script = ExtResource("5_wr38c") block_class = &"EntryBlock" -serialized_props = [["block_name", "ready_block"], ["label", "EntryBlock"], ["color", Color(0.980392, 0.34902, 0.337255, 1)], ["block_type", 1], ["position", Vector2(49, 42)], ["scope", ""], ["block_format", "On Ready"], ["statement", "func _ready():"], ["defaults", {}], ["param_input_strings", {}], ["signal_name", ""]] +serialized_props = [["block_name", "define_method"], ["label", "EntryBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 1], ["position", Vector2(150, 100)], ["scope", ""], ["block_format", "Define method {method_name: NIL}"], ["statement", "func {method_name}():"], ["defaults", {}], ["param_input_strings", { +"method_name": "play_score" +}], ["signal_name", ""]] -[sub_resource type="Resource" id="Resource_lfbxc"] +[sub_resource type="Resource" id="Resource_xfvef"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_2m4ct") -path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_bku44")]] +serialized_block = SubResource("Resource_yyfqg") +path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_k2iga")]] + +[sub_resource type="Resource" id="Resource_4lp40"] +script = ExtResource("6_ppdc3") +array = Array[ExtResource("4_qtggh")]([SubResource("Resource_xfvef")]) + +[sub_resource type="Resource" id="Resource_hcu2g"] +script = ExtResource("7_uuuue") +script_inherits = "AudioStreamPlayer" +block_trees = SubResource("Resource_4lp40") +variables = Array[Resource("res://addons/block_code/ui/block_canvas/variable_resource.gd")]([]) +generated_script = "extends AudioStreamPlayer + -[sub_resource type="Resource" id="Resource_0sepo"] +func play_score(): + play() + +" +version = 0 + +[sub_resource type="Resource" id="Resource_rhers"] script = ExtResource("5_wr38c") 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", " @@ -194,12 +253,12 @@ func _on_body_entered(_body: Node): var body: NodePath = _body.get_path() "], ["block_format", "body"], ["statement", "body"], ["defaults", {}], ["variant_type", 22], ["param_input_strings", {}]] -[sub_resource type="Resource" id="Resource_k5cwt"] +[sub_resource type="Resource" id="Resource_p2hoy"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_0sepo") +serialized_block = SubResource("Resource_rhers") path_child_pairs = [] -[sub_resource type="Resource" id="Resource_uucid"] +[sub_resource type="Resource" id="Resource_vy1b7"] script = ExtResource("5_wr38c") 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", " @@ -207,47 +266,42 @@ func _on_body_entered(_body: Node): var body: NodePath = _body.get_path() "], ["block_format", "body"], ["statement", "body"], ["defaults", {}], ["variant_type", 22], ["param_input_strings", {}]] -[sub_resource type="Resource" id="Resource_64xkq"] +[sub_resource type="Resource" id="Resource_knfgd"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_uucid") +serialized_block = SubResource("Resource_vy1b7") path_child_pairs = [] -[sub_resource type="Resource" id="Resource_76m34"] +[sub_resource type="Resource" id="Resource_g6aod"] script = ExtResource("5_wr38c") 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", ""], ["block_format", "Is {node: NODE_PATH} in group {group: STRING}"], ["statement", "get_node({node}).is_in_group({group})"], ["defaults", {}], ["variant_type", 1], ["param_input_strings", { +serialized_props = [["block_name", "is_node_in_group"], ["label", "Param"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Is {node: NODE_PATH} in group {group: STRING}"], ["statement", "get_node({node}).is_in_group({group})"], ["defaults", {}], ["variant_type", 1], ["param_input_strings", { "group": "paddles", "node": "" }]] -[sub_resource type="Resource" id="Resource_fmoex"] +[sub_resource type="Resource" id="Resource_s64pq"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_76m34") -path_child_pairs = [[NodePath("MarginContainer/HBoxContainer/ParameterInput0/SnapPoint"), SubResource("Resource_64xkq")]] +serialized_block = SubResource("Resource_g6aod") +path_child_pairs = [[NodePath("MarginContainer/HBoxContainer/ParameterInput0/SnapPoint"), SubResource("Resource_knfgd")]] -[sub_resource type="Resource" id="Resource_d7dfr"] +[sub_resource type="Resource" id="Resource_0ifu0"] script = ExtResource("5_wr38c") block_class = &"StatementBlock" -serialized_props = [["block_name", "statement_block"], ["label", "StatementBlock"], ["color", Color(0.890196, 0.0588235, 0.752941, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Play the sound {name: STRING} with Volume dB {db: FLOAT} and Pitch Scale {pitch: FLOAT}"], ["statement", " -var __sound_node = get_node({name}) -__sound_node.volume_db = {db} -__sound_node.pitch_scale = {pitch} -__sound_node.play() -"], ["defaults", { -"db": "0.0", -"pitch": "1.0" -}], ["param_input_strings", { -"db": "0.0", -"name": "paddle_hit", -"pitch": "1.0" +serialized_props = [["block_name", "call_node_method"], ["label", "StatementBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Call method {method_name: STRING} in node {node_path: NODE_PATH}"], ["statement", " +var node = get_node({node_path}) +if node: + node.call({method_name}) +"], ["defaults", {}], ["param_input_strings", { +"method_name": "play_paddle_hit", +"node_path": "\"PaddleHitSound\"" }]] -[sub_resource type="Resource" id="Resource_oqnor"] +[sub_resource type="Resource" id="Resource_tv1or"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_d7dfr") +serialized_block = SubResource("Resource_0ifu0") path_child_pairs = [] -[sub_resource type="Resource" id="Resource_uibbi"] +[sub_resource type="Resource" id="Resource_njgvu"] script = ExtResource("5_wr38c") 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", " @@ -255,186 +309,162 @@ func _on_body_entered(_body: Node): var body: NodePath = _body.get_path() "], ["block_format", "body"], ["statement", "body"], ["defaults", {}], ["variant_type", 22], ["param_input_strings", {}]] -[sub_resource type="Resource" id="Resource_7jqxw"] +[sub_resource type="Resource" id="Resource_2jomo"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_uibbi") +serialized_block = SubResource("Resource_njgvu") path_child_pairs = [] -[sub_resource type="Resource" id="Resource_nchna"] +[sub_resource type="Resource" id="Resource_jvaxk"] script = ExtResource("5_wr38c") 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", ""], ["block_format", "Is {node: NODE_PATH} in group {group: STRING}"], ["statement", "get_node({node}).is_in_group({group})"], ["defaults", {}], ["variant_type", 1], ["param_input_strings", { +serialized_props = [["block_name", "is_node_in_group"], ["label", "Param"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Is {node: NODE_PATH} in group {group: STRING}"], ["statement", "get_node({node}).is_in_group({group})"], ["defaults", {}], ["variant_type", 1], ["param_input_strings", { "group": "walls", "node": "" }]] -[sub_resource type="Resource" id="Resource_35nkf"] +[sub_resource type="Resource" id="Resource_hg0af"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_nchna") -path_child_pairs = [[NodePath("MarginContainer/HBoxContainer/ParameterInput0/SnapPoint"), SubResource("Resource_7jqxw")]] +serialized_block = SubResource("Resource_jvaxk") +path_child_pairs = [[NodePath("MarginContainer/HBoxContainer/ParameterInput0/SnapPoint"), SubResource("Resource_2jomo")]] -[sub_resource type="Resource" id="Resource_fywef"] +[sub_resource type="Resource" id="Resource_xdmkw"] script = ExtResource("5_wr38c") block_class = &"StatementBlock" -serialized_props = [["block_name", "statement_block"], ["label", "StatementBlock"], ["color", Color(0.890196, 0.0588235, 0.752941, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Play the sound {name: STRING} with Volume dB {db: FLOAT} and Pitch Scale {pitch: FLOAT}"], ["statement", " -var __sound_node = get_node({name}) -__sound_node.volume_db = {db} -__sound_node.pitch_scale = {pitch} -__sound_node.play() -"], ["defaults", { -"db": "0.0", -"pitch": "1.0" -}], ["param_input_strings", { -"db": "0.0", -"name": "wall_hit", -"pitch": "1.0" +serialized_props = [["block_name", "call_node_method"], ["label", "StatementBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Call method {method_name: STRING} in node {node_path: NODE_PATH}"], ["statement", " +var node = get_node({node_path}) +if node: + node.call({method_name}) +"], ["defaults", {}], ["param_input_strings", { +"method_name": "play_wall_hit", +"node_path": "\"WallHitSound\"" }]] -[sub_resource type="Resource" id="Resource_pucal"] +[sub_resource type="Resource" id="Resource_t531l"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_fywef") +serialized_block = SubResource("Resource_xdmkw") path_child_pairs = [] -[sub_resource type="Resource" id="Resource_8nvnv"] +[sub_resource type="Resource" id="Resource_1vgbj"] script = ExtResource("5_wr38c") block_class = &"ControlBlock" -serialized_props = [["block_name", "control_block"], ["label", "Control Block"], ["color", Color(0.270588, 0.666667, 0.94902, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_formats", ["if {condition: BOOL}"]], ["statements", ["if {condition}:"]], ["defaults", {}], ["param_input_strings_array", [{ +serialized_props = [["block_name", "if"], ["label", "Control Block"], ["color", Color(0.270588, 0.666667, 0.94902, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_formats", ["if {condition: BOOL}"]], ["statements", ["if {condition}:"]], ["defaults", {}], ["param_input_strings_array", [{ "condition": false }]]] -[sub_resource type="Resource" id="Resource_r8172"] +[sub_resource type="Resource" id="Resource_504pr"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_8nvnv") -path_child_pairs = [[NodePath("VBoxContainer/MarginContainer/Rows/Row0/RowHBoxContainer/RowHBox/ParameterInput0/SnapPoint"), SubResource("Resource_35nkf")], [NodePath("VBoxContainer/MarginContainer/Rows/SnapContainer0/SnapPoint"), SubResource("Resource_pucal")]] +serialized_block = SubResource("Resource_1vgbj") +path_child_pairs = [[NodePath("VBoxContainer/MarginContainer/Rows/Row0/RowHBoxContainer/RowHBox/ParameterInput0/SnapPoint"), SubResource("Resource_hg0af")], [NodePath("VBoxContainer/MarginContainer/Rows/SnapContainer0/SnapPoint"), SubResource("Resource_t531l")]] -[sub_resource type="Resource" id="Resource_fl4h4"] +[sub_resource type="Resource" id="Resource_d2qtv"] script = ExtResource("5_wr38c") block_class = &"ControlBlock" -serialized_props = [["block_name", "control_block"], ["label", "Control Block"], ["color", Color(0.270588, 0.666667, 0.94902, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_formats", ["if {condition: BOOL}"]], ["statements", ["if {condition}:"]], ["defaults", {}], ["param_input_strings_array", [{ +serialized_props = [["block_name", "if"], ["label", "Control Block"], ["color", Color(0.270588, 0.666667, 0.94902, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_formats", ["if {condition: BOOL}"]], ["statements", ["if {condition}:"]], ["defaults", {}], ["param_input_strings_array", [{ "condition": false }]]] -[sub_resource type="Resource" id="Resource_3xq0k"] +[sub_resource type="Resource" id="Resource_f8dag"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_fl4h4") -path_child_pairs = [[NodePath("VBoxContainer/MarginContainer/Rows/Row0/RowHBoxContainer/RowHBox/ParameterInput0/SnapPoint"), SubResource("Resource_fmoex")], [NodePath("VBoxContainer/MarginContainer/Rows/SnapContainer0/SnapPoint"), SubResource("Resource_oqnor")], [NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_r8172")]] +serialized_block = SubResource("Resource_d2qtv") +path_child_pairs = [[NodePath("VBoxContainer/MarginContainer/Rows/Row0/RowHBoxContainer/RowHBox/ParameterInput0/SnapPoint"), SubResource("Resource_s64pq")], [NodePath("VBoxContainer/MarginContainer/Rows/SnapContainer0/SnapPoint"), SubResource("Resource_tv1or")], [NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_504pr")]] -[sub_resource type="Resource" id="Resource_eiexb"] +[sub_resource type="Resource" id="Resource_lbwdb"] script = ExtResource("5_wr38c") block_class = &"EntryBlock" -serialized_props = [["block_name", "entry_block"], ["label", "EntryBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 1], ["position", Vector2(50, 226)], ["scope", ""], ["block_format", "On [body: NODE_PATH] entered"], ["statement", " +serialized_props = [["block_name", "rigidbody2d_on_entered"], ["label", "EntryBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 1], ["position", Vector2(200, 75)], ["scope", ""], ["block_format", "On [body: NODE_PATH] entered"], ["statement", " func _on_body_entered(_body: Node): var body: NodePath = _body.get_path() "], ["defaults", {}], ["param_input_strings", {}], ["signal_name", "body_entered"]] -[sub_resource type="Resource" id="Resource_gg652"] +[sub_resource type="Resource" id="Resource_30amv"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_eiexb") -path_child_pairs = [[NodePath("VBoxContainer/TopMarginContainer/MarginContainer/HBoxContainer/ParameterOutput0/SnapPoint"), SubResource("Resource_k5cwt")], [NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_3xq0k")]] +serialized_block = SubResource("Resource_lbwdb") +path_child_pairs = [[NodePath("VBoxContainer/TopMarginContainer/MarginContainer/HBoxContainer/ParameterOutput0/SnapPoint"), SubResource("Resource_p2hoy")], [NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_f8dag")]] -[sub_resource type="Resource" id="Resource_py8f3"] +[sub_resource type="Resource" id="Resource_dqvtn"] script = ExtResource("5_wr38c") block_class = &"ParameterBlock" -serialized_props = [["block_name", "parameter_block"], ["label", "Param"], ["color", Color(0.0117647, 0.666667, 0.454902, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Viewport Center"], ["statement", "(func (): var transform: Transform2D = get_viewport_transform(); var scale: Vector2 = transform.get_scale(); return -transform.origin / scale + get_viewport_rect().size / scale / 2).call()"], ["defaults", {}], ["variant_type", 5], ["param_input_strings", {}]] +serialized_props = [["block_name", "viewport_center"], ["label", "Param"], ["color", Color(0.0117647, 0.666667, 0.454902, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Viewport Center"], ["statement", "(func (): var transform: Transform2D = get_viewport_transform(); var scale: Vector2 = transform.get_scale(); return -transform.origin / scale + get_viewport_rect().size / scale / 2).call()"], ["defaults", {}], ["variant_type", 5], ["param_input_strings", {}]] -[sub_resource type="Resource" id="Resource_kck4x"] +[sub_resource type="Resource" id="Resource_2ai25"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_py8f3") +serialized_block = SubResource("Resource_dqvtn") path_child_pairs = [] -[sub_resource type="Resource" id="Resource_fyaul"] +[sub_resource type="Resource" id="Resource_jmcmm"] script = ExtResource("5_wr38c") block_class = &"StatementBlock" -serialized_props = [["block_name", "statement_block"], ["label", "StatementBlock"], ["color", Color(0.890196, 0.0588235, 0.752941, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Play the sound {name: STRING} with Volume dB {db: FLOAT} and Pitch Scale {pitch: FLOAT}"], ["statement", " -var __sound_node = get_node({name}) -__sound_node.volume_db = {db} -__sound_node.pitch_scale = {pitch} -__sound_node.play() -"], ["defaults", { -"db": "0.0", -"pitch": "1.0" -}], ["param_input_strings", { -"db": "0.0", -"name": "score_sound", -"pitch": "1.0" +serialized_props = [["block_name", "call_node_method"], ["label", "StatementBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Call method {method_name: STRING} in node {node_path: NODE_PATH}"], ["statement", " +var node = get_node({node_path}) +if node: + node.call({method_name}) +"], ["defaults", {}], ["param_input_strings", { +"method_name": "play_score", +"node_path": "\"ScoreSound\"" }]] -[sub_resource type="Resource" id="Resource_1o8v3"] +[sub_resource type="Resource" id="Resource_ma505"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_fyaul") +serialized_block = SubResource("Resource_jmcmm") path_child_pairs = [] -[sub_resource type="Resource" id="Resource_5fsso"] +[sub_resource type="Resource" id="Resource_3iuha"] script = ExtResource("5_wr38c") block_class = &"StatementBlock" -serialized_props = [["block_name", "statement_block"], ["label", "StatementBlock"], ["color", Color(0.439216, 0.501961, 0.564706, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Set Physics Position {position: VECTOR2}"], ["statement", "PhysicsServer2D.body_set_state(get_rid(),PhysicsServer2D.BODY_STATE_TRANSFORM,Transform2D.IDENTITY.translated({position}))"], ["defaults", {}], ["param_input_strings", { -"position": "960,544" +serialized_props = [["block_name", "rigidbody2d_physics_position"], ["label", "StatementBlock"], ["color", Color(0.294118, 0.396078, 0.517647, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Set Physics Position {position: VECTOR2}"], ["statement", " +PhysicsServer2D.body_set_state( + get_rid(), + PhysicsServer2D.BODY_STATE_TRANSFORM, + Transform2D.IDENTITY.translated({position}) +) +"], ["defaults", {}], ["param_input_strings", { +"position": "," }]] -[sub_resource type="Resource" id="Resource_uyy35"] +[sub_resource type="Resource" id="Resource_mo2jw"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_5fsso") -path_child_pairs = [[NodePath("VBoxContainer/TopMarginContainer/MarginContainer/HBoxContainer/ParameterInput0/SnapPoint"), SubResource("Resource_kck4x")], [NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_1o8v3")]] +serialized_block = SubResource("Resource_3iuha") +path_child_pairs = [[NodePath("VBoxContainer/TopMarginContainer/MarginContainer/HBoxContainer/ParameterInput0/SnapPoint"), SubResource("Resource_2ai25")], [NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_ma505")]] -[sub_resource type="Resource" id="Resource_f3xvu"] +[sub_resource type="Resource" id="Resource_8s62l"] script = ExtResource("5_wr38c") block_class = &"EntryBlock" -serialized_props = [["block_name", "entry_block"], ["label", "EntryBlock"], ["color", Color(0.941176, 0.764706, 0, 1)], ["block_type", 1], ["position", Vector2(51, 616)], ["scope", ""], ["block_format", "Define method {method_name: NIL}"], ["statement", "func {method_name}():"], ["defaults", {}], ["param_input_strings", { +serialized_props = [["block_name", "define_method"], ["label", "EntryBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 1], ["position", Vector2(200, 450)], ["scope", ""], ["block_format", "Define method {method_name: NIL}"], ["statement", "func {method_name}():"], ["defaults", {}], ["param_input_strings", { "method_name": "reset" }], ["signal_name", ""]] -[sub_resource type="Resource" id="Resource_n4cap"] +[sub_resource type="Resource" id="Resource_b6o8o"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_f3xvu") -path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_uyy35")]] +serialized_block = SubResource("Resource_8s62l") +path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_mo2jw")]] -[sub_resource type="Resource" id="Resource_gn6n3"] +[sub_resource type="Resource" id="Resource_pf0hb"] script = ExtResource("6_ppdc3") -array = Array[ExtResource("4_qtggh")]([SubResource("Resource_lfbxc"), SubResource("Resource_gg652"), SubResource("Resource_n4cap")]) +array = Array[ExtResource("4_qtggh")]([SubResource("Resource_30amv"), SubResource("Resource_b6o8o")]) -[sub_resource type="Resource" id="Resource_hnwk2"] +[sub_resource type="Resource" id="Resource_debj3"] script = ExtResource("7_uuuue") script_inherits = "RigidBody2D" -block_trees = SubResource("Resource_gn6n3") +block_trees = SubResource("Resource_pf0hb") variables = Array[Resource("res://addons/block_code/ui/block_canvas/variable_resource.gd")]([]) generated_script = "extends RigidBody2D -func _ready(): - var __sound_1 = AudioStreamPlayer.new() - __sound_1.name = 'paddle_hit' - __sound_1.set_stream(load('res://addons/block_code/examples/pong_game/assets/paddle_hit.ogg')) - add_child(__sound_1) - var __sound_2 = AudioStreamPlayer.new() - __sound_2.name = 'wall_hit' - __sound_2.set_stream(load('res://addons/block_code/examples/pong_game/assets/wall_hit.ogg')) - add_child(__sound_2) - var __sound_3 = AudioStreamPlayer.new() - __sound_3.name = 'score_sound' - __sound_3.set_stream(load('res://addons/block_code/examples/pong_game/assets/score.ogg')) - add_child(__sound_3) - func _on_body_entered(_body: Node): var body: NodePath = _body.get_path() if get_node(body).is_in_group('paddles'): - var __sound_node_1 = get_node('paddle_hit') - __sound_node_1.volume_db = 0.0 - __sound_node_1.pitch_scale = 1.0 - __sound_node_1.play() - if get_node(body).is_in_group('walls'): - var __sound_node_2 = get_node('wall_hit') - __sound_node_2.volume_db = 0.0 - __sound_node_2.pitch_scale = 1.0 - __sound_node_2.play() + var node = get_node(\"PaddleHitSound\") + if node: + node.call('play_paddle_hit') func reset(): - PhysicsServer2D.body_set_state(get_rid(),PhysicsServer2D.BODY_STATE_TRANSFORM,Transform2D.IDENTITY.translated((func (): var transform: Transform2D = get_viewport_transform(); var scale: Vector2 = transform.get_scale(); return -transform.origin / scale + get_viewport_rect().size / scale / 2).call())) - var __sound_node_1 = get_node('score_sound') - __sound_node_1.volume_db = 0.0 - __sound_node_1.pitch_scale = 1.0 - __sound_node_1.play() + PhysicsServer2D.body_set_state( + get_rid(), + PhysicsServer2D.BODY_STATE_TRANSFORM, + Transform2D.IDENTITY.translated((func (): var transform: Transform2D = get_viewport_transform(); var scale: Vector2 = transform.get_scale(); return -transform.origin / scale + get_viewport_rect().size / scale / 2).call()) + ) func _init(): body_entered.connect(_on_body_entered) @@ -823,9 +853,30 @@ modulate = Color(0.511, 0.362, 0.972, 1) position = Vector2(960, 544) gravity_scale = 0.0 +[node name="PaddleHitSound" type="AudioStreamPlayer" parent="Ball"] +stream = ExtResource("10_5astu") + +[node name="BlockCode" type="Node" parent="Ball/PaddleHitSound"] +script = ExtResource("3_6jaq8") +block_script = SubResource("Resource_qcspn") + +[node name="WallHitSound" type="AudioStreamPlayer" parent="Ball"] +stream = ExtResource("11_nrwuh") + +[node name="BlockCode" type="Node" parent="Ball/WallHitSound"] +script = ExtResource("3_6jaq8") +block_script = SubResource("Resource_jqyr2") + +[node name="ScoreSound" type="AudioStreamPlayer" parent="Ball"] +stream = ExtResource("12_ya5pa") + +[node name="BlockCode" type="Node" parent="Ball/ScoreSound"] +script = ExtResource("3_6jaq8") +block_script = SubResource("Resource_hcu2g") + [node name="BlockCode" type="Node" parent="Ball"] script = ExtResource("3_6jaq8") -block_script = SubResource("Resource_hnwk2") +block_script = SubResource("Resource_debj3") [node name="GoalAreaLeft" parent="." groups=["goal", "goal_left"] instance=ExtResource("12_nqmxu")] position = Vector2(-64, 544)