diff --git a/assets/scifi_tilesheet@2.png b/assets/scifi_tilesheet@2.png index 4fcc627..c1073a4 100644 Binary files a/assets/scifi_tilesheet@2.png and b/assets/scifi_tilesheet@2.png differ diff --git a/data/scifi_tileset.tres b/data/scifi_tileset.tres index 375dfbc..575130c 100644 --- a/data/scifi_tileset.tres +++ b/data/scifi_tileset.tres @@ -25,24 +25,6 @@ texture_region_size = Vector2i(128, 128) 15:0/0 = 0 16:0/0 = 0 17:0/0 = 0 -18:0/0 = 0 -19:0/0 = 0 -20:0/0 = 0 -21:0/0 = 0 -22:0/0 = 0 -23:0/0 = 0 -24:0/0 = 0 -25:0/0 = 0 -26:0/0 = 0 -27:0/0 = 0 -28:0/0 = 0 -29:0/0 = 0 -30:0/0 = 0 -31:0/0 = 0 -32:0/0 = 0 -33:0/0 = 0 -34:0/0 = 0 -35:0/0 = 0 0:1/0 = 0 1:1/0 = 0 2:1/0 = 0 @@ -61,24 +43,6 @@ texture_region_size = Vector2i(128, 128) 15:1/0 = 0 16:1/0 = 0 17:1/0 = 0 -18:1/0 = 0 -19:1/0 = 0 -20:1/0 = 0 -21:1/0 = 0 -22:1/0 = 0 -23:1/0 = 0 -24:1/0 = 0 -25:1/0 = 0 -26:1/0 = 0 -27:1/0 = 0 -28:1/0 = 0 -29:1/0 = 0 -30:1/0 = 0 -31:1/0 = 0 -32:1/0 = 0 -33:1/0 = 0 -34:1/0 = 0 -35:1/0 = 0 0:2/0 = 0 1:2/0 = 0 2:2/0 = 0 @@ -97,24 +61,6 @@ texture_region_size = Vector2i(128, 128) 15:2/0 = 0 16:2/0 = 0 17:2/0 = 0 -18:2/0 = 0 -19:2/0 = 0 -20:2/0 = 0 -21:2/0 = 0 -22:2/0 = 0 -23:2/0 = 0 -24:2/0 = 0 -25:2/0 = 0 -26:2/0 = 0 -27:2/0 = 0 -28:2/0 = 0 -29:2/0 = 0 -30:2/0 = 0 -31:2/0 = 0 -32:2/0 = 0 -33:2/0 = 0 -34:2/0 = 0 -35:2/0 = 0 0:3/0 = 0 1:3/0 = 0 2:3/0 = 0 @@ -133,24 +79,6 @@ texture_region_size = Vector2i(128, 128) 15:3/0 = 0 16:3/0 = 0 17:3/0 = 0 -18:3/0 = 0 -19:3/0 = 0 -20:3/0 = 0 -21:3/0 = 0 -22:3/0 = 0 -23:3/0 = 0 -24:3/0 = 0 -25:3/0 = 0 -26:3/0 = 0 -27:3/0 = 0 -28:3/0 = 0 -29:3/0 = 0 -30:3/0 = 0 -31:3/0 = 0 -32:3/0 = 0 -33:3/0 = 0 -34:3/0 = 0 -35:3/0 = 0 0:4/0 = 0 1:4/0 = 0 2:4/0 = 0 @@ -169,24 +97,6 @@ texture_region_size = Vector2i(128, 128) 15:4/0 = 0 16:4/0 = 0 17:4/0 = 0 -18:4/0 = 0 -19:4/0 = 0 -20:4/0 = 0 -21:4/0 = 0 -22:4/0 = 0 -23:4/0 = 0 -24:4/0 = 0 -25:4/0 = 0 -26:4/0 = 0 -27:4/0 = 0 -28:4/0 = 0 -29:4/0 = 0 -30:4/0 = 0 -31:4/0 = 0 -32:4/0 = 0 -33:4/0 = 0 -34:4/0 = 0 -35:4/0 = 0 0:5/0 = 0 1:5/0 = 0 2:5/0 = 0 @@ -205,24 +115,6 @@ texture_region_size = Vector2i(128, 128) 15:5/0 = 0 16:5/0 = 0 17:5/0 = 0 -18:5/0 = 0 -19:5/0 = 0 -20:5/0 = 0 -21:5/0 = 0 -22:5/0 = 0 -23:5/0 = 0 -24:5/0 = 0 -25:5/0 = 0 -26:5/0 = 0 -27:5/0 = 0 -28:5/0 = 0 -29:5/0 = 0 -30:5/0 = 0 -31:5/0 = 0 -32:5/0 = 0 -33:5/0 = 0 -34:5/0 = 0 -35:5/0 = 0 0:6/0 = 0 1:6/0 = 0 2:6/0 = 0 @@ -239,35 +131,50 @@ texture_region_size = Vector2i(128, 128) 15:6/0 = 0 16:6/0 = 0 17:6/0 = 0 -18:6/0 = 0 -19:6/0 = 0 -20:6/0 = 0 -21:6/0 = 0 -22:6/0 = 0 -23:6/0 = 0 -24:6/0 = 0 -25:6/0 = 0 -26:6/0 = 0 -27:6/0 = 0 -28:6/0 = 0 -29:6/0 = 0 -30:6/0 = 0 -31:6/0 = 0 -32:6/0 = 0 -33:6/0 = 0 -34:6/0 = 0 -35:6/0 = 0 0:7/0 = 0 -1:7/0 = 0 -2:7/0 = 0 -3:7/0 = 0 4:7/0 = 0 +4:7/0/terrain_set = 0 +4:7/0/terrain = 0 +4:7/0/terrains_peering_bit/bottom_side = 0 5:7/0 = 0 +5:7/0/terrain_set = 0 +5:7/0/terrain = 0 +5:7/0/terrains_peering_bit/right_side = 0 +5:7/0/terrains_peering_bit/bottom_right_corner = 0 +5:7/0/terrains_peering_bit/bottom_side = 0 6:7/0 = 0 +6:7/0/terrain_set = 0 +6:7/0/terrain = 0 +6:7/0/terrains_peering_bit/right_side = 0 +6:7/0/terrains_peering_bit/bottom_right_corner = 0 +6:7/0/terrains_peering_bit/bottom_side = 0 +6:7/0/terrains_peering_bit/bottom_left_corner = 0 +6:7/0/terrains_peering_bit/left_side = 0 7:7/0 = 0 -8:7/0 = 0 +7:7/0/terrain_set = 0 +7:7/0/terrain = 0 +7:7/0/terrains_peering_bit/bottom_side = 0 +7:7/0/terrains_peering_bit/bottom_left_corner = 0 +7:7/0/terrains_peering_bit/left_side = 0 9:7/0 = 0 +9:7/0/terrain_set = 0 +9:7/0/terrain = 0 +9:7/0/terrains_peering_bit/right_side = 0 +9:7/0/terrains_peering_bit/bottom_side = 0 +9:7/0/terrains_peering_bit/left_side = 0 +9:7/0/terrains_peering_bit/top_left_corner = 0 +9:7/0/terrains_peering_bit/top_side = 0 +9:7/0/terrains_peering_bit/top_right_corner = 0 10:7/0 = 0 +10:7/0/terrain_set = 0 +10:7/0/terrain = 0 +10:7/0/terrains_peering_bit/right_side = 0 +10:7/0/terrains_peering_bit/bottom_right_corner = 0 +10:7/0/terrains_peering_bit/bottom_side = 0 +10:7/0/terrains_peering_bit/left_side = 0 +10:7/0/terrains_peering_bit/top_left_corner = 0 +10:7/0/terrains_peering_bit/top_side = 0 +10:7/0/terrains_peering_bit/top_right_corner = 0 11:7/0 = 0 12:7/0 = 0 13:7/0 = 0 @@ -275,35 +182,67 @@ texture_region_size = Vector2i(128, 128) 15:7/0 = 0 16:7/0 = 0 17:7/0 = 0 -18:7/0 = 0 -19:7/0 = 0 -20:7/0 = 0 -21:7/0 = 0 -22:7/0 = 0 -23:7/0 = 0 -24:7/0 = 0 -25:7/0 = 0 -26:7/0 = 0 -27:7/0 = 0 -28:7/0 = 0 -29:7/0 = 0 -30:7/0 = 0 -31:7/0 = 0 -32:7/0 = 0 -33:7/0 = 0 -34:7/0 = 0 -35:7/0 = 0 0:8/0 = 0 1:8/0 = 0 2:8/0 = 0 3:8/0 = 0 4:8/0 = 0 +4:8/0/terrain_set = 0 +4:8/0/terrain = 0 +4:8/0/terrains_peering_bit/bottom_side = 0 +4:8/0/terrains_peering_bit/top_side = 0 5:8/0 = 0 +5:8/0/terrain_set = 0 +5:8/0/terrain = 0 +5:8/0/terrains_peering_bit/right_side = 0 +5:8/0/terrains_peering_bit/bottom_right_corner = 0 +5:8/0/terrains_peering_bit/bottom_side = 0 +5:8/0/terrains_peering_bit/top_side = 0 +5:8/0/terrains_peering_bit/top_right_corner = 0 6:8/0 = 0 +6:8/0/terrain_set = 0 +6:8/0/terrain = 0 +6:8/0/terrains_peering_bit/right_side = 0 +6:8/0/terrains_peering_bit/bottom_right_corner = 0 +6:8/0/terrains_peering_bit/bottom_side = 0 +6:8/0/terrains_peering_bit/bottom_left_corner = 0 +6:8/0/terrains_peering_bit/left_side = 0 +6:8/0/terrains_peering_bit/top_left_corner = 0 +6:8/0/terrains_peering_bit/top_side = 0 +6:8/0/terrains_peering_bit/top_right_corner = 0 7:8/0 = 0 +7:8/0/terrain_set = 0 +7:8/0/terrain = 0 +7:8/0/terrains_peering_bit/bottom_side = 0 +7:8/0/terrains_peering_bit/bottom_left_corner = 0 +7:8/0/terrains_peering_bit/left_side = 0 +7:8/0/terrains_peering_bit/top_left_corner = 0 +7:8/0/terrains_peering_bit/top_side = 0 8:8/0 = 0 +8:8/0/terrain_set = 0 +8:8/0/terrain = 0 +8:8/0/terrains_peering_bit/right_side = 0 +8:8/0/terrains_peering_bit/bottom_side = 0 +8:8/0/terrains_peering_bit/bottom_left_corner = 0 +8:8/0/terrains_peering_bit/left_side = 0 +8:8/0/terrains_peering_bit/top_left_corner = 0 +8:8/0/terrains_peering_bit/top_side = 0 9:8/0 = 0 +9:8/0/terrain_set = 0 +9:8/0/terrain = 0 +9:8/0/terrains_peering_bit/right_side = 0 +9:8/0/terrains_peering_bit/bottom_side = 0 +9:8/0/terrains_peering_bit/left_side = 0 +9:8/0/terrains_peering_bit/top_side = 0 10:8/0 = 0 +10:8/0/terrain_set = 0 +10:8/0/terrain = 0 +10:8/0/terrains_peering_bit/right_side = 0 +10:8/0/terrains_peering_bit/bottom_right_corner = 0 +10:8/0/terrains_peering_bit/bottom_side = 0 +10:8/0/terrains_peering_bit/left_side = 0 +10:8/0/terrains_peering_bit/top_side = 0 +10:8/0/terrains_peering_bit/top_right_corner = 0 11:8/0 = 0 12:8/0 = 0 13:8/0 = 0 @@ -311,35 +250,63 @@ texture_region_size = Vector2i(128, 128) 15:8/0 = 0 16:8/0 = 0 17:8/0 = 0 -18:8/0 = 0 -19:8/0 = 0 -20:8/0 = 0 -21:8/0 = 0 -22:8/0 = 0 -23:8/0 = 0 -24:8/0 = 0 -25:8/0 = 0 -26:8/0 = 0 -27:8/0 = 0 -28:8/0 = 0 -29:8/0 = 0 -30:8/0 = 0 -31:8/0 = 0 -32:8/0 = 0 -33:8/0 = 0 -34:8/0 = 0 -35:8/0 = 0 0:9/0 = 0 1:9/0 = 0 2:9/0 = 0 3:9/0 = 0 4:9/0 = 0 +4:9/0/terrain_set = 0 +4:9/0/terrain = 0 +4:9/0/terrains_peering_bit/top_side = 0 5:9/0 = 0 +5:9/0/terrain_set = 0 +5:9/0/terrain = 0 +5:9/0/terrains_peering_bit/right_side = 0 +5:9/0/terrains_peering_bit/top_side = 0 +5:9/0/terrains_peering_bit/top_right_corner = 0 6:9/0 = 0 +6:9/0/terrain_set = 0 +6:9/0/terrain = 0 +6:9/0/terrains_peering_bit/right_side = 0 +6:9/0/terrains_peering_bit/left_side = 0 +6:9/0/terrains_peering_bit/top_left_corner = 0 +6:9/0/terrains_peering_bit/top_side = 0 +6:9/0/terrains_peering_bit/top_right_corner = 0 7:9/0 = 0 +7:9/0/terrain_set = 0 +7:9/0/terrain = 0 +7:9/0/terrains_peering_bit/left_side = 0 +7:9/0/terrains_peering_bit/top_left_corner = 0 +7:9/0/terrains_peering_bit/top_side = 0 8:9/0 = 0 +8:9/0/terrain_set = 0 +8:9/0/terrain = 0 +8:9/0/terrains_peering_bit/right_side = 0 +8:9/0/terrains_peering_bit/bottom_right_corner = 0 +8:9/0/terrains_peering_bit/bottom_side = 0 +8:9/0/terrains_peering_bit/bottom_left_corner = 0 +8:9/0/terrains_peering_bit/left_side = 0 +8:9/0/terrains_peering_bit/top_left_corner = 0 +8:9/0/terrains_peering_bit/top_side = 0 9:9/0 = 0 +9:9/0/terrain_set = 0 +9:9/0/terrain = 0 +9:9/0/terrains_peering_bit/right_side = 0 +9:9/0/terrains_peering_bit/bottom_right_corner = 0 +9:9/0/terrains_peering_bit/bottom_side = 0 +9:9/0/terrains_peering_bit/bottom_left_corner = 0 +9:9/0/terrains_peering_bit/left_side = 0 +9:9/0/terrains_peering_bit/top_side = 0 10:9/0 = 0 +10:9/0/terrain_set = 0 +10:9/0/terrain = 0 +10:9/0/terrains_peering_bit/right_side = 0 +10:9/0/terrains_peering_bit/bottom_right_corner = 0 +10:9/0/terrains_peering_bit/bottom_side = 0 +10:9/0/terrains_peering_bit/bottom_left_corner = 0 +10:9/0/terrains_peering_bit/left_side = 0 +10:9/0/terrains_peering_bit/top_side = 0 +10:9/0/terrains_peering_bit/top_right_corner = 0 11:9/0 = 0 12:9/0 = 0 13:9/0 = 0 @@ -347,32 +314,26 @@ texture_region_size = Vector2i(128, 128) 15:9/0 = 0 16:9/0 = 0 17:9/0 = 0 -18:9/0 = 0 -19:9/0 = 0 -20:9/0 = 0 -21:9/0 = 0 -22:9/0 = 0 -23:9/0 = 0 -24:9/0 = 0 -25:9/0 = 0 -26:9/0 = 0 -27:9/0 = 0 -28:9/0 = 0 -29:9/0 = 0 -30:9/0 = 0 -31:9/0 = 0 -32:9/0 = 0 -33:9/0 = 0 -34:9/0 = 0 -35:9/0 = 0 0:10/0 = 0 1:10/0 = 0 2:10/0 = 0 3:10/0 = 0 4:10/0 = 0 +4:10/0/terrain_set = 0 +4:10/0/terrain = 0 5:10/0 = 0 +5:10/0/terrain_set = 0 +5:10/0/terrain = 0 +5:10/0/terrains_peering_bit/right_side = 0 6:10/0 = 0 +6:10/0/terrain_set = 0 +6:10/0/terrain = 0 +6:10/0/terrains_peering_bit/right_side = 0 +6:10/0/terrains_peering_bit/left_side = 0 7:10/0 = 0 +7:10/0/terrain_set = 0 +7:10/0/terrain = 0 +7:10/0/terrains_peering_bit/left_side = 0 8:10/0 = 0 9:10/0 = 0 10:10/0 = 0 @@ -383,135 +344,25 @@ texture_region_size = Vector2i(128, 128) 15:10/0 = 0 16:10/0 = 0 17:10/0 = 0 -18:10/0 = 0 -19:10/0 = 0 -20:10/0 = 0 -21:10/0 = 0 -22:10/0 = 0 -23:10/0 = 0 -24:10/0 = 0 -25:10/0 = 0 -26:10/0 = 0 -27:10/0 = 0 -28:10/0 = 0 -29:10/0 = 0 -30:10/0 = 0 -31:10/0 = 0 -32:10/0 = 0 -33:10/0 = 0 -34:10/0 = 0 -35:10/0 = 0 -0:11/0 = 0 -1:11/0 = 0 -2:11/0 = 0 -3:11/0 = 0 -4:11/0 = 0 -5:11/0 = 0 -6:11/0 = 0 -7:11/0 = 0 -8:11/0 = 0 -9:11/0 = 0 -10:11/0 = 0 -11:11/0 = 0 -12:11/0 = 0 -13:11/0 = 0 -14:11/0 = 0 -15:11/0 = 0 -16:11/0 = 0 -17:11/0 = 0 -18:11/0 = 0 -19:11/0 = 0 -20:11/0 = 0 -21:11/0 = 0 -22:11/0 = 0 -23:11/0 = 0 -24:11/0 = 0 -25:11/0 = 0 -26:11/0 = 0 -27:11/0 = 0 -28:11/0 = 0 -29:11/0 = 0 -30:11/0 = 0 -31:11/0 = 0 -32:11/0 = 0 -33:11/0 = 0 -34:11/0 = 0 -35:11/0 = 0 -0:12/0 = 0 -1:12/0 = 0 -2:12/0 = 0 -3:12/0 = 0 -4:12/0 = 0 -5:12/0 = 0 -6:12/0 = 0 -7:12/0 = 0 -8:12/0 = 0 -9:12/0 = 0 -10:12/0 = 0 -11:12/0 = 0 -12:12/0 = 0 -13:12/0 = 0 -14:12/0 = 0 -15:12/0 = 0 -16:12/0 = 0 -17:12/0 = 0 -18:12/0 = 0 -19:12/0 = 0 -20:12/0 = 0 -21:12/0 = 0 -22:12/0 = 0 -23:12/0 = 0 -24:12/0 = 0 -25:12/0 = 0 -26:12/0 = 0 -27:12/0 = 0 -28:12/0 = 0 -29:12/0 = 0 -30:12/0 = 0 -31:12/0 = 0 -32:12/0 = 0 -33:12/0 = 0 -34:12/0 = 0 -35:12/0 = 0 -0:13/0 = 0 -1:13/0 = 0 -2:13/0 = 0 -3:13/0 = 0 -4:13/0 = 0 -5:13/0 = 0 -6:13/0 = 0 -7:13/0 = 0 -8:13/0 = 0 -9:13/0 = 0 -10:13/0 = 0 -11:13/0 = 0 -12:13/0 = 0 -13:13/0 = 0 -14:13/0 = 0 -15:13/0 = 0 -16:13/0 = 0 -17:13/0 = 0 -18:13/0 = 0 -19:13/0 = 0 -20:13/0 = 0 -21:13/0 = 0 -22:13/0 = 0 -23:13/0 = 0 -24:13/0 = 0 -25:13/0 = 0 -26:13/0 = 0 -27:13/0 = 0 -28:13/0 = 0 -29:13/0 = 0 -30:13/0 = 0 -31:13/0 = 0 -32:13/0 = 0 -33:13/0 = 0 -34:13/0 = 0 -35:13/0 = 0 8:6/0 = 0 9:6/0 = 0 +1:7/0 = 0 +2:7/0 = 0 +3:7/0 = 0 +8:7/0 = 0 +8:7/0/terrain_set = 0 +8:7/0/terrain = 0 +8:7/0/terrains_peering_bit/right_side = 0 +8:7/0/terrains_peering_bit/bottom_side = 0 +8:7/0/terrains_peering_bit/bottom_left_corner = 0 +8:7/0/terrains_peering_bit/left_side = 0 +8:7/0/terrains_peering_bit/top_left_corner = 0 +8:7/0/terrains_peering_bit/top_side = 0 +8:7/0/terrains_peering_bit/top_right_corner = 0 [resource] tile_size = Vector2i(128, 128) +terrain_set_0/mode = 0 +terrain_set_0/terrain_0/name = "corruption" +terrain_set_0/terrain_0/color = Color(0.368627, 0.411765, 0.129412, 1) sources/0 = SubResource("TileSetAtlasSource_yq8ar") diff --git a/project.godot b/project.godot index ffdf9e1..c96f054 100644 --- a/project.godot +++ b/project.godot @@ -11,5 +11,6 @@ config_version=5 [application] config/name="Corupture" +run/main_scene="res://scene/world.tscn" config/features=PackedStringArray("4.2", "Forward Plus") config/icon="res://icon.svg" diff --git a/scene/base.tscn b/scene/base.tscn new file mode 100644 index 0000000..0ddcd33 --- /dev/null +++ b/scene/base.tscn @@ -0,0 +1,11 @@ +[gd_scene load_steps=2 format=3 uid="uid://bbsaqy4xm1ldf"] + +[ext_resource type="Script" path="res://scripts/Base.gd" id="1_0nxag"] + +[node name="Base" type="Node2D"] +script = ExtResource("1_0nxag") + +[node name="ExpandTimer" type="Timer" parent="."] +autostart = true + +[connection signal="timeout" from="ExpandTimer" to="." method="_on_expand_timer_timeout"] diff --git a/scene/world.tscn b/scene/world.tscn index 2597e9e..36d55d0 100644 --- a/scene/world.tscn +++ b/scene/world.tscn @@ -1,7 +1,9 @@ -[gd_scene load_steps=5 format=3 uid="uid://m0us5xqa3gnk"] +[gd_scene load_steps=7 format=3 uid="uid://m0us5xqa3gnk"] [ext_resource type="Script" path="res://scripts/world.gd" id="1_yf6q1"] [ext_resource type="TileSet" uid="uid://d1sh6dy2w10b0" path="res://data/scifi_tileset.tres" id="2_sa7dm"] +[ext_resource type="Script" path="res://scripts/Window.gd" id="3_bfjot"] +[ext_resource type="Script" path="res://scripts/BuildingManager.gd" id="4_61js3"] [sub_resource type="FastNoiseLite" id="FastNoiseLite_teaou"] @@ -16,12 +18,18 @@ noise_texture = SubResource("NoiseTexture2D_8pjar") tile_set = ExtResource("2_sa7dm") format = 2 layer_0/name = "ground" -layer_1/name = "environment" +layer_1/name = "Cursor" layer_1/tile_data = PackedInt32Array() -layer_2/name = "buildings" +layer_2/name = "environment" layer_2/tile_data = PackedInt32Array() +layer_3/name = "buildings" +layer_3/tile_data = PackedInt32Array() [node name="Camera2D" type="Camera2D" parent="."] -zoom = Vector2(0.05, 0.05) +zoom = Vector2(0.3, 0.3) drag_horizontal_enabled = true drag_vertical_enabled = true +script = ExtResource("3_bfjot") + +[node name="BuildingManager" type="Node2D" parent="."] +script = ExtResource("4_61js3") diff --git a/scripts/Base.gd b/scripts/Base.gd new file mode 100644 index 0000000..3427c88 --- /dev/null +++ b/scripts/Base.gd @@ -0,0 +1,23 @@ +extends Node2D +class_name Base + +@export var world_grid: TileMap +var grid_loc +var i = 1 + +const curruption_directions := [Vector2i.LEFT, Vector2i.RIGHT, Vector2i.UP, Vector2i.DOWN] +var corruption_tiles: Array[Vector2i] = [] + +func _ready(): + grid_loc = world_grid.local_to_map(position) + corruption_tiles.append(grid_loc) + world_grid.set_cell(Constants.TilemapLayers.BUILDINGS, grid_loc, 0, Vector2i(17,7)) + + +func _on_expand_timer_timeout(): + var corrupt_tile = corruption_tiles.pick_random() + self.curruption_directions.pick_random() + while corruption_tiles.has(corrupt_tile): + corrupt_tile = corruption_tiles.pick_random() + self.curruption_directions.pick_random() + corruption_tiles.append(corrupt_tile) + world_grid.set_cells_terrain_connect(Constants.TilemapLayers.ENVIRONMENT, corruption_tiles, 0, 0) + i += 1 diff --git a/scripts/BuildingManager.gd b/scripts/BuildingManager.gd new file mode 100644 index 0000000..50f2f2c --- /dev/null +++ b/scripts/BuildingManager.gd @@ -0,0 +1,12 @@ +extends Node2D + +@onready var world_grid = $"../world_grid" +var base = preload("res://scene/base.tscn") + +func _unhandled_input(event): + if event is InputEventMouseButton and event.is_pressed() and event.button_index == MOUSE_BUTTON_LEFT: + var build = base.instantiate() + build.position = get_global_mouse_position() + build.world_grid = world_grid + add_child(build) + #world_grid.set_cell(2, world_grid.local_to_map(get_global_mouse_position()), 0, Vector2i(16,2)) diff --git a/scripts/Window.gd b/scripts/Window.gd new file mode 100644 index 0000000..e748efd --- /dev/null +++ b/scripts/Window.gd @@ -0,0 +1,13 @@ +extends Camera2D + +@export var drag_sens: float = 2.0 + +func _unhandled_input(event): + if event is InputEventMouseButton: + match event.button_index: + MOUSE_BUTTON_WHEEL_DOWN: + zoom -= Vector2(0.01, 0.01) + MOUSE_BUTTON_WHEEL_UP: + zoom += Vector2(0.01, 0.01) + if event is InputEventMouseMotion and Input.is_mouse_button_pressed(MOUSE_BUTTON_MIDDLE): + position -= event.relative * drag_sens / zoom diff --git a/scripts/constants.gd b/scripts/constants.gd new file mode 100644 index 0000000..04c0d01 --- /dev/null +++ b/scripts/constants.gd @@ -0,0 +1,9 @@ +extends Node +class_name Constants + +enum TilemapLayers { + GROUND = 0, + CURSOR = 1, + ENVIRONMENT = 2, + BUILDINGS = 3, +} diff --git a/scripts/world.gd b/scripts/world.gd index 7971fa0..c21d974 100644 --- a/scripts/world.gd +++ b/scripts/world.gd @@ -31,3 +31,8 @@ func _ready(): for region in noise_regions.size(): prints(region, noise_regions[region], temp_noise_reg.count(region)) #get_tree().quit() + +func _process(delta): + var mouse_pos = world_grid.local_to_map(get_local_mouse_position()) + world_grid.clear_layer(1) + world_grid.set_cell(1, mouse_pos,0,Vector2i(0,7))