diff --git a/data/character/character.gd b/data/character/character.gd index eb42d23..53de424 100644 --- a/data/character/character.gd +++ b/data/character/character.gd @@ -14,8 +14,17 @@ var status = { "health": 100, "stamina": 100 } +var current_tool = "none" +func change_tool(tool): + current_tool = tool + $body_pivot/body/tool.texture = load(game_data.tools[tool].image) + $body_pivot/body/tool.position = game_data.tools[tool].offset + +func _ready(): + change_tool("stick") + func _physics_process(delta): var pre_velocity = Vector2(0, 0) if !immobile: diff --git a/data/character/character.tscn b/data/character/character.tscn index 427c6cd..ff756df 100644 --- a/data/character/character.tscn +++ b/data/character/character.tscn @@ -2,7 +2,7 @@ [ext_resource type="Texture2D" uid="uid://gfxfxkfu8uk4" path="res://textures/character/character.svg" id="1_f7cgp"] [ext_resource type="Script" path="res://data/character/character.gd" id="1_qlitf"] -[ext_resource type="Texture2D" uid="uid://b7hh5vuwdmg0v" path="res://textures/tools/stick.svg" id="3_1h5n2"] +[ext_resource type="Texture2D" uid="uid://crw5j541ciab8" path="res://textures/tools/none.svg" id="3_c34pt"] [ext_resource type="Script" path="res://data/character/hud.gd" id="3_eogh2"] [ext_resource type="Texture2D" uid="uid://ttb1b3k07qu5" path="res://textures/world/boulder.svg" id="4_t4sgq"] [ext_resource type="Texture2D" uid="uid://i7fjjduk8b0c" path="res://textures/world/biome/forest/tree.svg" id="5_j15j3"] @@ -78,7 +78,7 @@ texture = ExtResource("1_f7cgp") [node name="tool" type="Sprite2D" parent="body_pivot/body"] z_index = -1 position = Vector2(-80, -120) -texture = ExtResource("3_1h5n2") +texture = ExtResource("3_c34pt") [node name="hud" type="Control" parent="."] z_index = 10 diff --git a/project.godot b/project.godot index e22091b..41a7d39 100644 --- a/project.godot +++ b/project.godot @@ -15,6 +15,10 @@ run/main_scene="res://scenes/world.tscn" config/features=PackedStringArray("4.1", "GL Compatibility") config/icon="res://icon.svg" +[autoload] + +game_data="*res://script/game_data.gd" + [display] window/stretch/aspect="expand" diff --git a/script/game_data.gd b/script/game_data.gd new file mode 100644 index 0000000..f6c7d69 --- /dev/null +++ b/script/game_data.gd @@ -0,0 +1,13 @@ +extends Node + + +var tools = { + "none": { + "image": "res://textures/tools/none.svg", + "offset": Vector2(0, 0) + }, + "stick": { + "image": "res://textures/tools/stick.svg", + "offset": Vector2(-80, -120) + } +} diff --git a/textures/tools/none.svg b/textures/tools/none.svg new file mode 100644 index 0000000..6e62965 --- /dev/null +++ b/textures/tools/none.svg @@ -0,0 +1,55 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/textures/tools/none.svg.import b/textures/tools/none.svg.import new file mode 100644 index 0000000..af0eb89 --- /dev/null +++ b/textures/tools/none.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://crw5j541ciab8" +path="res://.godot/imported/none.svg-d6acfffb4a4bec01aae97ce1add71e20.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://textures/tools/none.svg" +dest_files=["res://.godot/imported/none.svg-d6acfffb4a4bec01aae97ce1add71e20.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 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false