Made building warping possible with multiple buildings
This commit is contained in:
parent
2274eab9e1
commit
b7ae0e33ac
7 changed files with 30 additions and 14 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
shader_type canvas_item;
|
shader_type canvas_item;
|
||||||
|
|
||||||
uniform ivec2 location;
|
varying flat ivec2 location;
|
||||||
uniform ivec2 dimension = ivec2(1,1);
|
varying flat ivec2 dimension;
|
||||||
|
|
||||||
uniform float ground_height = 3000.;
|
uniform float ground_height = 3000.;
|
||||||
uniform float cell_height = 300.;
|
uniform float cell_height = 300.;
|
||||||
|
|
@ -12,6 +12,10 @@ varying vec2 world_position;
|
||||||
void vertex()
|
void vertex()
|
||||||
{
|
{
|
||||||
world_position = (MODEL_MATRIX * vec4(VERTEX, 0.0, 1.0)).xy;
|
world_position = (MODEL_MATRIX * vec4(VERTEX, 0.0, 1.0)).xy;
|
||||||
|
location = ivec2(256. * COLOR.xy);
|
||||||
|
dimension = ivec2(256. * COLOR.zw);
|
||||||
|
//location = ivec2(45, 1);
|
||||||
|
//dimension = ivec2(1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fragment() {
|
void fragment() {
|
||||||
|
|
@ -25,6 +29,7 @@ void fragment() {
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
COLOR = texture(TEXTURE, vec2(sample_x, sample_y));
|
COLOR = texture(TEXTURE, vec2(sample_x, sample_y));
|
||||||
|
//COLOR = vec4(ivec4(location, dimension));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,13 @@
|
||||||
[gd_scene load_steps=5 format=3 uid="uid://djawvtdwp423v"]
|
[gd_scene load_steps=6 format=3 uid="uid://djawvtdwp423v"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://b2ji03ekijjnn" path="res://building.gd" id="1_5j34s"]
|
[ext_resource type="Script" uid="uid://b2ji03ekijjnn" path="res://building.gd" id="1_5j34s"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cy70quh6k3s1j" path="res://icon.svg" id="2_2yopf"]
|
[ext_resource type="Texture2D" uid="uid://cy70quh6k3s1j" path="res://icon.svg" id="2_2yopf"]
|
||||||
[ext_resource type="Shader" uid="uid://c7gb1nqwvkr37" path="res://building.gdshader" id="2_f1gjg"]
|
[ext_resource type="Shader" uid="uid://c7gb1nqwvkr37" path="res://building.gdshader" id="2_f1gjg"]
|
||||||
|
[ext_resource type="Script" uid="uid://dj7d4d2xs3nci" path="res://building_mesh.gd" id="4_qnfc1"]
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_qnfc1"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_qnfc1"]
|
||||||
resource_local_to_scene = true
|
resource_local_to_scene = true
|
||||||
shader = ExtResource("2_f1gjg")
|
shader = ExtResource("2_f1gjg")
|
||||||
shader_parameter/location = Vector2i(45, 0)
|
|
||||||
shader_parameter/dimension = Vector2i(1, 1)
|
|
||||||
shader_parameter/ground_height = 3000.0
|
shader_parameter/ground_height = 3000.0
|
||||||
shader_parameter/cell_height = 300.0
|
shader_parameter/cell_height = 300.0
|
||||||
shader_parameter/num_cells = 60
|
shader_parameter/num_cells = 60
|
||||||
|
|
@ -17,6 +16,8 @@ shader_parameter/num_cells = 60
|
||||||
script = ExtResource("1_5j34s")
|
script = ExtResource("1_5j34s")
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
self_modulate = Color(0.1764706, 0, 0.003921569, 0.003921569)
|
||||||
material = SubResource("ShaderMaterial_qnfc1")
|
material = SubResource("ShaderMaterial_qnfc1")
|
||||||
scale = Vector2(7, 7)
|
scale = Vector2(7, 7)
|
||||||
texture = ExtResource("2_2yopf")
|
texture = ExtResource("2_2yopf")
|
||||||
|
script = ExtResource("4_qnfc1")
|
||||||
|
|
|
||||||
7
building_mesh.gd
Normal file
7
building_mesh.gd
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
extends Sprite2D
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
var location = Vector2i(get_parent().location)
|
||||||
|
var dimension = Vector2i(get_parent().dimension)
|
||||||
|
print(location, dimension)
|
||||||
|
self_modulate = Color8(location.x, location.y, dimension.x, dimension.y)
|
||||||
1
building_mesh.gd.uid
Normal file
1
building_mesh.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dj7d4d2xs3nci
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
[gd_scene load_steps=5 format=3 uid="uid://33k5v6skcbsm"]
|
[gd_scene load_steps=4 format=3 uid="uid://33k5v6skcbsm"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://b5fhsy1xlreco" path="res://draw_circle.gd" id="2_2bhor"]
|
[ext_resource type="Script" uid="uid://b5fhsy1xlreco" path="res://draw_circle.gd" id="2_2bhor"]
|
||||||
[ext_resource type="Script" uid="uid://m3vyyfk8gnma" path="res://grid.gd" id="3_2bhor"]
|
[ext_resource type="Script" uid="uid://m3vyyfk8gnma" path="res://grid.gd" id="3_2bhor"]
|
||||||
[ext_resource type="PackedScene" uid="uid://djawvtdwp423v" path="res://building.tscn" id="3_5i67w"]
|
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_5i67w"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_5i67w"]
|
||||||
radius = 3000.0
|
radius = 3000.0
|
||||||
|
|
@ -28,9 +27,3 @@ cell_height = 300.0
|
||||||
num_collumns = 60
|
num_collumns = 60
|
||||||
debug = true
|
debug = true
|
||||||
metadata/_custom_type_script = "uid://m3vyyfk8gnma"
|
metadata/_custom_type_script = "uid://m3vyyfk8gnma"
|
||||||
|
|
||||||
[node name="Building" parent="." instance=ExtResource("3_5i67w")]
|
|
||||||
position = Vector2(-5212, -1497)
|
|
||||||
|
|
||||||
[node name="Building2" parent="." instance=ExtResource("3_5i67w")]
|
|
||||||
position = Vector2(49, 25)
|
|
||||||
|
|
|
||||||
9
grid.gd
9
grid.gd
|
|
@ -32,6 +32,15 @@ func add_building_to_collumn(building : Building, collumn : int):
|
||||||
# for testing
|
# for testing
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
var packed : PackedScene = preload("res://building.tscn")
|
var packed : PackedScene = preload("res://building.tscn")
|
||||||
|
|
||||||
var test_building = packed.instantiate()
|
var test_building = packed.instantiate()
|
||||||
|
test_building.location = Vector2(45, 0)
|
||||||
|
add_child(test_building)
|
||||||
|
|
||||||
|
test_building = packed.instantiate()
|
||||||
|
test_building.location = Vector2(44, 0)
|
||||||
|
add_child(test_building)
|
||||||
|
|
||||||
|
test_building = packed.instantiate()
|
||||||
test_building.location = Vector2(45, 1)
|
test_building.location = Vector2(45, 1)
|
||||||
add_child(test_building)
|
add_child(test_building)
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ config_version=5
|
||||||
|
|
||||||
config/name="The Dark Side of Earth"
|
config/name="The Dark Side of Earth"
|
||||||
run/main_scene="res://earth.tscn"
|
run/main_scene="res://earth.tscn"
|
||||||
config/features=PackedStringArray("4.4", "Forward Plus")
|
config/features=PackedStringArray("4.5", "Forward Plus")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue