diff --git a/assets/sprites/scraps_09.png b/assets/sprites/scraps_09.png new file mode 100755 index 0000000..d1d53c5 Binary files /dev/null and b/assets/sprites/scraps_09.png differ diff --git a/assets/sprites/scraps_09.png.import b/assets/sprites/scraps_09.png.import new file mode 100644 index 0000000..d9ae5dc --- /dev/null +++ b/assets/sprites/scraps_09.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dxni3dw1x4lrl" +path="res://.godot/imported/scraps_09.png-83f98d86ccb89d700aeea74833a44455.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/sprites/scraps_09.png" +dest_files=["res://.godot/imported/scraps_09.png-83f98d86ccb89d700aeea74833a44455.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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/autoloads/audio_manager.gd b/autoloads/audio_manager.gd index 20b3116..1e9dd56 100644 --- a/autoloads/audio_manager.gd +++ b/autoloads/audio_manager.gd @@ -4,6 +4,7 @@ var music_player : AudioStreamPlayer var sfx_player : AudioStreamPlayer const AMBIANCE_VOLUME_DB := -12.0 +const SFX_VOLUME_DB := -8.0 const AMBIANCES := { "entrepot": preload("res://assets/audio/music/entrepot.ogg"), @@ -31,6 +32,7 @@ func _ready() -> void: sfx_player = AudioStreamPlayer.new() sfx_player.name = "SfxPlayer" sfx_player.bus = "SFX" + sfx_player.volume_db = SFX_VOLUME_DB add_child(sfx_player) sfx_player.process_mode = Node.PROCESS_MODE_ALWAYS diff --git a/entities/player/player.gd b/entities/player/player.gd index 66aecb1..c770869 100644 --- a/entities/player/player.gd +++ b/entities/player/player.gd @@ -1,6 +1,6 @@ extends CharacterBody2D -const SPEED := 120 +const SPEED := 64 const TILE_SIZE := 16 @onready var sprite := $AnimatedSprite2D diff --git a/entities/player/player.tscn b/entities/player/player.tscn index ac3658f..de672fb 100644 --- a/entities/player/player.tscn +++ b/entities/player/player.tscn @@ -1,281 +1,178 @@ [gd_scene format=3 uid="uid://mh3msmluve7p"] [ext_resource type="Script" uid="uid://tuwu6hmfun0e" path="res://entities/player/player.gd" id="1_fkugw"] -[ext_resource type="Texture2D" uid="uid://dhmrfo4dfhbww" path="res://tests/assets/sprites/player_001/IDLE/idle_down.png" id="2_bectd"] -[ext_resource type="Texture2D" uid="uid://byy4h3q72guaj" path="res://tests/assets/sprites/player_001/IDLE/idle_left.png" id="3_wvtmh"] -[ext_resource type="Texture2D" uid="uid://bsdcjceiotf2y" path="res://tests/assets/sprites/player_001/IDLE/idle_right.png" id="4_7thud"] -[ext_resource type="Texture2D" uid="uid://3q718xogyij0" path="res://tests/assets/sprites/player_001/IDLE/idle_up.png" id="5_a1qjk"] -[ext_resource type="Texture2D" uid="uid://bx3l0csay8b8b" path="res://tests/assets/sprites/player_001/RUN/run_down.png" id="6_j3ovn"] -[ext_resource type="Texture2D" uid="uid://ctx7kmb6730oe" path="res://tests/assets/sprites/player_001/RUN/run_left.png" id="7_afbqv"] -[ext_resource type="Texture2D" uid="uid://saic6hvcajw0" path="res://tests/assets/sprites/player_001/RUN/run_right.png" id="8_gx6sm"] -[ext_resource type="Texture2D" uid="uid://dmijbmqm1ysft" path="res://tests/assets/sprites/player_001/RUN/run_up.png" id="9_yqrof"] +[ext_resource type="Texture2D" uid="uid://dxni3dw1x4lrl" path="res://assets/sprites/scraps_09.png" id="2_bectd"] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_26q78"] -radius = 6.0 -height = 12.0 +radius = 7.0 +height = 14.0 + +[sub_resource type="AtlasTexture" id="AtlasTexture_wvtmh"] +atlas = ExtResource("2_bectd") +region = Rect2(0, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_abrql"] +atlas = ExtResource("2_bectd") +region = Rect2(0, 192, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_sglur"] +atlas = ExtResource("2_bectd") +region = Rect2(0, 128, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_bls4j"] +atlas = ExtResource("2_bectd") +region = Rect2(0, 64, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_fkugw"] +atlas = ExtResource("2_bectd") +region = Rect2(0, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_8fjmc"] +atlas = ExtResource("2_bectd") +region = Rect2(64, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_qiwj3"] +atlas = ExtResource("2_bectd") +region = Rect2(128, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_26q78"] +atlas = ExtResource("2_bectd") +region = Rect2(192, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_bectd"] +atlas = ExtResource("2_bectd") +region = Rect2(0, 192, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_7thud"] +atlas = ExtResource("2_bectd") +region = Rect2(64, 192, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_a1qjk"] +atlas = ExtResource("2_bectd") +region = Rect2(128, 192, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_j3ovn"] +atlas = ExtResource("2_bectd") +region = Rect2(192, 192, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_afbqv"] +atlas = ExtResource("2_bectd") +region = Rect2(0, 128, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_gx6sm"] +atlas = ExtResource("2_bectd") +region = Rect2(64, 128, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_yqrof"] +atlas = ExtResource("2_bectd") +region = Rect2(128, 128, 64, 64) [sub_resource type="AtlasTexture" id="AtlasTexture_3wlsy"] atlas = ExtResource("2_bectd") -region = Rect2(0, 0, 96, 80) +region = Rect2(192, 128, 64, 64) [sub_resource type="AtlasTexture" id="AtlasTexture_b2kln"] atlas = ExtResource("2_bectd") -region = Rect2(96, 0, 96, 80) +region = Rect2(0, 64, 64, 64) [sub_resource type="AtlasTexture" id="AtlasTexture_we0b7"] atlas = ExtResource("2_bectd") -region = Rect2(192, 0, 96, 80) +region = Rect2(64, 64, 64, 64) [sub_resource type="AtlasTexture" id="AtlasTexture_mtric"] atlas = ExtResource("2_bectd") -region = Rect2(288, 0, 96, 80) +region = Rect2(128, 64, 64, 64) [sub_resource type="AtlasTexture" id="AtlasTexture_eyb6c"] atlas = ExtResource("2_bectd") -region = Rect2(384, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_221hk"] -atlas = ExtResource("2_bectd") -region = Rect2(480, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_ghoj8"] -atlas = ExtResource("2_bectd") -region = Rect2(576, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_t1t22"] -atlas = ExtResource("2_bectd") -region = Rect2(672, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_50fht"] -atlas = ExtResource("3_wvtmh") -region = Rect2(0, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_wuv6x"] -atlas = ExtResource("3_wvtmh") -region = Rect2(96, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_qpopc"] -atlas = ExtResource("3_wvtmh") -region = Rect2(192, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_wq0jh"] -atlas = ExtResource("3_wvtmh") -region = Rect2(288, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_gt4e4"] -atlas = ExtResource("3_wvtmh") -region = Rect2(384, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_24ehl"] -atlas = ExtResource("3_wvtmh") -region = Rect2(480, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_bwdx1"] -atlas = ExtResource("3_wvtmh") -region = Rect2(576, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_vewsg"] -atlas = ExtResource("3_wvtmh") -region = Rect2(672, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_2soq1"] -atlas = ExtResource("4_7thud") -region = Rect2(0, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_8q4fm"] -atlas = ExtResource("4_7thud") -region = Rect2(96, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_np63p"] -atlas = ExtResource("4_7thud") -region = Rect2(192, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_0eo6o"] -atlas = ExtResource("4_7thud") -region = Rect2(288, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_ttr27"] -atlas = ExtResource("4_7thud") -region = Rect2(384, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_13wue"] -atlas = ExtResource("4_7thud") -region = Rect2(480, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_wy7bt"] -atlas = ExtResource("4_7thud") -region = Rect2(576, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_geky7"] -atlas = ExtResource("4_7thud") -region = Rect2(672, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_qwspa"] -atlas = ExtResource("5_a1qjk") -region = Rect2(0, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_r633c"] -atlas = ExtResource("5_a1qjk") -region = Rect2(96, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_pacje"] -atlas = ExtResource("5_a1qjk") -region = Rect2(192, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_2h0qb"] -atlas = ExtResource("5_a1qjk") -region = Rect2(288, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_mmk7k"] -atlas = ExtResource("5_a1qjk") -region = Rect2(384, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_g3pa7"] -atlas = ExtResource("5_a1qjk") -region = Rect2(480, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_7otdo"] -atlas = ExtResource("5_a1qjk") -region = Rect2(576, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_c112w"] -atlas = ExtResource("5_a1qjk") -region = Rect2(672, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_u37te"] -atlas = ExtResource("6_j3ovn") -region = Rect2(0, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_ssgi7"] -atlas = ExtResource("6_j3ovn") -region = Rect2(96, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_rtlkk"] -atlas = ExtResource("6_j3ovn") -region = Rect2(192, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_a2brg"] -atlas = ExtResource("6_j3ovn") -region = Rect2(288, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_arp52"] -atlas = ExtResource("6_j3ovn") -region = Rect2(384, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_jjk8f"] -atlas = ExtResource("6_j3ovn") -region = Rect2(480, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_cnswy"] -atlas = ExtResource("6_j3ovn") -region = Rect2(576, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_q5bfg"] -atlas = ExtResource("6_j3ovn") -region = Rect2(672, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_p22ii"] -atlas = ExtResource("7_afbqv") -region = Rect2(0, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_7rgwd"] -atlas = ExtResource("7_afbqv") -region = Rect2(96, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_24so6"] -atlas = ExtResource("7_afbqv") -region = Rect2(192, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_sk710"] -atlas = ExtResource("7_afbqv") -region = Rect2(288, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_kbbq5"] -atlas = ExtResource("7_afbqv") -region = Rect2(384, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_akixf"] -atlas = ExtResource("7_afbqv") -region = Rect2(480, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_3y563"] -atlas = ExtResource("7_afbqv") -region = Rect2(576, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_sgfia"] -atlas = ExtResource("7_afbqv") -region = Rect2(672, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_sv458"] -atlas = ExtResource("8_gx6sm") -region = Rect2(0, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_pth52"] -atlas = ExtResource("8_gx6sm") -region = Rect2(96, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_4iu2e"] -atlas = ExtResource("8_gx6sm") -region = Rect2(192, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_0q7bw"] -atlas = ExtResource("8_gx6sm") -region = Rect2(288, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_qb5t2"] -atlas = ExtResource("8_gx6sm") -region = Rect2(384, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_qsjf6"] -atlas = ExtResource("8_gx6sm") -region = Rect2(480, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_k3n4f"] -atlas = ExtResource("8_gx6sm") -region = Rect2(576, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_gmffv"] -atlas = ExtResource("8_gx6sm") -region = Rect2(672, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_rqau1"] -atlas = ExtResource("9_yqrof") -region = Rect2(0, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_gv6fn"] -atlas = ExtResource("9_yqrof") -region = Rect2(96, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_2vqvu"] -atlas = ExtResource("9_yqrof") -region = Rect2(192, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_yb4xh"] -atlas = ExtResource("9_yqrof") -region = Rect2(288, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_ix1gt"] -atlas = ExtResource("9_yqrof") -region = Rect2(384, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_sym6v"] -atlas = ExtResource("9_yqrof") -region = Rect2(480, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_dnai7"] -atlas = ExtResource("9_yqrof") -region = Rect2(576, 0, 96, 80) - -[sub_resource type="AtlasTexture" id="AtlasTexture_u8til"] -atlas = ExtResource("9_yqrof") -region = Rect2(672, 0, 96, 80) +region = Rect2(192, 64, 64, 64) [sub_resource type="SpriteFrames" id="SpriteFrames_ix1gt"] animations = [{ "frames": [{ "duration": 1.0, -"texture": SubResource("AtlasTexture_3wlsy") +"texture": SubResource("AtlasTexture_wvtmh") +}], +"loop": true, +"name": &"idle_down", +"speed": 10.0 }, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_abrql") +}], +"loop": true, +"name": &"idle_left", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_sglur") +}], +"loop": true, +"name": &"idle_right", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_bls4j") +}], +"loop": true, +"name": &"idle_up", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_fkugw") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_8fjmc") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_qiwj3") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_26q78") +}], +"loop": true, +"name": &"walk_down", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_bectd") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_7thud") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_a1qjk") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_j3ovn") +}], +"loop": true, +"name": &"walk_left", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_afbqv") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_gx6sm") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_yqrof") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_3wlsy") +}], +"loop": true, +"name": &"walk_right", +"speed": 10.0 +}, { +"frames": [{ "duration": 1.0, "texture": SubResource("AtlasTexture_b2kln") }, { @@ -287,218 +184,6 @@ animations = [{ }, { "duration": 1.0, "texture": SubResource("AtlasTexture_eyb6c") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_221hk") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_ghoj8") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_t1t22") -}], -"loop": true, -"name": &"idle_down", -"speed": 10.0 -}, { -"frames": [{ -"duration": 1.0, -"texture": SubResource("AtlasTexture_50fht") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_wuv6x") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_qpopc") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_wq0jh") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_gt4e4") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_24ehl") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_bwdx1") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_vewsg") -}], -"loop": true, -"name": &"idle_left", -"speed": 10.0 -}, { -"frames": [{ -"duration": 1.0, -"texture": SubResource("AtlasTexture_2soq1") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_8q4fm") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_np63p") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_0eo6o") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_ttr27") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_13wue") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_wy7bt") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_geky7") -}], -"loop": true, -"name": &"idle_right", -"speed": 10.0 -}, { -"frames": [{ -"duration": 1.0, -"texture": SubResource("AtlasTexture_qwspa") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_r633c") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_pacje") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_2h0qb") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_mmk7k") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_g3pa7") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_7otdo") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_c112w") -}], -"loop": true, -"name": &"idle_up", -"speed": 10.0 -}, { -"frames": [{ -"duration": 1.0, -"texture": SubResource("AtlasTexture_u37te") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_ssgi7") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_rtlkk") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_a2brg") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_arp52") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_jjk8f") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_cnswy") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_q5bfg") -}], -"loop": true, -"name": &"walk_down", -"speed": 10.0 -}, { -"frames": [{ -"duration": 1.0, -"texture": SubResource("AtlasTexture_p22ii") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_7rgwd") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_24so6") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_sk710") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_kbbq5") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_akixf") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_3y563") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_sgfia") -}], -"loop": true, -"name": &"walk_left", -"speed": 10.0 -}, { -"frames": [{ -"duration": 1.0, -"texture": SubResource("AtlasTexture_sv458") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_pth52") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_4iu2e") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_0q7bw") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_qb5t2") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_qsjf6") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_k3n4f") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_gmffv") -}], -"loop": true, -"name": &"walk_right", -"speed": 10.0 -}, { -"frames": [{ -"duration": 1.0, -"texture": SubResource("AtlasTexture_rqau1") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_gv6fn") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_2vqvu") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_yb4xh") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_ix1gt") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_sym6v") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_dnai7") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_u8til") }], "loop": true, "name": &"walk_up", @@ -506,7 +191,7 @@ animations = [{ }] [sub_resource type="RectangleShape2D" id="RectangleShape2D_bectd"] -size = Vector2(45.375, 42.84375) +size = Vector2(65.84375, 66.25) [node name="Player" type="CharacterBody2D" unique_id=1424887591] collision_layer = 2 @@ -521,10 +206,11 @@ zoom = Vector2(0.75, 0.75) position_smoothing_enabled = true [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." unique_id=1926532622] -position = Vector2(-1, -8) +position = Vector2(0, -13) sprite_frames = SubResource("SpriteFrames_ix1gt") -animation = &"walk_right" +animation = &"walk_down" autoplay = "idle_down" +frame_progress = 0.9045258 [node name="InteractionArea" type="Area2D" parent="." unique_id=1623204784] position = Vector2(-1, -12) @@ -532,7 +218,7 @@ collision_layer = 16 collision_mask = 28 [node name="CollisionShape2D" type="CollisionShape2D" parent="InteractionArea" unique_id=446150610] -position = Vector2(1, 9) +position = Vector2(1, -2) shape = SubResource("RectangleShape2D_bectd") debug_color = Color(0.9411765, 0, 0.29411766, 0.19607843) diff --git a/ui/minigame/repair_minigame.gd b/ui/minigame/repair_minigame.gd index 9b3f62d..3ed0fcc 100644 --- a/ui/minigame/repair_minigame.gd +++ b/ui/minigame/repair_minigame.gd @@ -6,147 +6,152 @@ signal repair_complete const PUZZLES := { "vrac7": { "title": "RECONNECTION — MOTOR SYSTEM", - "connections": [[0, 0], [1, 2], [3, 3]] + "colors": [Color("#f4c430"), Color("#5bc8f5"), Color("#f47c3c")] }, "iris3": { "title": "RECALIBRATION — OPTICAL SENSOR", - "connections": [[0, 1], [2, 3]] + "colors": [Color("#f4c430"), Color("#5bc8f5")] }, - "scrap09": { + "scrap09": { "title": "SELF-REPAIR — SCRAP-09", - "connections": [[0, 0], [1, 2], [2, 3]] + "colors": [Color("#f4c430"), Color("#5bc8f5"), Color("#f47c3c")] }, } -const GRID_SIZE := 4 +const DOT_RADIUS := 8.0 +const WIRE_WIDTH := 4.0 -var current_puzzle: Dictionary -var paths: Array = [] -var active_path: int = -1 -var solved_paths: Array = [] +var current_puzzle : Dictionary +var right_order : Array = [] +var connections : Dictionary = {} +var dragging : int = -1 +var drag_pos : Vector2 -@onready var grid := $Background/Panel/VBoxContainer/Grid -@onready var title_lbl := $Background/Panel/VBoxContainer/Title -@onready var status := $Background/Panel/VBoxContainer/StatusLabel +@onready var wire_canvas : Control = $Background/Panel/VBoxContainer/WireCanvas +@onready var title_lbl : Label = $Background/Panel/VBoxContainer/Title +@onready var status : Label = $Background/Panel/VBoxContainer/StatusLabel -# ── Lifecycle ───────────────────────────────────────────────────────────────── func _ready() -> void: + var vbox = $Background/Panel/VBoxContainer layer = 1000 - - var panel := $Background/Panel - panel.set_anchors_preset(Control.PRESET_CENTER) - - var vbox := $Background/Panel/VBoxContainer - vbox.alignment = BoxContainer.ALIGNMENT_CENTER - vbox.add_theme_constant_override("separation", 12) - - # Centre la grid horizontalement dans le VBox - grid.size_flags_horizontal = Control.SIZE_SHRINK_CENTER - grid.size_flags_vertical = Control.SIZE_SHRINK_CENTER + wire_canvas.custom_minimum_size = Vector2(320, 120) + wire_canvas.size_flags_vertical = Control.SIZE_SHRINK_CENTER + vbox.size_flags_vertical = Control.SIZE_SHRINK_CENTER func _unhandled_input(event: InputEvent) -> void: if event.is_action_pressed("ui_cancel"): _cancel() -# ── API publique ────────────────────────────────────────────────────────────── - func open(robot_id: String) -> void: - current_puzzle = PUZZLES[robot_id] - title_lbl.text = current_puzzle["title"] - paths.clear() - solved_paths.clear() - for _c in current_puzzle["connections"]: - paths.append([]) - solved_paths.append(false) + current_puzzle = PUZZLES.get(robot_id, {}) + if current_puzzle.is_empty(): + return + title_lbl.text = current_puzzle["title"] as String + connections.clear() + dragging = -1 + + var n: int = (current_puzzle["colors"] as Array).size() # ← FIX ligne 49 + right_order = range(n) + right_order.shuffle() + _set_hud_visible(false) _set_player_enabled(false) - _build_grid() _update_status() + wire_canvas.queue_redraw() show() -# ── Grille ──────────────────────────────────────────────────────────────────── +# ── Drawing ──────────────────────────────────────────────────────────────────── -func _build_grid() -> void: - for child in grid.get_children(): - child.queue_free() - - # Taille fixe de la grille : GRID_SIZE * taille bouton + séparation - var cell_size := 25 - var separation := 4 - var grid_px := GRID_SIZE * cell_size + (GRID_SIZE - 1) * separation - grid.custom_minimum_size = Vector2(grid_px, grid_px) - grid.columns = GRID_SIZE - - for row in GRID_SIZE: - for col in GRID_SIZE: - var btn := Button.new() - btn.custom_minimum_size = Vector2(cell_size, cell_size) - btn.name = "Cell_%d_%d" % [row, col] - btn.add_theme_stylebox_override("normal", _make_stylebox(Color(0.15, 0.15, 0.15), 1.0)) - btn.add_theme_stylebox_override("hover", _make_stylebox(Color(0.25, 0.25, 0.25), 1.0)) - - if col == 0: - var path_idx = _entry_for_row(row) - if path_idx >= 0: - btn.text = "0" - btn.modulate = _color_for_path(path_idx) - elif col == 3: - var path_idx = _exit_for_row(row) - if path_idx >= 0: - btn.text = "X" - btn.modulate = _color_for_path(path_idx) - - btn.pressed.connect(_on_cell_pressed.bind(row, col)) - grid.add_child(btn) - -func _on_cell_pressed(row: int, col: int) -> void: - var entry_idx = _entry_for_row(row) - if col == 0 and entry_idx >= 0: - active_path = entry_idx - paths[active_path] = [Vector2i(row, col)] - _refresh_grid() +func draw_wires(canvas: Control) -> void: + if current_puzzle.is_empty(): return + var colors := current_puzzle["colors"] as Array + var n: int = colors.size() + var w := canvas.size.x + var h := canvas.size.y - if active_path < 0: + canvas.draw_line(Vector2(w * 0.5, 10), Vector2(w * 0.5, h - 10), + Color(1, 1, 1, 0.08), 1.0) + + for left_idx in connections: + var right_slot: int = connections[left_idx] + var from := _left_pos(left_idx, n, w, h) + var to := _right_pos(right_slot, n, w, h) + canvas.draw_line(from, to, colors[left_idx], WIRE_WIDTH, true) + + if dragging >= 0: + var from := _left_pos(dragging, n, w, h) + canvas.draw_line(from, drag_pos, (colors[dragging] as Color).lightened(0.3), WIRE_WIDTH, true) + + for i in n: + var pos := _left_pos(i, n, w, h) + var c := colors[i] as Color + canvas.draw_circle(pos, DOT_RADIUS, c) + if not connections.has(i): + canvas.draw_arc(pos, DOT_RADIUS + 4, 0, TAU, 32, c.lightened(0.5), 2.0) + + for i in n: + var pos := _right_pos(i, n, w, h) + var col_idx : int = right_order[i] + var c := colors[col_idx] as Color + canvas.draw_circle(pos, DOT_RADIUS, c) + if not connections.values().has(i): + canvas.draw_arc(pos, DOT_RADIUS + 4, 0, TAU, 32, c.lightened(0.5), 2.0) + +# ── Input ───────────────────────────────────────────────────────────────────── + +func on_canvas_input(event: InputEvent) -> void: + if current_puzzle.is_empty(): return + var colors := current_puzzle["colors"] as Array + var n: int = colors.size() + var w := wire_canvas.size.x + var h := wire_canvas.size.y - var last: Vector2i = paths[active_path].back() if paths[active_path].size() > 0 else Vector2i(-1, -1) - var cell := Vector2i(row, col) + if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT: + if event.pressed: + for i in n: + if event.position.distance_to(_left_pos(i, n, w, h)) <= DOT_RADIUS + 6.0: + connections.erase(i) + dragging = i + drag_pos = event.position + _update_status() + wire_canvas.queue_redraw() + return + else: + if dragging >= 0: + for i in n: + if connections.values().has(i): + continue + if event.position.distance_to(_right_pos(i, n, w, h)) <= DOT_RADIUS + 6.0: + if right_order[i] == dragging: + connections[dragging] = i + _update_status() + _check_win() + dragging = -1 + wire_canvas.queue_redraw() - if not _is_adjacent(last, cell): - return + elif event is InputEventMouseMotion and dragging >= 0: + drag_pos = event.position + wire_canvas.queue_redraw() - for i in paths.size(): - if i == active_path: - continue - if cell in paths[i]: - return +# ── Helpers ─────────────────────────────────────────────────────────────────── - paths[active_path].append(cell) +func _left_pos(i: int, n: int, w: float, h: float) -> Vector2: + return Vector2(DOT_RADIUS + 20.0, h / (n + 1) * (i + 1)) - var exit_row = current_puzzle["connections"][active_path][1] - if col == 3 and row == exit_row: - solved_paths[active_path] = true - active_path = -1 - _refresh_grid() - _update_status() - _check_win() - return - - _refresh_grid() - _update_status() - -# ── Victoire / Annulation ───────────────────────────────────────────────────── +func _right_pos(i: int, n: int, w: float, h: float) -> Vector2: + return Vector2(w - DOT_RADIUS - 20.0, h / (n + 1) * (i + 1)) func _check_win() -> void: - if solved_paths.all(func(s): return s == true): + if connections.size() == (current_puzzle["colors"] as Array).size(): await get_tree().create_timer(0.6).timeout repair_complete.emit() _close() func _cancel() -> void: - active_path = -1 + dragging = -1 _close() func _close() -> void: @@ -154,89 +159,23 @@ func _close() -> void: _set_player_enabled(true) hide() -# ── Affichage ───────────────────────────────────────────────────────────────── - -func _refresh_grid() -> void: - for row in GRID_SIZE: - for col in GRID_SIZE: - var btn: Button = grid.get_node_or_null("Cell_%d_%d" % [row, col]) - if btn == null: - continue - var cell := Vector2i(row, col) - var found := false - - for i in paths.size(): - if cell in paths[i]: - var c := _color_for_path(i) - var is_endpoint := (col == 0 or col == 3) - btn.text = "O" if is_endpoint else "+" - btn.modulate = Color.WHITE - btn.add_theme_stylebox_override("normal", _make_stylebox(c, 0.5)) - btn.add_theme_color_override("font_color", c) - found = true - break - - if not found: - btn.modulate = Color.WHITE - btn.text = "" - btn.add_theme_stylebox_override("normal", _make_stylebox(Color(0.15, 0.15, 0.15), 1.0)) - btn.remove_theme_color_override("font_color") - var ei = _entry_for_row(row) - var xi = _exit_for_row(row) - if col == 0 and ei >= 0: - btn.text = "O" - btn.add_theme_color_override("font_color", _color_for_path(ei)) - elif col == 3 and xi >= 0: - btn.text = "O" - func _update_status() -> void: - var count := solved_paths.count(true) - var total := solved_paths.size() - if count == total: + var total: int = (current_puzzle.get("colors", []) as Array).size() + var done := connections.size() + if done == total: status.text = "REPAIR COMPLETE" status.add_theme_color_override("font_color", Color("#6daa45")) else: - status.text = "%d / %d connections established" % [count, total] + status.text = "%d / %d connections established" % [done, total] status.remove_theme_color_override("font_color") -# ── Helpers ─────────────────────────────────────────────────────────────────── - -func _set_hud_visible(visible: bool) -> void: +func _set_hud_visible(v: bool) -> void: var hud = get_tree().get_first_node_in_group("hud") if hud: - hud.visible = visible - -func _make_stylebox(color: Color, alpha: float) -> StyleBoxFlat: - var sb := StyleBoxFlat.new() - sb.bg_color = Color(color.r, color.g, color.b, alpha) - sb.corner_radius_top_left = 4 - sb.corner_radius_top_right = 4 - sb.corner_radius_bottom_left = 4 - sb.corner_radius_bottom_right = 4 - return sb - -func _entry_for_row(row: int) -> int: - for i in current_puzzle["connections"].size(): - if current_puzzle["connections"][i][0] == row: - return i - return -1 - -func _exit_for_row(row: int) -> int: - for i in current_puzzle["connections"].size(): - if current_puzzle["connections"][i][1] == row: - return i - return -1 - -func _is_adjacent(a: Vector2i, b: Vector2i) -> bool: - return abs(a.x - b.x) + abs(a.y - b.y) == 1 - -func _color_for_path(idx: int) -> Color: - var colors := [Color("#f4c430"), Color("#5bc8f5"), Color("#f47c3c")] - return colors[idx % colors.size()] + hud.visible = v func _set_player_enabled(enabled: bool) -> void: var player = get_tree().get_first_node_in_group("player") - print("_set_player_enabled: ", enabled, " | player trouvé: ", player) if player: player.set_process(enabled) player.set_physics_process(enabled) diff --git a/ui/minigame/repair_minigame.tscn b/ui/minigame/repair_minigame.tscn index eb811fe..1525a1c 100644 --- a/ui/minigame/repair_minigame.tscn +++ b/ui/minigame/repair_minigame.tscn @@ -1,6 +1,7 @@ [gd_scene format=3 uid="uid://djtxltf8mtuv6"] [ext_resource type="Script" uid="uid://b5237vkobhji0" path="res://ui/minigame/repair_minigame.gd" id="1_151ia"] +[ext_resource type="PackedScene" uid="uid://dchwkw273wjq7" path="res://ui/minigame/wire_canvas.tscn" id="2_sehdy"] [node name="RepairMinigame" type="CanvasLayer" unique_id=189116174] script = ExtResource("1_151ia") @@ -11,18 +12,23 @@ anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 -offset_left = -70.0 -offset_top = -70.0 -offset_right = -70.0 -offset_bottom = -70.0 grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 [node name="Panel" type="PanelContainer" parent="Background" unique_id=1782143434] -layout_mode = 0 -offset_right = 40.0 -offset_bottom = 40.0 +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -150.0 +offset_top = -106.0 +offset_right = 150.0 +offset_bottom = 106.0 +grow_horizontal = 2 +grow_vertical = 2 [node name="VBoxContainer" type="VBoxContainer" parent="Background/Panel" unique_id=937959925] layout_mode = 2 @@ -34,9 +40,11 @@ theme_override_font_sizes/font_size = 8 horizontal_alignment = 1 vertical_alignment = 1 -[node name="Grid" type="GridContainer" parent="Background/Panel/VBoxContainer" unique_id=123587798] +[node name="WireCanvas" parent="Background/Panel/VBoxContainer" unique_id=1594830372 instance=ExtResource("2_sehdy")] +custom_minimum_size = Vector2(300, 180) layout_mode = 2 -columns = 4 +size_flags_horizontal = 4 +size_flags_vertical = 4 [node name="StatusLabel" type="Label" parent="Background/Panel/VBoxContainer" unique_id=1700512059] layout_mode = 2 diff --git a/ui/minigame/wire_canvas.gd b/ui/minigame/wire_canvas.gd new file mode 100644 index 0000000..5f05975 --- /dev/null +++ b/ui/minigame/wire_canvas.gd @@ -0,0 +1,12 @@ +extends Control + +func _ready() -> void: + mouse_filter = MOUSE_FILTER_STOP + +func _draw() -> void: + if owner is RepairMinigame: + owner.draw_wires(self) + +func _gui_input(event: InputEvent) -> void: + if owner is RepairMinigame: + owner.on_canvas_input(event) diff --git a/ui/minigame/wire_canvas.gd.uid b/ui/minigame/wire_canvas.gd.uid new file mode 100644 index 0000000..ac4a178 --- /dev/null +++ b/ui/minigame/wire_canvas.gd.uid @@ -0,0 +1 @@ +uid://dlb7sr4wrfc2h diff --git a/ui/minigame/wire_canvas.tscn b/ui/minigame/wire_canvas.tscn new file mode 100644 index 0000000..71f0051 --- /dev/null +++ b/ui/minigame/wire_canvas.tscn @@ -0,0 +1,8 @@ +[gd_scene format=3 uid="uid://dchwkw273wjq7"] + +[ext_resource type="Script" uid="uid://dlb7sr4wrfc2h" path="res://ui/minigame/wire_canvas.gd" id="1_pcg8e"] + +[node name="WireCanvas" type="Control" unique_id=1594830372] +layout_mode = 3 +anchors_preset = 0 +script = ExtResource("1_pcg8e")