diff --git a/Main.tscn b/Main.tscn index e6a4dec..77a4589 100644 --- a/Main.tscn +++ b/Main.tscn @@ -1,10 +1,31 @@ -[gd_scene load_steps=3 format=3 uid="uid://5ske2hm55rce"] +[gd_scene load_steps=8 format=3 uid="uid://5ske2hm55rce"] [ext_resource type="Theme" uid="uid://d035h7upxrw3h" path="res://theme.tres" id="1_xbn5h"] -[ext_resource type="Script" path="res://main.gd" id="1_xjws2"] +[ext_resource type="Texture2D" uid="uid://bsrh0u02bckhy" path="res://iso_building.png" id="3_qa5pv"] +[ext_resource type="Texture2D" uid="uid://bvn5lewpp7pmd" path="res://iso_tile.png" id="4_7pks7"] +[ext_resource type="Script" path="res://tile_map.gd" id="5_v47eg"] + +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_dxrqb"] +texture = ExtResource("4_7pks7") +margins = Vector2i(16, 16) +1:1/0 = 0 +0:0/0 = 0 + +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_j7eew"] +texture = ExtResource("3_qa5pv") +margins = Vector2i(15, 14) +texture_region_size = Vector2i(18, 20) +1:1/0 = 0 +0:0/0 = 0 + +[sub_resource type="TileSet" id="TileSet_2mye8"] +tile_shape = 1 +tile_layout = 5 +tile_size = Vector2i(16, 8) +sources/0 = SubResource("TileSetAtlasSource_dxrqb") +sources/1 = SubResource("TileSetAtlasSource_j7eew") [node name="Main" type="Node2D"] -script = ExtResource("1_xjws2") [node name="Control" type="Control" parent="."] layout_mode = 3 @@ -12,3 +33,12 @@ anchors_preset = 0 offset_right = 40.0 offset_bottom = 40.0 theme = ExtResource("1_xbn5h") + +[node name="TileMap" type="TileMap" parent="."] +tile_set = SubResource("TileSet_2mye8") +rendering_quadrant_size = 128 +format = 2 +layer_1/name = "Layer1" +script = ExtResource("5_v47eg") + +[node name="Camera2D" type="Camera2D" parent="."] diff --git a/Test_Building.tscn b/Test_Building.tscn deleted file mode 100644 index 0db25ad..0000000 --- a/Test_Building.tscn +++ /dev/null @@ -1,6 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://bxf8c2vnv1cs6"] - -[ext_resource type="Texture2D" uid="uid://bi03hh1ousovx" path="res://icon.svg" id="1_5dc4m"] - -[node name="TestBulding" type="Sprite2D"] -texture = ExtResource("1_5dc4m") diff --git a/iso_building.png b/iso_building.png new file mode 100644 index 0000000..1617483 Binary files /dev/null and b/iso_building.png differ diff --git a/iso_building.png.import b/iso_building.png.import new file mode 100644 index 0000000..085692a --- /dev/null +++ b/iso_building.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bsrh0u02bckhy" +path="res://.godot/imported/iso_building.png-07fa6cdf1b52a70a76ecc45b8890244f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://iso_building.png" +dest_files=["res://.godot/imported/iso_building.png-07fa6cdf1b52a70a76ecc45b8890244f.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/iso_tile.png b/iso_tile.png new file mode 100644 index 0000000..7813bee Binary files /dev/null and b/iso_tile.png differ diff --git a/iso_tile.png.import b/iso_tile.png.import new file mode 100644 index 0000000..57f7797 --- /dev/null +++ b/iso_tile.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bvn5lewpp7pmd" +path="res://.godot/imported/iso_tile.png-22fe1886c3f7d12f0ecefdbde6a3adae.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://iso_tile.png" +dest_files=["res://.godot/imported/iso_tile.png-22fe1886c3f7d12f0ecefdbde6a3adae.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/main.gd b/main.gd deleted file mode 100644 index 938c332..0000000 --- a/main.gd +++ /dev/null @@ -1,9 +0,0 @@ -extends Node2D - -var test_building_scene: PackedScene = preload("res://Test_Building.tscn") - -func _process(_delta): - if Input.is_action_just_pressed("lclick"): - var test_building: Sprite2D = test_building_scene.instantiate() - test_building.position = get_global_mouse_position() - $".".add_child(test_building) diff --git a/tile_map.gd b/tile_map.gd new file mode 100644 index 0000000..663690d --- /dev/null +++ b/tile_map.gd @@ -0,0 +1,30 @@ +extends TileMap + +var GridSize = 16 +var Dic = {} +var placed = [] + +func _ready(): + for x in GridSize: + for y in GridSize: + Dic[str(Vector2(x,y))] = { + "Type": "Ground", + "Position": str(Vector2(x,y)), + "Placed": false + } + set_cell(0, Vector2(x, y), 0, Vector2i(0,0), 0) + +func _process(delta): + var tile = local_to_map(get_global_mouse_position()) + + for x in GridSize: + for y in GridSize: + if !Dic[str(Vector2(x,y))].get("Placed"): + erase_cell(1, Vector2(x,y)) + + if Dic.has(str(tile)): + set_cell(1, tile, 1, Vector2i(0,0), 0) + #print(Dic[str(tile)]) + + if Input.is_action_just_pressed("lclick"): + Dic[str(tile)]["Placed"] = true