Skip to content

Commit

Permalink
Inheritance for platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
Dariasteam committed Dec 24, 2018
1 parent 7953671 commit 7598ef8
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 50 deletions.
2 changes: 1 addition & 1 deletion Scenes/end_line.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
31 changes: 2 additions & 29 deletions Scenes/first_platform.gd
Original file line number Diff line number Diff line change
@@ -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():

Expand All @@ -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()

delete_enter (body)
3 changes: 1 addition & 2 deletions Scenes/first_platform.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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="."]

Expand Down Expand Up @@ -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
Expand Down
22 changes: 4 additions & 18 deletions Scenes/platform.gd
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -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)


40 changes: 40 additions & 0 deletions abstract_platform.gd
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 7598ef8

Please sign in to comment.