diff --git a/.gitea/workflows/android-debug.yaml b/.gitea/workflows/android-debug.yaml new file mode 100644 index 0000000..94b758f --- /dev/null +++ b/.gitea/workflows/android-debug.yaml @@ -0,0 +1,36 @@ +name: Android Debug APK + +on: + push: + branches: + - main + + workflow_dispatch: + +jobs: + build: + runs-on: godot-android + + steps: + - name: Checkout + uses: builtin:checkout + + - name: Check environment + run: | + echo "=== Godot ===" + godot --version + + echo "=== Java ===" + java -version + + echo "=== Android SDK ===" + sdkmanager --version + + - name: Build APK + run: | + ./scripts/export_android_debug.sh + + - name: Verify APK + run: | + test -f build/android/mortal-maze-debug.apk + ls -lh build/android/mortal-maze-debug.apk diff --git a/assets/ui/mobile_controls/attack.png b/assets/ui/mobile_controls/attack.png new file mode 100755 index 0000000..d4f82f3 Binary files /dev/null and b/assets/ui/mobile_controls/attack.png differ diff --git a/assets/ui/mobile_controls/attack.png.import b/assets/ui/mobile_controls/attack.png.import new file mode 100644 index 0000000..7e49c99 --- /dev/null +++ b/assets/ui/mobile_controls/attack.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://byb0xo2xlcj4f" +path="res://.godot/imported/attack.png-e43acc2a00eb7a48aa8e4db2c6722944.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/ui/mobile_controls/attack.png" +dest_files=["res://.godot/imported/attack.png-e43acc2a00eb7a48aa8e4db2c6722944.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/assets/ui/mobile_controls/left-arrow.png b/assets/ui/mobile_controls/left-arrow.png new file mode 100755 index 0000000..53ae60d Binary files /dev/null and b/assets/ui/mobile_controls/left-arrow.png differ diff --git a/assets/ui/mobile_controls/left-arrow.png.import b/assets/ui/mobile_controls/left-arrow.png.import new file mode 100644 index 0000000..6fca1b2 --- /dev/null +++ b/assets/ui/mobile_controls/left-arrow.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cj6wl2l43nao2" +path="res://.godot/imported/left-arrow.png-df3bc54036c7ce5369dfbc6a55314e31.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/ui/mobile_controls/left-arrow.png" +dest_files=["res://.godot/imported/left-arrow.png-df3bc54036c7ce5369dfbc6a55314e31.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/assets/ui/mobile_controls/right-arrow.png b/assets/ui/mobile_controls/right-arrow.png new file mode 100755 index 0000000..88ae6ba Binary files /dev/null and b/assets/ui/mobile_controls/right-arrow.png differ diff --git a/assets/ui/mobile_controls/right-arrow.png.import b/assets/ui/mobile_controls/right-arrow.png.import new file mode 100644 index 0000000..53627e8 --- /dev/null +++ b/assets/ui/mobile_controls/right-arrow.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://y0tsuhk4moj3" +path="res://.godot/imported/right-arrow.png-ca6c60c3a56ad3496fb01c50c4addf77.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/ui/mobile_controls/right-arrow.png" +dest_files=["res://.godot/imported/right-arrow.png-ca6c60c3a56ad3496fb01c50c4addf77.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/assets/ui/mobile_controls/top-arrow.png b/assets/ui/mobile_controls/top-arrow.png new file mode 100755 index 0000000..1acec9e Binary files /dev/null and b/assets/ui/mobile_controls/top-arrow.png differ diff --git a/assets/ui/mobile_controls/top-arrow.png.import b/assets/ui/mobile_controls/top-arrow.png.import new file mode 100644 index 0000000..74b15d4 --- /dev/null +++ b/assets/ui/mobile_controls/top-arrow.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b832qiumqbdwc" +path="res://.godot/imported/top-arrow.png-9c88b2442b3e25841f7a8ae0923e7ca3.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/ui/mobile_controls/top-arrow.png" +dest_files=["res://.godot/imported/top-arrow.png-9c88b2442b3e25841f7a8ae0923e7ca3.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/ui/mobile_controls/mobile_controls.gd b/ui/mobile_controls/mobile_controls.gd index 715f4c7..f783b4c 100644 --- a/ui/mobile_controls/mobile_controls.gd +++ b/ui/mobile_controls/mobile_controls.gd @@ -19,14 +19,32 @@ extends CanvasLayer @onready var jump_button: Button = $Controls/Jump @onready var attack_button: Button = $Controls/Attack +var direction_touch_index: int = -1 + func _ready() -> void: - _bind_button(move_left_button, &"move_left") - _bind_button(move_right_button, &"move_right") _bind_button(jump_button, &"jump") _bind_button(attack_button, &"attack") +func _input(event: InputEvent) -> void: + if event is InputEventScreenTouch: + var touch := event as InputEventScreenTouch + if touch.pressed and direction_touch_index == -1: + var action := _direction_at(touch.position) + if action != &"": + direction_touch_index = touch.index + _press_direction(action) + elif not touch.pressed and touch.index == direction_touch_index: + _release_direction() + elif event is InputEventScreenDrag: + var drag := event as InputEventScreenDrag + if drag.index == direction_touch_index: + var action := _direction_at(drag.position) + if action != &"": + _press_direction(action) + + func _exit_tree() -> void: # Si la escena cambia mientras un dedo sigue apoyado, Godot puede no llegar # a emitir button_up. Liberamos las acciones para no dejar una tecla virtual @@ -37,6 +55,26 @@ func _exit_tree() -> void: Input.action_release(&"attack") +func _direction_at(position: Vector2) -> StringName: + if move_left_button.get_global_rect().has_point(position): + return &"move_left" + if move_right_button.get_global_rect().has_point(position): + return &"move_right" + return &"" + + +func _press_direction(action: StringName) -> void: + var other_action: StringName = &"move_right" if action == &"move_left" else &"move_left" + Input.action_release(other_action) + Input.action_press(action) + + +func _release_direction() -> void: + Input.action_release(&"move_left") + Input.action_release(&"move_right") + direction_touch_index = -1 + + func _bind_button(button: Button, action: StringName) -> void: button.button_down.connect(_press_action.bind(action)) button.button_up.connect(_release_action.bind(action)) diff --git a/ui/mobile_controls/mobile_controls.tscn b/ui/mobile_controls/mobile_controls.tscn index eafb917..84794ba 100644 --- a/ui/mobile_controls/mobile_controls.tscn +++ b/ui/mobile_controls/mobile_controls.tscn @@ -1,6 +1,10 @@ -[gd_scene load_steps=4 format=3] +[gd_scene load_steps=8 format=3] [ext_resource type="Script" path="res://ui/mobile_controls/mobile_controls.gd" id="1_controls"] +[ext_resource type="Texture2D" path="res://assets/ui/mobile_controls/left-arrow.png" id="2_left"] +[ext_resource type="Texture2D" path="res://assets/ui/mobile_controls/right-arrow.png" id="3_right"] +[ext_resource type="Texture2D" path="res://assets/ui/mobile_controls/top-arrow.png" id="4_jump"] +[ext_resource type="Texture2D" path="res://assets/ui/mobile_controls/attack.png" id="5_attack"] [sub_resource type="StyleBoxFlat" id="ButtonNormal"] bg_color = Color(0.65, 0.04, 0.04, 0.28) @@ -56,7 +60,9 @@ theme_override_font_sizes/font_size = 42 theme_override_styles/normal = SubResource("ButtonNormal") theme_override_styles/hover = SubResource("ButtonNormal") theme_override_styles/pressed = SubResource("ButtonPressed") -text = "<" +icon = ExtResource("2_left") +expand_icon = true +icon_max_width = 48 [node name="MoveRight" type="Button" parent="Controls"] layout_mode = 0 @@ -75,7 +81,9 @@ theme_override_font_sizes/font_size = 42 theme_override_styles/normal = SubResource("ButtonNormal") theme_override_styles/hover = SubResource("ButtonNormal") theme_override_styles/pressed = SubResource("ButtonPressed") -text = ">" +icon = ExtResource("3_right") +expand_icon = true +icon_max_width = 48 [node name="Jump" type="Button" parent="Controls"] layout_mode = 0 @@ -97,7 +105,9 @@ theme_override_font_sizes/font_size = 22 theme_override_styles/normal = SubResource("ButtonNormal") theme_override_styles/hover = SubResource("ButtonNormal") theme_override_styles/pressed = SubResource("ButtonPressed") -text = "JUMP" +icon = ExtResource("4_jump") +expand_icon = true +icon_max_width = 48 [node name="Attack" type="Button" parent="Controls"] layout_mode = 0 @@ -119,4 +129,6 @@ theme_override_font_sizes/font_size = 22 theme_override_styles/normal = SubResource("ButtonNormal") theme_override_styles/hover = SubResource("ButtonNormal") theme_override_styles/pressed = SubResource("ButtonPressed") -text = "ATK" +icon = ExtResource("5_attack") +expand_icon = true +icon_max_width = 48