The_Dark_Side_of_Earth/utils/platform.gd

17 lines
445 B
GDScript3
Raw Normal View History

2025-09-18 18:10:44 +02:00
class_name Platform extends StaticBody2D
var building
2025-09-19 13:42:23 +02:00
func _ready() -> void:
2025-10-15 16:00:47 +02:00
# Choose a platform design at random
2025-09-19 13:42:23 +02:00
if(randf() > 0.5):
$Sprite2D.visible = true
$Sprite2D2.visible = false
2025-10-15 16:00:47 +02:00
# Stretch platforms depending on their height to prevent gaps in the ceiling
func init_at_horizontal_distortion(distortion : float):
scale.x *= distortion
2025-09-18 18:10:44 +02:00
2025-10-15 16:00:47 +02:00
# When a platform is destroyed, destroy the whole building
2025-09-18 18:10:44 +02:00
func destroy():
building.destroy()