Added platform shader
This commit is contained in:
@@ -17,12 +17,13 @@ const MAX_WIDTH = TILE_SIZE * 32
|
||||
|
||||
|
||||
@onready var collision: CollisionShape2D = $AnimatableBody2D/CollisionShape2D
|
||||
@onready var platform_sprite: Sprite2D = $PlatformSprite
|
||||
@onready var platform_rect: ColorRect = $PlatformRect
|
||||
@onready var icon_sprite: AnimatedSprite2D = $IconSprite
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
platform_sprite.material.set_shader_parameter("tile_size", TILE_SIZE)
|
||||
platform_rect.material.set_shader_parameter("tile_size", TILE_SIZE)
|
||||
platform_rect.material.set_shader_parameter("seed", randf())
|
||||
rebuild_platform()
|
||||
|
||||
|
||||
@@ -33,7 +34,9 @@ func rebuild_platform() -> void:
|
||||
collision.shape = shape
|
||||
shape.size = Vector2(platform_width, TILE_SIZE)
|
||||
|
||||
platform_sprite.material.set_shader_parameter("platform_width", platform_width)
|
||||
platform_rect.size.x = platform_width
|
||||
platform_rect.position.x = -platform_width/2
|
||||
platform_rect.material.set_shader_parameter("platform_width", platform_width)
|
||||
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
|
||||
@@ -5,19 +5,38 @@
|
||||
[ext_resource type="Shader" uid="uid://d4hm3vjx1rhsf" path="res://game/shaders/platform.gdshader" id="2_jsq8n"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_2ivtb"]
|
||||
resource_local_to_scene = true
|
||||
shader = ExtResource("2_jsq8n")
|
||||
shader_parameter/tile_size = 16.0
|
||||
shader_parameter/platform_width = 16.0
|
||||
shader_parameter/tile_size = 8.0
|
||||
shader_parameter/platform_width = 24.0
|
||||
shader_parameter/atlas = ExtResource("2_31xwx")
|
||||
shader_parameter/seed = 0.038039055
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_jsq8n"]
|
||||
resource_local_to_scene = true
|
||||
size = Vector2(16, 8)
|
||||
|
||||
[node name="AbstractPlatform" type="Node2D" unique_id=1226827206]
|
||||
script = ExtResource("1_426vp")
|
||||
|
||||
[node name="PlatformSprite" type="Sprite2D" parent="." unique_id=1901062470]
|
||||
[node name="PlatformRect" type="ColorRect" parent="." unique_id=646284480]
|
||||
material = SubResource("ShaderMaterial_2ivtb")
|
||||
texture = ExtResource("2_31xwx")
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -8.0
|
||||
offset_top = -4.0
|
||||
offset_right = 8.0
|
||||
offset_bottom = 4.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
pivot_offset_ratio = Vector2(0.5, 0.5)
|
||||
|
||||
[node name="IconSprite" type="AnimatedSprite2D" parent="." unique_id=287774650]
|
||||
|
||||
[node name="AnimatableBody2D" type="AnimatableBody2D" parent="." unique_id=908936954]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="AnimatableBody2D" unique_id=175449124]
|
||||
shape = SubResource("RectangleShape2D_jsq8n")
|
||||
|
||||
Reference in New Issue
Block a user