diff --git a/Scenes/end_line.tscn b/Scenes/end_line.tscn index 30ee042..3ba48d3 100644 --- a/Scenes/end_line.tscn +++ b/Scenes/end_line.tscn @@ -8,8 +8,8 @@ plane = Plane( 0, 1, 0, 0 ) [node name="Area" type="Area" groups=[ -"end_line", "deleter", +"end_line", ]] _import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ) diff --git a/Scenes/first_platform.gd b/Scenes/first_platform.gd index a9d934c..21e5dcd 100644 --- a/Scenes/first_platform.gd +++ b/Scenes/first_platform.gd @@ -1,16 +1,4 @@ -extends Spatial - -export(float) var velocity = 1 - -onready var children = get_node("Children") -onready var area = get_node("Area") - -var next_platform - -var segment = preload ("res://Scenes/Regular_Segment.tscn") - -const SEGMENTS = 16 -onready var offset = float(360) / SEGMENTS +extends "res://abstract_platform.gd" func _ready(): @@ -21,21 +9,6 @@ func _ready(): aux.rotate_y(deg2rad(offset * i)) children.add_child(aux) -func explode(): - if (global.sound_enabled): - get_node("StreamPlayer").play(0) - for child in children.get_children(): - child.explode() - area.queue_free() func _on_Area_body_enter( body ): - - if (next_platform.allowed_range != Vector2(-1,-1)): - global.player.limit_rotation_range(next_platform.allowed_range) - else: - global.player.unlimit_rotation_range() - - if (!body.is_in_group("camera")): - body.get_parent().on_platform_passed() - explode() - \ No newline at end of file + delete_enter (body) \ No newline at end of file diff --git a/Scenes/first_platform.tscn b/Scenes/first_platform.tscn index 109701a..d98af9c 100644 --- a/Scenes/first_platform.tscn +++ b/Scenes/first_platform.tscn @@ -11,7 +11,6 @@ extents = Vector3( 0.27822, 0.211002, 0.261824 ) _import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ) script/script = ExtResource( 1 ) -velocity = 0.0 [node name="Children" type="Spatial" parent="."] @@ -49,7 +48,7 @@ shape = SubResource( 1 ) trigger = false _update_shape_index = 0 -[node name="StreamPlayer" type="StreamPlayer" parent="."] +[node name="RegularExplosion" type="StreamPlayer" parent="."] stream/stream = ExtResource( 2 ) stream/play = false diff --git a/Scenes/platform.gd b/Scenes/platform.gd index cfb52b7..5953fb4 100644 --- a/Scenes/platform.gd +++ b/Scenes/platform.gd @@ -1,21 +1,10 @@ -extends Spatial +extends "res://abstract_platform.gd" export(float) var velocity = 1 -onready var children = get_node("Children") -onready var area = get_node("Deleter") - -var segment = preload ("res://Scenes/Regular_Segment.tscn") var segment_tall = preload ("res://Scenes/Segment_Tall.tscn") var segment_movement = preload ("res://Scenes/Segment_Double.tscn") -var next_platform - -var allowed_range = Vector2(-1,-1) - -const SEGMENTS = 16 -onready var offset = float(360) / SEGMENTS - func _ready(): randomize() @@ -81,10 +70,7 @@ func meteorize(): child.meteorize() explode() -func _on_Deleter_body_enter( body ): - if (!body.is_in_group("camera")): - body.get_parent().on_platform_passed() - if (global.sound_enabled): - get_node("RegularExplosion").play() - explode() +func _on_Deleter_body_enter( body ): + delete_enter (body) + diff --git a/abstract_platform.gd b/abstract_platform.gd new file mode 100644 index 0000000..48a0222 --- /dev/null +++ b/abstract_platform.gd @@ -0,0 +1,40 @@ +extends Spatial + +onready var children = get_node("Children") +onready var area = get_node("Deleter") + +var segment = preload ("res://Scenes/Regular_Segment.tscn") + +var next_platform + +var allowed_range = Vector2(-1,-1) + +const SEGMENTS = 16 +onready var offset = float(360) / SEGMENTS + +func send_next_platform_limits(): + if (next_platform.allowed_range != Vector2(-1,-1)): + global.player.limit_rotation_range(next_platform.allowed_range) + else: + global.player.unlimit_rotation_range() + +func explode(): + send_next_platform_limits() + for child in children.get_children(): + child.explode() + +func meteorize(): + send_next_platform_limits() + if (global.sound_enabled): + get_node("BigExplosion").play() + for child in children.get_children(): + child.meteorize() + explode() + +func delete_enter ( body ): + if (!body.is_in_group("camera")): + body.get_parent().on_platform_passed() + if (global.sound_enabled): + get_node("RegularExplosion").play() + explode() +