Added abstract colored platform. Reworked platform sprite to viewport
This commit is contained in:
@@ -43,6 +43,7 @@ object = NodePath("..")
|
|||||||
process_callback = 0
|
process_callback = 0
|
||||||
position_smoothing_enabled = true
|
position_smoothing_enabled = true
|
||||||
drag_horizontal_enabled = true
|
drag_horizontal_enabled = true
|
||||||
|
drag_vertical_enabled = true
|
||||||
drag_left_margin = 0.1
|
drag_left_margin = 0.1
|
||||||
drag_top_margin = 0.1
|
drag_top_margin = 0.1
|
||||||
drag_right_margin = 0.1
|
drag_right_margin = 0.1
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
@tool
|
||||||
class_name CollisionSwitcher
|
class_name CollisionSwitcher
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
|
|||||||
@@ -23,12 +23,13 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://cb0w6mt8g4mer" path="res://game/characters/enemies/gray_cultist.tscn" id="18_blgb8"]
|
[ext_resource type="PackedScene" uid="uid://cb0w6mt8g4mer" path="res://game/characters/enemies/gray_cultist.tscn" id="18_blgb8"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cutjutvd8dqqc" path="res://game/characters/enemies/black_cultist.tscn" id="19_ohfy3"]
|
[ext_resource type="PackedScene" uid="uid://cutjutvd8dqqc" path="res://game/characters/enemies/black_cultist.tscn" id="19_ohfy3"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bv2gahb4wxgb1" path="res://game/characters/enemies/white_cultist.tscn" id="20_rt0xo"]
|
[ext_resource type="PackedScene" uid="uid://bv2gahb4wxgb1" path="res://game/characters/enemies/white_cultist.tscn" id="20_rt0xo"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://wpkj48bqyuy2" path="res://game/platform/abstract_colored_platform.tscn" id="24_h1708"]
|
||||||
|
|
||||||
[node name="TestLevel" unique_id=600627332 instance=ExtResource("1_15okj")]
|
[node name="TestLevel" unique_id=600627332 instance=ExtResource("1_15okj")]
|
||||||
script = ExtResource("2_a2sw7")
|
script = ExtResource("2_a2sw7")
|
||||||
|
|
||||||
[node name="AbstractPlatform" parent="Platforms" parent_id_path=PackedInt32Array(1140671629) index="0" unique_id=1226827206 instance=ExtResource("3_pmn5w")]
|
[node name="AbstractPlatform" parent="Platforms" parent_id_path=PackedInt32Array(1140671629) index="0" unique_id=1226827206 instance=ExtResource("3_pmn5w")]
|
||||||
position = Vector2(182, -42)
|
position = Vector2(180, -51)
|
||||||
platform_width = 104
|
platform_width = 104
|
||||||
|
|
||||||
[node name="LeverDoor" parent="Doors" parent_id_path=PackedInt32Array(1468144392) index="0" unique_id=1575363350 instance=ExtResource("2_r01v2")]
|
[node name="LeverDoor" parent="Doors" parent_id_path=PackedInt32Array(1468144392) index="0" unique_id=1575363350 instance=ExtResource("2_r01v2")]
|
||||||
@@ -114,3 +115,7 @@ position = Vector2(1334, 103)
|
|||||||
|
|
||||||
[node name="CollisionShape2D" parent="LevelEnd" index="0" unique_id=937956890]
|
[node name="CollisionShape2D" parent="LevelEnd" index="0" unique_id=937956890]
|
||||||
position = Vector2(42, 59)
|
position = Vector2(42, 59)
|
||||||
|
|
||||||
|
[node name="AbstractColoredPlatform" parent="." index="10" unique_id=137546339 instance=ExtResource("24_h1708")]
|
||||||
|
position = Vector2(274, -81)
|
||||||
|
platform_width = 48
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
@tool
|
||||||
|
class_name AbstractColoredPlatform
|
||||||
|
extends AbstractPlatform
|
||||||
|
|
||||||
|
|
||||||
|
@onready var collision_switcher : CollisionSwitcher = $CollisionSwitcher
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
super._ready()
|
||||||
|
collision_switcher.material = platform_rect.material
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://6hn6ncbqe6cn
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
[gd_scene format=3 uid="uid://wpkj48bqyuy2"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://guvijso3k6eq" path="res://game/platform/abstract_platform.tscn" id="1_8ogjv"]
|
||||||
|
[ext_resource type="Script" uid="uid://6hn6ncbqe6cn" path="res://game/platform/abstract_colored_platform.gd" id="2_3iy2o"]
|
||||||
|
[ext_resource type="Shader" uid="uid://d4hm3vjx1rhsf" path="res://game/shaders/platform.gdshader" id="2_jpqbs"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://cpcuokqv8u2xa" path="res://images/level/platform.png" id="3_3iy2o"]
|
||||||
|
[ext_resource type="Material" uid="uid://d2o2o1w8kb51g" path="res://game/materials/walls_white.tres" id="3_6pvc3"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://5qlocc0yu8ug" path="res://game/collision_switcher.tscn" id="5_3iy2o"]
|
||||||
|
|
||||||
|
[sub_resource type="ViewportTexture" id="ViewportTexture_majud"]
|
||||||
|
viewport_path = NodePath("SubViewport")
|
||||||
|
|
||||||
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_gfbtg"]
|
||||||
|
resource_local_to_scene = true
|
||||||
|
shader = ExtResource("2_jpqbs")
|
||||||
|
shader_parameter/black_color = Color(0, 0, 0, 1)
|
||||||
|
shader_parameter/white_color = Color(1, 1, 1, 1)
|
||||||
|
shader_parameter/switch_colors = false
|
||||||
|
shader_parameter/threshold = 0.5
|
||||||
|
shader_parameter/speed = 0.5
|
||||||
|
shader_parameter/intensity = 1.0
|
||||||
|
shader_parameter/scale = 20.0
|
||||||
|
shader_parameter/tile_size = 8.0
|
||||||
|
shader_parameter/platform_width = 24.0
|
||||||
|
shader_parameter/atlas = ExtResource("3_3iy2o")
|
||||||
|
shader_parameter/seed = 0.23701711
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_2p7w0"]
|
||||||
|
resource_local_to_scene = true
|
||||||
|
size = Vector2(16, 7)
|
||||||
|
|
||||||
|
[node name="AbstractColoredPlatform" unique_id=137546339 instance=ExtResource("1_8ogjv")]
|
||||||
|
collision_layer = 32
|
||||||
|
script = ExtResource("2_3iy2o")
|
||||||
|
|
||||||
|
[node name="Sprite2D" parent="." index="0" unique_id=264863796]
|
||||||
|
material = ExtResource("3_6pvc3")
|
||||||
|
texture = SubResource("ViewportTexture_majud")
|
||||||
|
|
||||||
|
[node name="PlatformRect" parent="SubViewport" parent_id_path=PackedInt32Array(226200089) index="0" unique_id=794315918]
|
||||||
|
material = SubResource("ShaderMaterial_gfbtg")
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" parent="." index="2" unique_id=175449124]
|
||||||
|
shape = SubResource("RectangleShape2D_2p7w0")
|
||||||
|
|
||||||
|
[node name="CollisionSwitcher" parent="." index="3" unique_id=542648449 node_paths=PackedStringArray("object") instance=ExtResource("5_3iy2o")]
|
||||||
|
object = NodePath("..")
|
||||||
@@ -16,9 +16,10 @@ const MAX_WIDTH = TILE_SIZE * 32
|
|||||||
rebuild_platform()
|
rebuild_platform()
|
||||||
|
|
||||||
|
|
||||||
@onready var collision: CollisionShape2D = $AnimatableBody2D/CollisionShape2D
|
@onready var collision: CollisionShape2D = $CollisionShape2D
|
||||||
@onready var platform_rect: ColorRect = $PlatformRect
|
@onready var sub_viewport: SubViewport = $SubViewport
|
||||||
@onready var icon_sprite: AnimatedSprite2D = $IconSprite
|
@onready var platform_rect: ColorRect = $SubViewport/PlatformRect
|
||||||
|
@onready var icon_sprite: AnimatedSprite2D = $SubViewport/IconSprite
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
@@ -29,13 +30,13 @@ func _ready() -> void:
|
|||||||
|
|
||||||
func rebuild_platform() -> void:
|
func rebuild_platform() -> void:
|
||||||
var shape := collision.shape as RectangleShape2D
|
var shape := collision.shape as RectangleShape2D
|
||||||
if not shape:
|
|
||||||
shape = RectangleShape2D.new()
|
|
||||||
collision.shape = shape
|
|
||||||
shape.size = Vector2(platform_width, TILE_SIZE)
|
shape.size = Vector2(platform_width, TILE_SIZE)
|
||||||
|
|
||||||
|
sub_viewport.size = Vector2(platform_width, TILE_SIZE)
|
||||||
platform_rect.size.x = platform_width
|
platform_rect.size.x = platform_width
|
||||||
platform_rect.position.x = -platform_width/2
|
platform_rect.position = Vector2.ZERO
|
||||||
|
icon_sprite.position = Vector2.ZERO
|
||||||
|
|
||||||
platform_rect.material.set_shader_parameter("platform_width", platform_width)
|
platform_rect.material.set_shader_parameter("platform_width", platform_width)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,25 +1,48 @@
|
|||||||
[gd_scene format=3 uid="uid://guvijso3k6eq"]
|
[gd_scene format=3 uid="uid://guvijso3k6eq"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://kjy0t56tgpxs" path="res://game/platform/abstract_platform.gd" id="1_426vp"]
|
[ext_resource type="Script" uid="uid://kjy0t56tgpxs" path="res://game/platform/abstract_platform.gd" id="1_426vp"]
|
||||||
|
[ext_resource type="Material" uid="uid://dojhoc6ljpt1a" path="res://game/materials/walls_gray.tres" id="2_2ivtb"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cpcuokqv8u2xa" path="res://images/level/platform.png" id="2_31xwx"]
|
[ext_resource type="Texture2D" uid="uid://cpcuokqv8u2xa" path="res://images/level/platform.png" id="2_31xwx"]
|
||||||
[ext_resource type="Shader" uid="uid://d4hm3vjx1rhsf" path="res://game/shaders/platform.gdshader" id="2_jsq8n"]
|
[ext_resource type="Shader" uid="uid://d4hm3vjx1rhsf" path="res://game/shaders/platform.gdshader" id="2_jsq8n"]
|
||||||
|
|
||||||
|
[sub_resource type="ViewportTexture" id="ViewportTexture_2ivtb"]
|
||||||
|
viewport_path = NodePath("SubViewport")
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_2ivtb"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_2ivtb"]
|
||||||
resource_local_to_scene = true
|
resource_local_to_scene = true
|
||||||
shader = ExtResource("2_jsq8n")
|
shader = ExtResource("2_jsq8n")
|
||||||
|
shader_parameter/black_color = Color(0, 0, 0, 1)
|
||||||
|
shader_parameter/white_color = Color(1, 1, 1, 1)
|
||||||
|
shader_parameter/switch_colors = false
|
||||||
|
shader_parameter/threshold = 0.5
|
||||||
|
shader_parameter/speed = 0.5
|
||||||
|
shader_parameter/intensity = 1.0
|
||||||
|
shader_parameter/scale = 20.0
|
||||||
shader_parameter/tile_size = 8.0
|
shader_parameter/tile_size = 8.0
|
||||||
shader_parameter/platform_width = 24.0
|
shader_parameter/platform_width = 24.0
|
||||||
shader_parameter/atlas = ExtResource("2_31xwx")
|
shader_parameter/atlas = ExtResource("2_31xwx")
|
||||||
shader_parameter/seed = 0.038039055
|
shader_parameter/seed = 0.7482483
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_jsq8n"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_jsq8n"]
|
||||||
resource_local_to_scene = true
|
resource_local_to_scene = true
|
||||||
size = Vector2(16, 8)
|
size = Vector2(16, 7)
|
||||||
|
|
||||||
[node name="AbstractPlatform" type="Node2D" unique_id=1226827206]
|
[node name="AbstractPlatform" type="AnimatableBody2D" unique_id=137546339]
|
||||||
|
collision_mask = 0
|
||||||
script = ExtResource("1_426vp")
|
script = ExtResource("1_426vp")
|
||||||
|
|
||||||
[node name="PlatformRect" type="ColorRect" parent="." unique_id=646284480]
|
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=264863796]
|
||||||
|
material = ExtResource("2_2ivtb")
|
||||||
|
texture = SubResource("ViewportTexture_2ivtb")
|
||||||
|
|
||||||
|
[node name="SubViewport" type="SubViewport" parent="." unique_id=226200089]
|
||||||
|
transparent_bg = true
|
||||||
|
handle_input_locally = false
|
||||||
|
canvas_item_default_texture_filter = 0
|
||||||
|
size = Vector2i(16, 8)
|
||||||
|
render_target_update_mode = 4
|
||||||
|
|
||||||
|
[node name="PlatformRect" type="ColorRect" parent="SubViewport" unique_id=794315918]
|
||||||
material = SubResource("ShaderMaterial_2ivtb")
|
material = SubResource("ShaderMaterial_2ivtb")
|
||||||
anchors_preset = 8
|
anchors_preset = 8
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
@@ -33,10 +56,11 @@ offset_bottom = 4.0
|
|||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
pivot_offset_ratio = Vector2(0.5, 0.5)
|
pivot_offset_ratio = Vector2(0.5, 0.5)
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
size_flags_vertical = 4
|
||||||
|
|
||||||
[node name="IconSprite" type="AnimatedSprite2D" parent="." unique_id=287774650]
|
[node name="IconSprite" type="AnimatedSprite2D" parent="SubViewport" unique_id=1917841765]
|
||||||
|
|
||||||
[node name="AnimatableBody2D" type="AnimatableBody2D" parent="." unique_id=908936954]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=175449124]
|
||||||
|
position = Vector2(0, -0.5)
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="AnimatableBody2D" unique_id=175449124]
|
|
||||||
shape = SubResource("RectangleShape2D_jsq8n")
|
shape = SubResource("RectangleShape2D_jsq8n")
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
shader_type canvas_item;
|
shader_type canvas_item;
|
||||||
|
|
||||||
|
#include "get_black_n_white.gdshaderinc"
|
||||||
|
|
||||||
uniform float tile_size = 8.0;
|
uniform float tile_size = 8.0;
|
||||||
uniform float platform_width = 24.0;
|
uniform float platform_width = 24.0;
|
||||||
uniform sampler2D atlas : filter_nearest;
|
uniform sampler2D atlas : filter_nearest;
|
||||||
@@ -35,4 +37,5 @@ void fragment() {
|
|||||||
vec2 atlas_size = vec2(textureSize(atlas, 0));
|
vec2 atlas_size = vec2(textureSize(atlas, 0));
|
||||||
vec2 atlas_uv = atlas_pixel / atlas_size;
|
vec2 atlas_uv = atlas_pixel / atlas_size;
|
||||||
COLOR = texture(atlas, atlas_uv);
|
COLOR = texture(atlas, atlas_uv);
|
||||||
|
COLOR = get_black_and_white(COLOR, UV, TIME);
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
Binary file not shown.
Reference in New Issue
Block a user