Skip to content

Commit 0fcd409

Browse files
Configure Android export and CI build
Co-authored-by: dabigflows <dabigflows@googlemail.com>
1 parent c0fbf74 commit 0fcd409

4 files changed

Lines changed: 188 additions & 76 deletions

File tree

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Build Android APK
2+
3+
on:
4+
push:
5+
branches:
6+
- feature/androidbuild
7+
pull_request:
8+
branches:
9+
- feature/androidbuild
10+
workflow_dispatch:
11+
12+
jobs:
13+
android:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
lfs: true
21+
submodules: recursive
22+
23+
- name: Set up Java
24+
uses: actions/setup-java@v4
25+
with:
26+
distribution: temurin
27+
java-version: "17"
28+
29+
- name: Cache Godot binaries and templates
30+
id: cache-godot
31+
uses: actions/cache@v4
32+
with:
33+
path: |
34+
~/.local/share/godot/export_templates/4.4.stable
35+
~/godot
36+
key: godot-4.4-stable-${{ runner.os }}
37+
38+
- name: Download Godot Headless
39+
if: steps.cache-godot.outputs.cache-hit != 'true'
40+
run: |
41+
set -euxo pipefail
42+
GODOT_VERSION=4.4-stable
43+
mkdir -p "$HOME/godot"
44+
curl -L "https://github.com/godotengine/godot/releases/download/${GODOT_VERSION}/Godot_v${GODOT_VERSION}_linux_headless.64.zip" -o /tmp/godot_headless.zip
45+
unzip -q /tmp/godot_headless.zip -d "$HOME/godot"
46+
mv "$HOME/godot/Godot_v${GODOT_VERSION}_linux_headless.64" "$HOME/godot/godot-headless"
47+
chmod +x "$HOME/godot/godot-headless"
48+
49+
- name: Install export templates
50+
if: steps.cache-godot.outputs.cache-hit != 'true'
51+
run: |
52+
set -euxo pipefail
53+
GODOT_VERSION=4.4-stable
54+
mkdir -p "$HOME/.local/share/godot/export_templates/4.4.stable"
55+
curl -L "https://github.com/godotengine/godot/releases/download/${GODOT_VERSION}/Godot_v${GODOT_VERSION}_export_templates.tpz" -o /tmp/godot_templates.tpz
56+
unzip -q /tmp/godot_templates.tpz -d /tmp/godot_templates
57+
cp -r /tmp/godot_templates/templates/. "$HOME/.local/share/godot/export_templates/4.4.stable/"
58+
59+
- name: Add Godot to PATH
60+
run: echo "$HOME/godot" >> "$GITHUB_PATH"
61+
62+
- name: Export Android APK
63+
run: |
64+
set -euxo pipefail
65+
mkdir -p build/android
66+
godot-headless --headless --verbose --path . --export-debug "Android"
67+
68+
- name: Upload APK artifact
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: too-fishy-android-debug
72+
path: build/android/TooFishy-debug.apk

export_presets.cfg

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ custom_features=""
123123
export_filter="all_resources"
124124
include_filter=""
125125
exclude_filter=""
126-
export_path="./Too Fishy.apk"
126+
export_path="build/android/TooFishy-debug.apk"
127127
patches=PackedStringArray()
128128
encryption_include_filters=""
129129
encryption_exclude_filters=""
@@ -140,17 +140,17 @@ gradle_build/use_gradle_build=false
140140
gradle_build/gradle_build_directory=""
141141
gradle_build/android_source_template=""
142142
gradle_build/export_format=0
143-
gradle_build/min_sdk=""
144-
gradle_build/target_sdk=""
143+
gradle_build/min_sdk="24"
144+
gradle_build/target_sdk="34"
145145
gradle_build/custom_theme_attributes={}
146-
architectures/armeabi-v7a=false
146+
architectures/armeabi-v7a=true
147147
architectures/arm64-v8a=true
148148
architectures/x86=false
149149
architectures/x86_64=false
150150
version/code=1
151-
version/name=""
151+
version/name="0.1.0"
152152
package/unique_name="too.fishy.$genname"
153-
package/name=""
153+
package/name="Too Fishy"
154154
package/signed=true
155155
package/app_category=2
156156
package/retain_data_on_uninstall=false

scenes/ui/touch_controls.tscn

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,15 @@
22

33
[ext_resource type="Script" path="res://scripts/touch_controls.gd" id="1_ywmkl"]
44

5-
[node name="TouchControls" type="CanvasLayer"]
5+
[node name="TouchControls" type="Control"]
6+
layout_mode=3
7+
anchors_preset=15
8+
anchor_right=1.0
9+
anchor_bottom=1.0
10+
offset_left=0.0
11+
offset_top=0.0
12+
offset_right=0.0
13+
offset_bottom=0.0
14+
grow_horizontal=2
15+
grow_vertical=2
616
script = ExtResource("1_ywmkl")

scripts/touch_controls.gd

Lines changed: 99 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,113 @@
11
extends Control
22

3-
# Virtual joystick variables
4-
var joystick_active = false
5-
var joystick_origin = Vector2.ZERO
6-
var joystick_position = Vector2.ZERO
7-
var joystick_direction = Vector2.ZERO
8-
var joystick_radius = 100.0
3+
@export var joystick_radius := 140.0
4+
@export var joystick_handle_radius := 52.0
5+
@export var shoot_button_size := Vector2(180, 180)
6+
@export var screen_margin := 24.0
7+
@export var joystick_deadzone := 0.12
98

10-
# Shoot button variables
11-
var shoot_button_rect = Rect2(0, 0, 150, 150)
12-
var shoot_button_pressed = false
9+
var joystick_active := false
10+
var joystick_origin := Vector2.ZERO
11+
var joystick_position := Vector2.ZERO
12+
var joystick_direction := Vector2.ZERO
13+
var joystick_touch_index := -1
1314

14-
# Signals
15-
signal joystick_input(direction)
15+
var shoot_button_rect := Rect2()
16+
var shoot_button_pressed := false
17+
var shoot_touch_index := -1
18+
19+
signal joystick_input(direction: Vector2)
1620
signal shoot_pressed()
1721

1822
func _ready():
19-
# Position the shoot button in the bottom right corner
20-
var screen_size = get_viewport().get_visible_rect().size
21-
shoot_button_rect.position = Vector2(screen_size.x - shoot_button_rect.size.x - 20,
22-
screen_size.y - shoot_button_rect.size.y - 20)
23+
var should_show := OS.has_feature("mobile") or OS.has_feature("web") or DisplayServer.is_touchscreen_mode_enabled()
24+
visible = should_show
25+
set_process(should_show)
26+
set_process_input(should_show)
27+
mouse_filter = Control.MOUSE_FILTER_IGNORE
28+
top_level = true
29+
focus_mode = Control.FOCUS_NONE
30+
z_index = 128
31+
set_anchors_preset(Control.PRESET_FULL_RECT)
32+
update_layout()
33+
if get_viewport():
34+
get_viewport().size_changed.connect(update_layout)
35+
36+
func update_layout():
37+
if not is_visible_in_tree():
38+
return
39+
var screen_size := get_viewport().get_visible_rect().size if get_viewport() else size
40+
shoot_button_rect.size = shoot_button_size
41+
shoot_button_rect.position = Vector2(
42+
screen_size.x - shoot_button_rect.size.x - screen_margin,
43+
screen_size.y - shoot_button_rect.size.y - screen_margin
44+
)
45+
queue_redraw()
2346

2447
func _input(event):
2548
if event is InputEventScreenTouch:
26-
if event.pressed:
27-
# Check if touch is within shoot button
28-
if shoot_button_rect.has_point(event.position):
29-
shoot_button_pressed = true
30-
emit_signal("shoot_pressed")
31-
else:
32-
# Start joystick
33-
joystick_active = true
34-
joystick_origin = event.position
35-
joystick_position = event.position
36-
else:
37-
# End touch
38-
if shoot_button_rect.has_point(event.position) and shoot_button_pressed:
39-
shoot_button_pressed = false
40-
41-
if joystick_active:
42-
joystick_active = false
43-
joystick_direction = Vector2.ZERO
44-
emit_signal("joystick_input", Vector2.ZERO)
45-
46-
elif event is InputEventScreenDrag and joystick_active:
47-
joystick_position = event.position
48-
49-
# Calculate joystick direction and limit to radius
50-
var direction = joystick_position - joystick_origin
51-
if direction.length() > joystick_radius:
52-
direction = direction.normalized() * joystick_radius
53-
joystick_position = joystick_origin + direction
54-
55-
# Normalize for input
56-
joystick_direction = direction / joystick_radius
57-
emit_signal("joystick_input", joystick_direction)
49+
_handle_screen_touch(event)
50+
elif event is InputEventScreenDrag:
51+
_handle_screen_drag(event)
5852

59-
func _draw():
60-
if OS.has_feature("mobile") or OS.has_feature("web"):
61-
# Draw joystick if active
62-
if joystick_active:
63-
# Draw joystick base
64-
draw_circle(joystick_origin, joystick_radius, Color(0.5, 0.5, 0.5, 0.5))
65-
# Draw joystick handle
66-
draw_circle(joystick_position, 50, Color(0.7, 0.7, 0.7, 0.7))
67-
68-
# Draw shoot button
69-
var button_color = Color(1.0, 0.3, 0.3, 0.7)
70-
if shoot_button_pressed:
71-
button_color = Color(1.0, 0.5, 0.5, 0.8)
72-
73-
draw_circle(shoot_button_rect.position + shoot_button_rect.size / 2, shoot_button_rect.size.x / 2, button_color)
53+
func _handle_screen_touch(event: InputEventScreenTouch) -> void:
54+
if event.pressed:
55+
if shoot_touch_index == -1 and shoot_button_rect.has_point(event.position):
56+
shoot_touch_index = event.index
57+
shoot_button_pressed = true
58+
emit_signal("shoot_pressed")
59+
queue_redraw()
60+
return
7461

75-
# Draw shoot icon (simple crosshair)
76-
var center = shoot_button_rect.position + shoot_button_rect.size / 2
77-
var line_length = 30
78-
draw_line(center - Vector2(line_length, 0), center + Vector2(line_length, 0), Color.WHITE, 5)
79-
draw_line(center - Vector2(0, line_length), center + Vector2(0, line_length), Color.WHITE, 5)
62+
if joystick_touch_index == -1:
63+
joystick_touch_index = event.index
64+
joystick_active = true
65+
joystick_origin = event.position
66+
joystick_position = event.position
67+
joystick_direction = Vector2.ZERO
68+
emit_signal("joystick_input", joystick_direction)
69+
queue_redraw()
70+
else:
71+
if event.index == shoot_touch_index:
72+
shoot_touch_index = -1
73+
shoot_button_pressed = false
74+
queue_redraw()
75+
if event.index == joystick_touch_index:
76+
joystick_touch_index = -1
77+
joystick_active = false
78+
joystick_direction = Vector2.ZERO
79+
emit_signal("joystick_input", Vector2.ZERO)
80+
queue_redraw()
8081

81-
func _process(_delta):
82-
# Redraw the controls every frame to handle movement
82+
func _handle_screen_drag(event: InputEventScreenDrag) -> void:
83+
if event.index != joystick_touch_index or not joystick_active:
84+
return
85+
joystick_position = event.position
86+
var direction := joystick_position - joystick_origin
87+
var distance := direction.length()
88+
if distance > joystick_radius and distance > 0:
89+
direction = direction / distance * joystick_radius
90+
joystick_position = joystick_origin + direction
91+
var normalized := direction / joystick_radius
92+
if normalized.length() < joystick_deadzone:
93+
normalized = Vector2.ZERO
94+
joystick_direction = normalized
95+
emit_signal("joystick_input", joystick_direction)
8396
queue_redraw()
97+
98+
func _draw():
99+
if not visible:
100+
return
101+
if not (OS.has_feature("mobile") or OS.has_feature("web") or DisplayServer.is_touchscreen_mode_enabled()):
102+
return
103+
if joystick_active:
104+
draw_circle(joystick_origin, joystick_radius, Color(0.5, 0.5, 0.5, 0.35))
105+
draw_circle(joystick_position, joystick_handle_radius, Color(0.8, 0.8, 0.8, 0.55))
106+
var button_color := Color(1.0, 0.3, 0.3, 0.65)
107+
if shoot_button_pressed:
108+
button_color = Color(1.0, 0.5, 0.5, 0.8)
109+
draw_circle(shoot_button_rect.position + shoot_button_rect.size / 2.0, shoot_button_rect.size.x / 2.0, button_color)
110+
var center := shoot_button_rect.position + shoot_button_rect.size / 2.0
111+
var line_length := shoot_button_rect.size.x * 0.18
112+
draw_line(center - Vector2(line_length, 0), center + Vector2(line_length, 0), Color.WHITE, 5)
113+
draw_line(center - Vector2(0, line_length), center + Vector2(0, line_length), Color.WHITE, 5)

0 commit comments

Comments
 (0)