Skip to content

Commit

Permalink
Fix touch 2 buttons problem, add WASD
Browse files Browse the repository at this point in the history
  • Loading branch information
= mlm-games committed Aug 28, 2024
1 parent 2f33190 commit 1113707
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 23 deletions.
4 changes: 4 additions & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,25 @@ import/blender/enabled=false
down={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
up={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null)
]
}
right={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null)
]
}
left={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null)
]
}
fire={
Expand Down
8 changes: 1 addition & 7 deletions scenes/hud.gd
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ func _ready() -> void:
%"Virtual Joystick".process_mode = Node.PROCESS_MODE_DISABLED
%"Virtual Joystick".hide()
%FireButton.scale = Vector2(4,4)
# idk how this works but (width + size)/2 doesnt
%FireButton.global_position.x = ProjectSettings.get_setting("display/window/size/viewport_width")/2 - (%FireButton.size.x * %FireButton.scale.x)/2
%FireButton.global_position.x = ProjectSettings.get_setting("display/window/size/viewport_width")/2 - (%FireButton.texture_normal.get_size().x * %FireButton.scale.x)/2

# Connect to player signals (for opening scene without player i.e debugging)
if player:
Expand Down Expand Up @@ -88,8 +87,3 @@ func _on_right_touch_screen_button_button_up() -> void:

func _on_left_touch_screen_button_button_up() -> void:
Input.action_release("left")


func _on_fire_button_button_down() -> void:
Input.action_press("fire")
Input.action_release("fire")
20 changes: 6 additions & 14 deletions scenes/hud.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=13 format=3 uid="uid://dw1xhin6im8kv"]
[gd_scene load_steps=12 format=3 uid="uid://dw1xhin6im8kv"]

[ext_resource type="Script" path="res://scenes/hud.gd" id="1_ocri0"]
[ext_resource type="LabelSettings" uid="uid://bj4owgofe5ayt" path="res://resources/textstyle.tres" id="2_8bg75"]
Expand All @@ -7,7 +7,6 @@
[ext_resource type="Texture2D" uid="uid://ceroyuqbhc4ys" path="res://art-and-sound/kenney_space-shooter-redux/PNG/Meteors/meteorBrown_med1.png" id="6_5rvp1"]
[ext_resource type="Texture2D" uid="uid://b7fpmcg7ian2w" path="res://art-and-sound/missile/spr_missile.png" id="6_o465q"]
[ext_resource type="Texture2D" uid="uid://c33xrciyt6ilb" path="res://art-and-sound/bg_1_1.png" id="7_2s6xh"]
[ext_resource type="Theme" uid="uid://bmy6kos4l110s" path="res://resources/button-theme.tres" id="7_oub31"]

[sub_resource type="Animation" id="Animation_c728u"]
length = 0.001
Expand Down Expand Up @@ -77,7 +76,7 @@ _data = {
}

[node name="HUD" type="CanvasLayer"]
layer = -3
layer = -1
script = ExtResource("1_ocri0")

[node name="Control" type="Control" parent="."]
Expand Down Expand Up @@ -272,22 +271,15 @@ size_flags_horizontal = 3
layout_mode = 2
size_flags_vertical = 3

[node name="FireButton" type="Button" parent="Control/TouchAltVBoxContainer/Control"]
[node name="FireButton" type="TouchScreenButton" parent="Control/TouchAltVBoxContainer/Control"]
unique_name_in_owner = true
modulate = Color(1, 1, 1, 0.52549)
layout_mode = 0
offset_left = 399.0
offset_top = 53.0001
offset_right = 450.0
offset_bottom = 104.0
position = Vector2(394, 57)
scale = Vector2(3.205, 3.205)
focus_mode = 0
theme = ExtResource("7_oub31")
icon = ExtResource("6_5rvp1")
icon_alignment = 1
texture_normal = ExtResource("6_5rvp1")
action = "fire"

[connection signal="button_down" from="Control/TouchAltVBoxContainer/HBoxContainer/LeftTouchScreenButton" to="." method="_on_left_touch_screen_button_button_down"]
[connection signal="button_up" from="Control/TouchAltVBoxContainer/HBoxContainer/LeftTouchScreenButton" to="." method="_on_left_touch_screen_button_button_up"]
[connection signal="button_down" from="Control/TouchAltVBoxContainer/HBoxContainer/RightTouchScreenButton" to="." method="_on_right_touch_screen_button_button_down"]
[connection signal="button_up" from="Control/TouchAltVBoxContainer/HBoxContainer/RightTouchScreenButton" to="." method="_on_right_touch_screen_button_button_up"]
[connection signal="button_down" from="Control/TouchAltVBoxContainer/Control/FireButton" to="." method="_on_fire_button_button_down"]
2 changes: 1 addition & 1 deletion scenes/spring_laser.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extends CharacterBody2D

#HACK: moves in the direction of its movement
#HACK: looks in the direction of its movement

# Enemy properties
var amplitude = 150.0 # Adjust this for the size of the sine wave
Expand Down
1 change: 0 additions & 1 deletion scenes/world.gd
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
extends Node2D
#FIXME: Convert audio files to check if they work (to .wav?), or find a solution to the poping of audio for fdroid files.

#You are a spaceship travelling along an asteriod belt trying to find what seems to be an anomaly,You get switched up into an asteriod but can move like an spaceship, when you try to reach back to your spacemates, they cant hear you and uh oh, looks like a fleet is firing at your asteriod belt. Will you live to tell your tale another day?

Expand Down

0 comments on commit 1113707

Please sign in to comment.