diff --git a/Scene/Interactibles/Crate.tscn b/Scene/Interactibles/Crate.tscn new file mode 100644 index 0000000..eb9c7a1 --- /dev/null +++ b/Scene/Interactibles/Crate.tscn @@ -0,0 +1,34 @@ +[gd_scene load_steps=4 format=3 uid="uid://nv8r4yu48mbj"] + +[ext_resource type="Script" path="res://Scripts/Interactibles/Crate.gd" id="1_a65k5"] +[ext_resource type="Texture2D" uid="uid://b4nga0rwqktws" path="res://Tilemaps/Tiles/tile_0274.png" id="1_aetqf"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_jjien"] +size = Vector2(16, 16) + +[node name="Crate" type="Area2D"] +script = ExtResource("1_a65k5") +Interact_Type = "Crate1" + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture_filter = 1 +texture_repeat = 1 +texture = ExtResource("1_aetqf") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(-16, 0) +shape = SubResource("RectangleShape2D_jjien") + +[node name="CollisionShape2D2" type="CollisionShape2D" parent="."] +position = Vector2(0, -16) +shape = SubResource("RectangleShape2D_jjien") + +[node name="CollisionShape2D3" type="CollisionShape2D" parent="."] +position = Vector2(0, 16) +shape = SubResource("RectangleShape2D_jjien") + +[node name="CollisionShape2D4" type="CollisionShape2D" parent="."] +position = Vector2(16, 0) +shape = SubResource("RectangleShape2D_jjien") + +[connection signal="body_entered" from="." to="." method="_on_body_entered"] diff --git a/Scene/PlayerScene.tscn b/Scene/PlayerScene.tscn index 99795fc..e0f3852 100644 --- a/Scene/PlayerScene.tscn +++ b/Scene/PlayerScene.tscn @@ -1,8 +1,20 @@ -[gd_scene load_steps=2 format=3 uid="uid://dy12im5456ufx"] +[gd_scene load_steps=4 format=3 uid="uid://dy12im5456ufx"] [ext_resource type="Texture2D" uid="uid://degatxb7g5fr7" path="res://Tilemaps/tile_0350.png" id="1_jp5c8"] +[ext_resource type="Script" path="res://Scripts/PlayerControler.gd" id="1_vtlo0"] -[node name="PlayerScene" type="Area2D"] +[sub_resource type="RectangleShape2D" id="RectangleShape2D_qegmh"] +size = Vector2(14, 14) + +[node name="PlayerScene" type="CharacterBody2D"] +script = ExtResource("1_vtlo0") [node name="Tile0350" type="Sprite2D" parent="."] +texture_filter = 1 +position = Vector2(0, -1) texture = ExtResource("1_jp5c8") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("RectangleShape2D_qegmh") + +[connection signal="can_interact" from="." to="." method="_on_can_interact"] diff --git a/Scene/TestScene.tscn b/Scene/TestScene.tscn index a731893..c82abf5 100644 --- a/Scene/TestScene.tscn +++ b/Scene/TestScene.tscn @@ -1,562 +1,30 @@ -[gd_scene load_steps=6 format=3 uid="uid://bvam15obn13sp"] +[gd_scene load_steps=4 format=3 uid="uid://bvam15obn13sp"] -[ext_resource type="Texture2D" uid="uid://n6wwhbhv6t6t" path="res://Tilemaps/tilemap_packed.png" id="1_o5o7o"] -[ext_resource type="Texture2D" uid="uid://degatxb7g5fr7" path="res://Tilemaps/tile_0350.png" id="2_ew7fn"] -[ext_resource type="Script" path="res://Scripts/PlayerControler.gd" id="3_mg7rp"] - -[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_om8rr"] -resource_name = "Tilemap1" -texture = ExtResource("1_o5o7o") -0:0/0 = 0 -1:0/0 = 0 -2:0/0 = 0 -3:0/0 = 0 -4:0/0 = 0 -5:0/0 = 0 -6:0/0 = 0 -7:0/0 = 0 -8:0/0 = 0 -9:0/0 = 0 -10:0/0 = 0 -11:0/0 = 0 -12:0/0 = 0 -13:0/0 = 0 -14:0/0 = 0 -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 -0:1/0 = 0 -1:1/0 = 0 -2:1/0 = 0 -3:1/0 = 0 -4:1/0 = 0 -5:1/0 = 0 -6:1/0 = 0 -7:1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= 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 -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 -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 -0:14/0 = 0 -1:14/0 = 0 -2:14/0 = 0 -3:14/0 = 0 -4:14/0 = 0 -5:14/0 = 0 -6:14/0 = 0 -7:14/0 = 0 -8:14/0 = 0 -9:14/0 = 0 -10:14/0 = 0 -11:14/0 = 0 -12:14/0 = 0 -13:14/0 = 0 -14:14/0 = 0 -15:14/0 = 0 -16:14/0 = 0 -17:14/0 = 0 -18:14/0 = 0 -19:14/0 = 0 -20:14/0 = 0 -21:14/0 = 0 -22:14/0 = 0 -23:14/0 = 0 -24:14/0 = 0 -25:14/0 = 0 -26:14/0 = 0 -27:14/0 = 0 -0:15/0 = 0 -1:15/0 = 0 -2:15/0 = 0 -3:15/0 = 0 -4:15/0 = 0 -5:15/0 = 0 -6:15/0 = 0 -7:15/0 = 0 -8:15/0 = 0 -9:15/0 = 0 -10:15/0 = 0 -11:15/0 = 0 -12:15/0 = 0 -13:15/0 = 0 -14:15/0 = 0 -15:15/0 = 0 -16:15/0 = 0 -17:15/0 = 0 -18:15/0 = 0 -19:15/0 = 0 -20:15/0 = 0 -21:15/0 = 0 -22:15/0 = 0 -23:15/0 = 0 -24:15/0 = 0 -25:15/0 = 0 -26:15/0 = 0 -27:15/0 = 0 -0:16/0 = 0 -1:16/0 = 0 -2:16/0 = 0 -3:16/0 = 0 -4:16/0 = 0 -5:16/0 = 0 -6:16/0 = 0 -7:16/0 = 0 -8:16/0 = 0 -9:16/0 = 0 -10:16/0 = 0 -11:16/0 = 0 -12:16/0 = 0 -13:16/0 = 0 -14:16/0 = 0 -15:16/0 = 0 -16:16/0 = 0 -17:16/0 = 0 -18:16/0 = 0 -19:16/0 = 0 -20:16/0 = 0 -21:16/0 = 0 -22:16/0 = 0 -23:16/0 = 0 -24:16/0 = 0 -25:16/0 = 0 -26:16/0 = 0 -27:16/0 = 0 -0:17/0 = 0 -1:17/0 = 0 -2:17/0 = 0 -3:17/0 = 0 -4:17/0 = 0 -5:17/0 = 0 -6:17/0 = 0 -7:17/0 = 0 -8:17/0 = 0 -9:17/0 = 0 -10:17/0 = 0 -11:17/0 = 0 -12:17/0 = 0 -13:17/0 = 0 -14:17/0 = 0 -15:17/0 = 0 -16:17/0 = 0 -17:17/0 = 0 -18:17/0 = 0 -19:17/0 = 0 -20:17/0 = 0 -21:17/0 = 0 -22:17/0 = 0 -23:17/0 = 0 -24:17/0 = 0 -25:17/0 = 0 -26:17/0 = 0 -27:17/0 = 0 -0:18/0 = 0 -1:18/0 = 0 -2:18/0 = 0 -3:18/0 = 0 -4:18/0 = 0 -5:18/0 = 0 -6:18/0 = 0 -7:18/0 = 0 -8:18/0 = 0 -9:18/0 = 0 -10:18/0 = 0 -11:18/0 = 0 -12:18/0 = 0 -13:18/0 = 0 -14:18/0 = 0 -15:18/0 = 0 -16:18/0 = 0 -17:18/0 = 0 -18:18/0 = 0 -19:18/0 = 0 -20:18/0 = 0 -21:18/0 = 0 -22:18/0 = 0 -23:18/0 = 0 -24:18/0 = 0 -25:18/0 = 0 -26:18/0 = 0 -27:18/0 = 0 - -[sub_resource type="TileSet" id="TileSet_8ya2m"] -custom_data_layer_0/name = "is_solid" -custom_data_layer_0/type = 1 -custom_data_layer_1/name = "is_interact" -custom_data_layer_1/type = 1 -sources/0 = SubResource("TileSetAtlasSource_om8rr") +[ext_resource type="TileSet" uid="uid://btq4xft7ghfa1" path="res://Tilemaps/TestScene.tres" id="1_ppucb"] +[ext_resource type="Script" path="res://Scripts/NavigationTiles.gd" id="2_j8mqm"] +[ext_resource type="PackedScene" uid="uid://dy12im5456ufx" path="res://Scene/PlayerScene.tscn" id="3_hlgkw"] [node name="Node2D" type="Node2D"] -[node name="TileMap" type="TileMap" parent="."] -texture_filter = 1 -tile_set = SubResource("TileSet_8ya2m") -format = 2 -layer_0/tile_data = PackedInt32Array(196624, 1048576, 805306375, 262160, 1048576, 5, 327696, 1048576, 5, 327695, 589824, 10, 262159, 327680, 10, 196623, 458752, 10, 131087, 1048576, 1342177285, 131086, 1048576, 1342177285, 131085, 1048576, 1342177285, 131088, 1048576, 1610612743, 131084, 1048576, 1342177287) +[node name="Camera2D" type="Camera2D" parent="."] +scale = Vector2(1, 0.68) +offset = Vector2(84.925, 47.62) +zoom = Vector2(6.645, 6.645) -[node name="Sprite2D" type="Sprite2D" parent="."] +[node name="NavigationMap" type="TileMap" parent="."] texture_filter = 1 -position = Vector2(200, 56) -texture = ExtResource("2_ew7fn") -script = ExtResource("3_mg7rp") +tile_set = ExtResource("1_ppucb") +format = 2 +layer_0/name = "Background" +layer_0/tile_data = PackedInt32Array(65537, 524288, 0, 131073, 524288, 1, 196609, 524288, 1, 262145, 524288, 2, 327681, 1048576, 1610612740, 65538, 589824, 0, 131074, 589824, 1, 196610, 589824, 1, 262146, 589824, 2, 327682, 1048576, 1610612742, 65539, 589824, 0, 196611, 589824, 1, 262147, 589824, 2, 327683, 1048576, 1610612742, 65540, 589824, 0, 262148, 589824, 2, 327684, 1048576, 1610612742, 65541, 655360, 0, 131077, 655360, 1, 196613, 655360, 1, 262149, 655360, 2, 327685, 1048576, 1610612742, 65542, 1048576, 5, 131078, 1048576, 5, 196614, 1048576, 5, 262150, 1048576, 5, 327686, 1048576, 7, 0, 1048576, 4, 65536, 1048576, 5, 131072, 1048576, 5, 196608, 1048576, 5, 262144, 1048576, 5, 327680, 1048576, 7, 1, 1048576, 1610612740, 2, 1048576, 1610612742, 3, 1048576, 1610612742, 4, 1048576, 1610612742, 5, 1048576, 1610612742, 6, 1048576, 4, 131075, 589824, 1, 196612, 589824, 1, 131076, 589824, 1) +layer_1/name = "Object" +layer_1/tile_data = PackedInt32Array(131076, 3, 65536) +layer_2/name = "ColisionMask" +layer_2/modulate = Color(1, 1, 1, 0) +layer_2/tile_data = PackedInt32Array(131076, 1048576, 5) +script = ExtResource("2_j8mqm") + +[node name="PlayerScene" parent="." instance=ExtResource("3_hlgkw")] +position = Vector2(24, 24) + +[connection signal="body_entered" from="NavigationMap/Crate" to="NavigationMap/Crate" method="_on_body_entered"] diff --git a/Scripts/Interactibles/Crate.gd b/Scripts/Interactibles/Crate.gd new file mode 100644 index 0000000..747911c --- /dev/null +++ b/Scripts/Interactibles/Crate.gd @@ -0,0 +1,18 @@ +extends Interactible + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + + +func _on_body_entered(body : Player): + body.can_interact.emit(Interact_Type,self) + + + diff --git a/Scripts/Interactibles/InteractibleClass.gd b/Scripts/Interactibles/InteractibleClass.gd new file mode 100644 index 0000000..cce2075 --- /dev/null +++ b/Scripts/Interactibles/InteractibleClass.gd @@ -0,0 +1,6 @@ +class_name Interactible extends Area2D + +@export +var Interact_Type = "none" + + diff --git a/Scripts/NavigationTiles.gd b/Scripts/NavigationTiles.gd new file mode 100644 index 0000000..7aed784 --- /dev/null +++ b/Scripts/NavigationTiles.gd @@ -0,0 +1,38 @@ +extends TileMap + +var astar = AStarGrid2D.new() +var map_rect = Rect2i() +const main_layer = 0 + +# Called when the node enters the scene tree for the first time. +func _ready(): + + var tile_size = get_tileset().tile_size + var tilemap_size = get_used_rect().end - get_used_rect().position + map_rect = Rect2i(Vector2i(), tilemap_size) + + astar.region = map_rect + astar.cell_size = tile_size + astar.offset = tile_size * 0.5 + astar.default_compute_heuristic = AStarGrid2D.HEURISTIC_MANHATTAN + + astar.diagonal_mode = AStarGrid2D.DIAGONAL_MODE_NEVER + astar.update() + + + for cell in get_used_cells(main_layer): + astar.set_point_solid(cell, is_spot_solid(main_layer,cell)) + for cell in get_used_cells(2): + astar.set_point_solid(cell, is_spot_solid(2,cell)) + + +func is_spot_solid(layer : int,spot : Vector2i) -> bool : + return get_cell_tile_data(layer,spot).get_custom_data("is_solid") + +func is_spot_walkable(spot) -> bool : + var map_pos = local_to_map(spot) + if map_rect.has_point(map_pos): + return not astar.is_point_solid(map_pos) + return false + + diff --git a/Scripts/PlayerControler.gd b/Scripts/PlayerControler.gd index dee7b76..b517b79 100644 --- a/Scripts/PlayerControler.gd +++ b/Scripts/PlayerControler.gd @@ -1,6 +1,9 @@ -extends Sprite2D +extends CharacterBody2D +class_name Player +@onready var gridcontrol: TileMap = $"../NavigationMap" +var current_path : Array[Vector2i] # Called when the node enters the scene tree for the first time. func _ready(): pass # Replace with function body. @@ -9,3 +12,28 @@ func _ready(): # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): pass + +func _physics_process(delta): + if current_path.is_empty(): + return + var target_position = gridcontrol.map_to_local(current_path.front()) + global_position = global_position.move_toward(target_position, 5) + + if global_position == target_position: + current_path.pop_front() + +func _unhandled_input(event): + var click_position = get_global_mouse_position() + if event.is_action_pressed("move_to"): + if gridcontrol.is_spot_walkable(click_position): + current_path = gridcontrol.astar.get_id_path( + gridcontrol.local_to_map(global_position), + gridcontrol.local_to_map(click_position) + ).slice(1) + +signal can_interact(object : String) + + + +func _on_can_interact(Interact_Type: String, object : Interactible): + prints("yippie", Interact_Type) diff --git a/Tilemaps/Information.png b/Tilemaps/Information.png new file mode 100644 index 0000000..9935508 Binary files /dev/null and b/Tilemaps/Information.png differ diff --git a/Tilemaps/Information.png.import b/Tilemaps/Information.png.import new file mode 100644 index 0000000..caf8ac6 --- /dev/null +++ b/Tilemaps/Information.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ctoivxr2npa6p" +path="res://.godot/imported/Information.png-3404e12edf12f3084cbb4c01f20ede6c.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Tilemaps/Information.png" +dest_files=["res://.godot/imported/Information.png-3404e12edf12f3084cbb4c01f20ede6c.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/Tilemaps/Instructions.url b/Tilemaps/Instructions.url new file mode 100644 index 0000000..f67aaf0 --- /dev/null +++ b/Tilemaps/Instructions.url @@ -0,0 +1,6 @@ +[InternetShortcut] +URL=https://kenney.nl/documentation/game-assets/isometric +IDList= +HotKey=0 +[{000214A0-0000-0000-C000-000000000046}] +Prop3=19,11 diff --git a/Tilemaps/TestScene.tres b/Tilemaps/TestScene.tres new file mode 100644 index 0000000..3348e00 --- /dev/null +++ b/Tilemaps/TestScene.tres @@ -0,0 +1,515 @@ +[gd_resource type="TileSet" load_steps=5 format=3 uid="uid://btq4xft7ghfa1"] + +[ext_resource type="Texture2D" uid="uid://n6wwhbhv6t6t" path="res://Tilemaps/tilemap_packed.png" id="1_eewka"] +[ext_resource type="PackedScene" uid="uid://nv8r4yu48mbj" path="res://Scene/Interactibles/Crate.tscn" id="2_oi0ah"] + +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_om8rr"] +resource_name = "Tilemap1" +texture = ExtResource("1_eewka") +0:0/0 = 0 +1:0/0 = 0 +2:0/0 = 0 +3:0/0 = 0 +4:0/0 = 0 +5:0/0 = 0 +6:0/0 = 0 +7:0/0 = 0 +8:0/0 = 0 +9:0/0 = 0 +10:0/0 = 0 +11:0/0 = 0 +12:0/0 = 0 +13:0/0 = 0 +14:0/0 = 0 +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 +0:1/0 = 0 +1:1/0 = 0 +2:1/0 = 0 +3:1/0 = 0 +4:1/0 = 0 +5:1/0 = 0 +6:1/0 = 0 +7:1/0 = 0 +8:1/0 = 0 +9:1/0 = 0 +10:1/0 = 0 +11:1/0 = 0 +12:1/0 = 0 +13:1/0 = 0 +14:1/0 = 0 +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 +0:2/0 = 0 +1:2/0 = 0 +2:2/0 = 0 +3:2/0 = 0 +4:2/0 = 0 +5:2/0 = 0 +6:2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 0 +25:8/0 = 0 +26:8/0 = 0 +0:9/0 = 0 +1:9/0 = 0 +2:9/0 = 0 +3:9/0 = 0 +4:9/0 = 0 +5:9/0 = 0 +6:9/0 = 0 +7:9/0 = 0 +8:9/0 = 0 +9:9/0 = 0 +10:9/0 = 0 +11:9/0 = 0 +12:9/0 = 0 +13:9/0 = 0 +14:9/0 = 0 +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 +0:10/0 = 0 +1:10/0 = 0 +2:10/0 = 0 +3:10/0 = 0 +4:10/0 = 0 +5:10/0 = 0 +5:10/0/custom_data_0 = true +5:10/0/custom_data_1 = true +6:10/0 = 0 +7:10/0 = 0 +7:10/0/custom_data_0 = true +7:10/0/custom_data_1 = true +8:10/0 = 0 +9:10/0 = 0 +9:10/0/custom_data_0 = true +9:10/0/custom_data_1 = true +10:10/0 = 0 +11:10/0 = 0 +12:10/0 = 0 +13:10/0 = 0 +14:10/0 = 0 +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 +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 +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 +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 +0:14/0 = 0 +1:14/0 = 0 +2:14/0 = 0 +3:14/0 = 0 +4:14/0 = 0 +5:14/0 = 0 +6:14/0 = 0 +7:14/0 = 0 +8:14/0 = 0 +9:14/0 = 0 +10:14/0 = 0 +11:14/0 = 0 +12:14/0 = 0 +13:14/0 = 0 +14:14/0 = 0 +15:14/0 = 0 +16:14/0 = 0 +17:14/0 = 0 +18:14/0 = 0 +19:14/0 = 0 +20:14/0 = 0 +21:14/0 = 0 +22:14/0 = 0 +23:14/0 = 0 +24:14/0 = 0 +25:14/0 = 0 +26:14/0 = 0 +0:15/0 = 0 +1:15/0 = 0 +2:15/0 = 0 +3:15/0 = 0 +4:15/0 = 0 +5:15/0 = 0 +6:15/0 = 0 +7:15/0 = 0 +8:15/0 = 0 +9:15/0 = 0 +10:15/0 = 0 +11:15/0 = 0 +12:15/0 = 0 +13:15/0 = 0 +14:15/0 = 0 +15:15/0 = 0 +16:15/0 = 0 +17:15/0 = 0 +18:15/0 = 0 +19:15/0 = 0 +20:15/0 = 0 +21:15/0 = 0 +22:15/0 = 0 +23:15/0 = 0 +24:15/0 = 0 +25:15/0 = 0 +26:15/0 = 0 +0:16/0 = 0 +1:16/0 = 0 +2:16/0 = 0 +3:16/0 = 0 +4:16/0 = 0 +5:16/0 = 0 +6:16/0 = 0 +7:16/0 = 0 +8:16/0 = 0 +9:16/0 = 0 +10:16/0 = 0 +11:16/0 = 0 +12:16/0 = 0 +13:16/0 = 0 +14:16/0 = 0 +15:16/0 = 0 +16:16/0 = 0 +17:16/0 = 0 +18:16/0 = 0 +19:16/0 = 0 +20:16/0 = 0 +21:16/0 = 0 +22:16/0 = 0 +23:16/0 = 0 +24:16/0 = 0 +25:16/0 = 0 +26:16/0 = 0 +0:17/0 = 0 +1:17/0 = 0 +2:17/0 = 0 +3:17/0 = 0 +4:17/0 = 0 +5:17/0 = 0 +6:17/0 = 0 +7:17/0 = 0 +8:17/0 = 0 +9:17/0 = 0 +10:17/0 = 0 +11:17/0 = 0 +12:17/0 = 0 +13:17/0 = 0 +14:17/0 = 0 +15:17/0 = 0 +16:17/0 = 0 +17:17/0 = 0 +18:17/0 = 0 +19:17/0 = 0 +20:17/0 = 0 +21:17/0 = 0 +22:17/0 = 0 +23:17/0 = 0 +24:17/0 = 0 +25:17/0 = 0 +26:17/0 = 0 + +[sub_resource type="TileSetScenesCollectionSource" id="TileSetScenesCollectionSource_t8dt2"] +scenes/1/scene = ExtResource("2_oi0ah") + +[resource] +custom_data_layer_0/name = "is_solid" +custom_data_layer_0/type = 1 +custom_data_layer_1/name = "is_interact" +custom_data_layer_1/type = 1 +sources/0 = SubResource("TileSetAtlasSource_om8rr") +sources/3 = SubResource("TileSetScenesCollectionSource_t8dt2") diff --git a/Tilemaps/Tiles/tile_0274.png b/Tilemaps/Tiles/tile_0274.png new file mode 100644 index 0000000..11d03cd Binary files /dev/null and b/Tilemaps/Tiles/tile_0274.png differ diff --git a/Tilemaps/Tiles/tile_0274.png.import b/Tilemaps/Tiles/tile_0274.png.import new file mode 100644 index 0000000..dff002a --- /dev/null +++ b/Tilemaps/Tiles/tile_0274.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b4nga0rwqktws" +path="res://.godot/imported/tile_0274.png-fbdee6c88f68e1b99b9627bf95f2fb99.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Tilemaps/Tiles/tile_0274.png" +dest_files=["res://.godot/imported/tile_0274.png-fbdee6c88f68e1b99b9627bf95f2fb99.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/project.godot b/project.godot index 7c5c482..4c85bdb 100644 --- a/project.godot +++ b/project.godot @@ -11,6 +11,7 @@ config_version=5 [application] config/name="Chaos Kitchen" +run/main_scene="res://Scene/TestScene.tscn" config/features=PackedStringArray("4.2", "Forward Plus") config/icon="res://icon.svg" @@ -18,3 +19,11 @@ config/icon="res://icon.svg" version_control/plugin_name="GitPlugin" version_control/autoload_on_startup=true + +[input] + +move_to={ +"deadzone": 0.5, +"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(160, 17),"global_position":Vector2(164, 58),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null) +] +}