Skip to content

Commit 739b945

Browse files
committed
Move laser gun to a separate scene from ship.tscn
We will treat the laser gun as a prefab, separate from the rest of the ship code.
1 parent 3ede4ed commit 739b945

File tree

2 files changed

+76
-67
lines changed

2 files changed

+76
-67
lines changed

game-06/laser_gun.tscn

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
[gd_scene load_steps=16 format=3 uid="uid://cmyx2g1new5rm"]
2+
3+
[ext_resource type="Script" path="res://addons/block_code/simple_spawner/simple_spawner.gd" id="1_63puc"]
4+
[ext_resource type="PackedScene" uid="uid://bhf37etwtrfbe" path="res://game-06/laser_particle.tscn" id="2_aqswo"]
5+
[ext_resource type="Script" path="res://addons/block_code/block_code_node/block_code.gd" id="3_ewtfj"]
6+
[ext_resource type="Script" path="res://addons/block_code/serialization/block_serialization_tree.gd" id="4_n1j5b"]
7+
[ext_resource type="Script" path="res://addons/block_code/serialization/block_serialization.gd" id="5_4y7w8"]
8+
[ext_resource type="Script" path="res://addons/block_code/serialization/value_block_serialization.gd" id="6_g1jce"]
9+
[ext_resource type="Script" path="res://addons/block_code/serialization/block_script_serialization.gd" id="6_jldvy"]
10+
[ext_resource type="Script" path="res://addons/block_code/code_generation/variable_definition.gd" id="7_nihrv"]
11+
[ext_resource type="AudioStream" uid="uid://bm178yv4wvqdn" path="res://game-06/Sounds/Pew.ogg" id="8_qms1c"]
12+
13+
[sub_resource type="Resource" id="Resource_cx5ym"]
14+
script = ExtResource("6_g1jce")
15+
name = &"get_node"
16+
arguments = {
17+
"path": NodePath("PewSound")
18+
}
19+
20+
[sub_resource type="Resource" id="Resource_nrjwr"]
21+
script = ExtResource("5_4y7w8")
22+
name = &"call_method_node"
23+
children = Array[ExtResource("5_4y7w8")]([])
24+
arguments = {
25+
"method_name": "play",
26+
"node": SubResource("Resource_cx5ym")
27+
}
28+
29+
[sub_resource type="Resource" id="Resource_33p8t"]
30+
script = ExtResource("5_4y7w8")
31+
name = &"simplespawner_spawn_once"
32+
children = Array[ExtResource("5_4y7w8")]([])
33+
arguments = {}
34+
35+
[sub_resource type="Resource" id="Resource_p4ncl"]
36+
script = ExtResource("5_4y7w8")
37+
name = &"define_method"
38+
children = Array[ExtResource("5_4y7w8")]([SubResource("Resource_nrjwr"), SubResource("Resource_33p8t")])
39+
arguments = {
40+
"method_name": &"fire"
41+
}
42+
43+
[sub_resource type="Resource" id="Resource_0e08p"]
44+
script = ExtResource("4_n1j5b")
45+
root = SubResource("Resource_p4ncl")
46+
canvas_position = Vector2(75, 50)
47+
48+
[sub_resource type="Resource" id="Resource_pgr2a"]
49+
script = ExtResource("6_jldvy")
50+
script_inherits = "SimpleSpawner"
51+
block_serialization_trees = Array[ExtResource("4_n1j5b")]([SubResource("Resource_0e08p")])
52+
variables = Array[ExtResource("7_nihrv")]([])
53+
generated_script = "extends SimpleSpawner
54+
55+
56+
func fire():
57+
(get_node(\"PewSound\")).call('play')
58+
spawn_once()
59+
60+
"
61+
version = 0
62+
63+
[node name="LaserGun" type="Node2D" groups=["lasers"]]
64+
script = ExtResource("1_63puc")
65+
scenes = Array[PackedScene]([ExtResource("2_aqswo")])
66+
spawn_limit = 10
67+
68+
[node name="BlockCode" type="Node" parent="."]
69+
script = ExtResource("3_ewtfj")
70+
block_script = SubResource("Resource_pgr2a")
71+
72+
[node name="PewSound" type="AudioStreamPlayer2D" parent="."]
73+
stream = ExtResource("8_qms1c")

game-06/ship.tscn

Lines changed: 3 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
[gd_scene load_steps=28 format=3 uid="uid://dps3xjhs2ssns"]
1+
[gd_scene load_steps=19 format=3 uid="uid://dps3xjhs2ssns"]
22

33
[ext_resource type="Script" path="res://addons/block_code/simple_nodes/simple_character/simple_character.gd" id="1_rrros"]
44
[ext_resource type="Texture2D" uid="uid://dqobtlpqjmouw" path="res://game-06/graphics/engine.svg" id="2_qdvvn"]
55
[ext_resource type="Texture2D" uid="uid://blq8smrhpgtpj" path="res://game-06/graphics/graphics.png" id="3_s1qof"]
6+
[ext_resource type="PackedScene" uid="uid://cmyx2g1new5rm" path="res://game-06/laser_gun.tscn" id="4_0x2nn"]
67
[ext_resource type="Script" path="res://addons/block_code/block_code_node/block_code.gd" id="4_i1022"]
7-
[ext_resource type="Script" path="res://addons/block_code/simple_spawner/simple_spawner.gd" id="4_m2gjr"]
88
[ext_resource type="Script" path="res://addons/block_code/serialization/block_serialization_tree.gd" id="5_8ag0i"]
9-
[ext_resource type="PackedScene" uid="uid://bhf37etwtrfbe" path="res://game-06/laser_particle.tscn" id="5_ongkj"]
109
[ext_resource type="Script" path="res://addons/block_code/serialization/block_serialization.gd" id="6_rpoob"]
11-
[ext_resource type="Script" path="res://addons/block_code/serialization/value_block_serialization.gd" id="7_xmg58"]
1210
[ext_resource type="Script" path="res://addons/block_code/serialization/block_script_serialization.gd" id="8_ui4ru"]
1311
[ext_resource type="Script" path="res://addons/block_code/code_generation/variable_definition.gd" id="9_5ylav"]
14-
[ext_resource type="AudioStream" uid="uid://bm178yv4wvqdn" path="res://game-06/Sounds/Pew.ogg" id="10_vxg6f"]
1512

1613
[sub_resource type="Curve" id="Curve_j0da6"]
1714
_data = [Vector2(0, 0.570571), 0.0, 0.0, 0, 0, Vector2(0.643836, 1), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0]
@@ -21,56 +18,6 @@ point_count = 3
2118
radius = 19.0
2219
height = 70.0
2320

24-
[sub_resource type="Resource" id="Resource_mrxa6"]
25-
script = ExtResource("7_xmg58")
26-
name = &"get_node"
27-
arguments = {
28-
"path": NodePath("../PewSound")
29-
}
30-
31-
[sub_resource type="Resource" id="Resource_7tcmp"]
32-
script = ExtResource("6_rpoob")
33-
name = &"call_method_node"
34-
children = Array[ExtResource("6_rpoob")]([])
35-
arguments = {
36-
"method_name": "play",
37-
"node": SubResource("Resource_mrxa6")
38-
}
39-
40-
[sub_resource type="Resource" id="Resource_ncv8w"]
41-
script = ExtResource("6_rpoob")
42-
name = &"simplespawner_spawn_once"
43-
children = Array[ExtResource("6_rpoob")]([])
44-
arguments = {}
45-
46-
[sub_resource type="Resource" id="Resource_404b6"]
47-
script = ExtResource("6_rpoob")
48-
name = &"define_method"
49-
children = Array[ExtResource("6_rpoob")]([SubResource("Resource_7tcmp"), SubResource("Resource_ncv8w")])
50-
arguments = {
51-
"method_name": &"fire"
52-
}
53-
54-
[sub_resource type="Resource" id="Resource_6q58r"]
55-
script = ExtResource("5_8ag0i")
56-
root = SubResource("Resource_404b6")
57-
canvas_position = Vector2(75, 50)
58-
59-
[sub_resource type="Resource" id="Resource_pgr2a"]
60-
script = ExtResource("8_ui4ru")
61-
script_inherits = "SimpleSpawner"
62-
block_serialization_trees = Array[ExtResource("5_8ag0i")]([SubResource("Resource_6q58r")])
63-
variables = Array[ExtResource("9_5ylav")]([])
64-
generated_script = "extends SimpleSpawner
65-
66-
67-
func fire():
68-
(get_node(\"../PewSound\")).call('play')
69-
spawn_once()
70-
71-
"
72-
version = 0
73-
7421
[sub_resource type="Animation" id="Animation_rp8jp"]
7522
length = 0.001
7623
tracks/0/type = "value"
@@ -176,14 +123,7 @@ position = Vector2(3, -4)
176123
rotation = -1.57079
177124
shape = SubResource("CapsuleShape2D_babat")
178125

179-
[node name="LaserSpawner" type="Node2D" parent="." groups=["lasers"]]
180-
script = ExtResource("4_m2gjr")
181-
scenes = Array[PackedScene]([ExtResource("5_ongkj")])
182-
spawn_limit = 10
183-
184-
[node name="BlockCode" type="Node" parent="LaserSpawner"]
185-
script = ExtResource("4_i1022")
186-
block_script = SubResource("Resource_pgr2a")
126+
[node name="LaserGun" parent="." instance=ExtResource("4_0x2nn")]
187127

188128
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
189129
libraries = {
@@ -194,7 +134,3 @@ speed_scale = 3.0
194134
[node name="BlockCode" type="Node" parent="AnimationPlayer"]
195135
script = ExtResource("4_i1022")
196136
block_script = SubResource("Resource_gtmbp")
197-
198-
[node name="PewSound" type="AudioStreamPlayer2D" parent="."]
199-
stream = ExtResource("10_vxg6f")
200-
pitch_scale = 2.0

0 commit comments

Comments
 (0)