touch controls

This commit is contained in:
Page Asgardius 2023-09-08 12:50:34 -07:00
parent 54afc74a16
commit f661d7fa53
16 changed files with 154 additions and 13 deletions

21
backgounds/Home.gd Normal file
View file

@ -0,0 +1,21 @@
extends TextureButton
# Called when the node enters the scene tree for the first time.
func _ready():
var button = Button.new()
button.text = "Home"
button.pressed.connect(self._button_pressed)
add_child(button)
func _button_pressed():
Global.live = 0
#_title()
func _title():
# This is like autoloading the scene, only
# it happens after already loading the main scene.
get_tree().change_scene_to_file("res://title.tscn")
#get_tree().root.add_child(title)
#get_tree().root.remove_child(boot)
#boot.queue_free()

View file

@ -16,6 +16,8 @@ func _process(delta):
if (Time.get_ticks_msec() - wait) >= 1000 && (Input.is_key_pressed(KEY_R) || Input.is_joy_button_pressed(0,JOY_BUTTON_X) || Input.is_joy_button_pressed(0,JOY_BUTTON_Y) || Input.is_joy_button_pressed(0,JOY_BUTTON_A) || Input.is_joy_button_pressed(0,JOY_BUTTON_B) || Input.is_joy_button_pressed(0,JOY_BUTTON_BACK) || Input.is_joy_button_pressed(0,JOY_BUTTON_START) || Input.is_joy_button_pressed(0,JOY_BUTTON_RIGHT_SHOULDER) || Input.is_joy_button_pressed(0,JOY_BUTTON_LEFT_SHOULDER)):
#print("Mouse Click/Unclick at: ", event.position)
_title()
if Global.live == 0:
_title()
#pass
func _title():

View file

@ -1,8 +1,9 @@
[gd_scene load_steps=4 format=3 uid="uid://cnstwjy5mqdyo"]
[gd_scene load_steps=5 format=3 uid="uid://cnstwjy5mqdyo"]
[ext_resource type="Texture2D" uid="uid://bona2ytn3y3a5" path="res://backgounds/galaxy.png" id="1_bmyxf"]
[ext_resource type="Script" path="res://backgounds/galaxy.gd" id="1_h1j80"]
[ext_resource type="Script" path="res://fps.gd" id="3_t81vx"]
[ext_resource type="Script" path="res://backgounds/Home.gd" id="4_hhu74"]
[node name="galaxy" type="Node2D"]
script = ExtResource("1_h1j80")
@ -16,3 +17,10 @@ texture = ExtResource("1_bmyxf")
offset_right = 40.0
offset_bottom = 23.0
script = ExtResource("3_t81vx")
[node name="Home" type="TextureButton" parent="."]
offset_left = 52.0
offset_top = 39.0
offset_right = 125.0
offset_bottom = 110.0
script = ExtResource("4_hhu74")

BIN
backgounds/home.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ddf85wtbxy6no"
path="res://.godot/imported/home.png-154cee737d467ac3381773af900fb5b7.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://backgounds/home.png"
dest_files=["res://.godot/imported/home.png-154cee737d467ac3381773af900fb5b7.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

View file

@ -16,6 +16,8 @@ func _process(delta):
if (Time.get_ticks_msec() - wait) >= 1000 && (Input.is_key_pressed(KEY_R) || Input.is_joy_button_pressed(0,JOY_BUTTON_X) || Input.is_joy_button_pressed(0,JOY_BUTTON_Y) || Input.is_joy_button_pressed(0,JOY_BUTTON_A) || Input.is_joy_button_pressed(0,JOY_BUTTON_B) || Input.is_joy_button_pressed(0,JOY_BUTTON_BACK) || Input.is_joy_button_pressed(0,JOY_BUTTON_START) || Input.is_joy_button_pressed(0,JOY_BUTTON_RIGHT_SHOULDER) || Input.is_joy_button_pressed(0,JOY_BUTTON_LEFT_SHOULDER)):
#print("Mouse Click/Unclick at: ", event.position)
_title()
if Global.live == 0:
_title()
#pass
func _title():

View file

@ -1,8 +1,9 @@
[gd_scene load_steps=4 format=3 uid="uid://by7ktb1k5ml5y"]
[gd_scene load_steps=5 format=3 uid="uid://by7ktb1k5ml5y"]
[ext_resource type="Script" path="res://backgounds/wormhole.gd" id="1_fibhv"]
[ext_resource type="Texture2D" uid="uid://bcfmwk0ffy73n" path="res://backgounds/wormhole.png" id="2_6mic1"]
[ext_resource type="Script" path="res://fps.gd" id="3_o2q0w"]
[ext_resource type="Script" path="res://backgounds/Home.gd" id="5_elxjd"]
[node name="wormhole" type="Node2D"]
script = ExtResource("1_fibhv")
@ -16,3 +17,10 @@ texture = ExtResource("2_6mic1")
offset_right = 40.0
offset_bottom = 23.0
script = ExtResource("3_o2q0w")
[node name="Home" type="TextureButton" parent="."]
offset_left = 52.0
offset_top = 39.0
offset_right = 125.0
offset_bottom = 110.0
script = ExtResource("5_elxjd")

View file

@ -24,8 +24,8 @@ gradle_build/min_sdk=""
gradle_build/target_sdk=""
architectures/armeabi-v7a=true
architectures/arm64-v8a=true
architectures/x86=true
architectures/x86_64=true
architectures/x86=false
architectures/x86_64=false
version/code=1
version/name="0.0.0"
package/unique_name="asgardius.page.r3game"

14
global.gd Normal file
View file

@ -0,0 +1,14 @@
extends Node
var live
var time
var origmpos
var mousepos
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass

View file

@ -1,10 +1,13 @@
extends Sprite2D
var origpos
#var origmpos
# Called when the node enters the scene tree for the first time.
#var velocity = Input.get_vector("move_left", "move_right", "move_forward", "move_back")
func _ready():
pass # Replace with function body.
origpos = self.position
#origmpos = get_viewport().get_mouse_position()
#pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
@ -14,6 +17,9 @@ func _process(delta):
var velocity = Vector2.ZERO
if Input.get_joy_axis(0,JOY_AXIS_LEFT_X) > 0.2 || Input.get_joy_axis(0,JOY_AXIS_LEFT_Y) > 0.2 || Input.get_joy_axis(0,JOY_AXIS_LEFT_X) < -0.2 || Input.get_joy_axis(0,JOY_AXIS_LEFT_Y) < -0.2:
velocity = (Vector2.RIGHT.rotated(rotation) * -50000 * delta * Input.get_joy_axis(0,JOY_AXIS_LEFT_X))-Vector2.UP.rotated(rotation) * -50000 *delta * Input.get_joy_axis(0,JOY_AXIS_LEFT_Y)
elif Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
#var mousepos = get_viewport().get_mouse_position() - origmpos
self.position = Vector2(origpos.x+(Global.mousepos.x*5), origpos.y+(Global.mousepos.y*5))
else:
if Input.is_action_pressed("ui_left"):
xm = -1
@ -24,6 +30,8 @@ func _process(delta):
if Input.is_action_pressed("ui_down"):
ym = 1
velocity = (Vector2.RIGHT.rotated(rotation) * -50000 * xm * delta)-Vector2.UP.rotated(rotation) * -50000 * ym * delta
origpos = self.position
#origmpos = get_viewport().get_mouse_position()
#if Input.get_joy_axis(0,JOY_AXIS_LEFT_Y) != 0:
# velocity = Vector2.UP.rotated(rotation) * -400 * Input.get_joy_axis(0,JOY_AXIS_LEFT_Y)
position += velocity * delta

View file

@ -1,10 +1,15 @@
extends Sprite2D
var origpos
var ctime
#var origmpos
# Called when the node enters the scene tree for the first time.
#var velocity = Input.get_vector("move_left", "move_right", "move_forward", "move_back")
func _ready():
pass # Replace with function body.
origpos = self.position
ctime = Time.get_ticks_msec()
Global.origmpos = get_viewport().get_mouse_position()
#pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
@ -14,6 +19,13 @@ func _process(delta):
var velocity = Vector2.ZERO
if Input.get_joy_axis(0,JOY_AXIS_LEFT_X) > 0.2 || Input.get_joy_axis(0,JOY_AXIS_LEFT_Y) > 0.2 || Input.get_joy_axis(0,JOY_AXIS_LEFT_X) < -0.2 || Input.get_joy_axis(0,JOY_AXIS_LEFT_Y) < -0.2:
velocity = (Vector2.RIGHT.rotated(rotation) * -10000 * delta * Input.get_joy_axis(0,JOY_AXIS_LEFT_X))-Vector2.UP.rotated(rotation) * -10000 *delta * Input.get_joy_axis(0,JOY_AXIS_LEFT_Y)
elif Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
if (Time.get_ticks_msec() - ctime) <= 67:
Global.origmpos = get_viewport().get_mouse_position()
Global.mousepos = get_viewport().get_mouse_position() - Global.origmpos
else :
Global.mousepos = get_viewport().get_mouse_position() - Global.origmpos
self.position = Vector2(origpos.x+Global.mousepos.x, origpos.y+Global.mousepos.y)
else:
if Input.is_action_pressed("ui_left"):
xm = -1
@ -24,6 +36,9 @@ func _process(delta):
if Input.is_action_pressed("ui_down"):
ym = 1
velocity = (Vector2.RIGHT.rotated(rotation) * -10000 * xm * delta)-Vector2.UP.rotated(rotation) * -10000 * ym * delta
origpos = self.position
Global.origmpos = get_viewport().get_mouse_position()
ctime = Time.get_ticks_msec()
#if Input.get_joy_axis(0,JOY_AXIS_LEFT_Y) != 0:
# velocity = Vector2.UP.rotated(rotation) * -400 * Input.get_joy_axis(0,JOY_AXIS_LEFT_Y)
position += velocity * delta

View file

@ -1,9 +1,12 @@
extends Sprite2D
var origpos
#var origmpos
# Called when the node enters the scene tree for the first time.
#var velocity = Input.get_vector("move_left", "move_right", "move_forward", "move_back")
func _ready():
origpos = self.position
#origmpos = get_viewport().get_mouse_position()
pass # Replace with function body.
@ -14,6 +17,9 @@ func _process(delta):
var velocity = Vector2.ZERO
if Input.get_joy_axis(0,JOY_AXIS_LEFT_X) > 0.2 || Input.get_joy_axis(0,JOY_AXIS_LEFT_Y) > 0.2 || Input.get_joy_axis(0,JOY_AXIS_LEFT_X) < -0.2 || Input.get_joy_axis(0,JOY_AXIS_LEFT_Y) < -0.2:
velocity = (Vector2.RIGHT.rotated(rotation) * -20000 * delta * Input.get_joy_axis(0,JOY_AXIS_LEFT_X))-Vector2.UP.rotated(rotation) * -20000 *delta * Input.get_joy_axis(0,JOY_AXIS_LEFT_Y)
elif Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
#var mousepos = get_viewport().get_mouse_position() - origmpos
self.position = Vector2(origpos.x+(Global.mousepos.x*2), origpos.y+(Global.mousepos.y*2))
else:
if Input.is_action_pressed("ui_left"):
xm = -1
@ -24,6 +30,8 @@ func _process(delta):
if Input.is_action_pressed("ui_down"):
ym = 1
velocity = (Vector2.RIGHT.rotated(rotation) * -20000 * xm * delta)-Vector2.UP.rotated(rotation) * -20000 * ym * delta
origpos = self.position
#origmpos = get_viewport().get_mouse_position()
#if Input.get_joy_axis(0,JOY_AXIS_LEFT_Y) != 0:
# velocity = Vector2.UP.rotated(rotation) * -400 * Input.get_joy_axis(0,JOY_AXIS_LEFT_Y)
position += velocity * delta

View file

@ -1,10 +1,13 @@
extends Sprite2D
var origpos
#var origmpos
# Called when the node enters the scene tree for the first time.
#var velocity = Input.get_vector("move_left", "move_right", "move_forward", "move_back")
func _ready():
pass # Replace with function body.
origpos = self.position
#origmpos = get_viewport().get_mouse_position()
#pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
@ -14,6 +17,9 @@ func _process(delta):
var velocity = Vector2.ZERO
if Input.get_joy_axis(0,JOY_AXIS_LEFT_X) > 0.2 || Input.get_joy_axis(0,JOY_AXIS_LEFT_Y) > 0.2 || Input.get_joy_axis(0,JOY_AXIS_LEFT_X) < -0.2 || Input.get_joy_axis(0,JOY_AXIS_LEFT_Y) < -0.2:
velocity = (Vector2.RIGHT.rotated(rotation) * -30000 * delta * Input.get_joy_axis(0,JOY_AXIS_LEFT_X))-Vector2.UP.rotated(rotation) * -30000 *delta * Input.get_joy_axis(0,JOY_AXIS_LEFT_Y)
elif Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
#var mousepos = get_viewport().get_mouse_position() - origmpos
self.position = Vector2(origpos.x+(Global.mousepos.x*3), origpos.y+(Global.mousepos.y*3))
else:
if Input.is_action_pressed("ui_left"):
xm = -1
@ -24,6 +30,8 @@ func _process(delta):
if Input.is_action_pressed("ui_down"):
ym = 1
velocity = (Vector2.RIGHT.rotated(rotation) * -30000 * xm * delta)-Vector2.UP.rotated(rotation) * -30000 * ym * delta
origpos = self.position
#origmpos = get_viewport().get_mouse_position()
#if Input.get_joy_axis(0,JOY_AXIS_LEFT_Y) != 0:
# velocity = Vector2.UP.rotated(rotation) * -400 * Input.get_joy_axis(0,JOY_AXIS_LEFT_Y)
position += velocity * delta

View file

@ -1,10 +1,13 @@
extends Sprite2D
var origpos
#var origmpos
# Called when the node enters the scene tree for the first time.
#var velocity = Input.get_vector("move_left", "move_right", "move_forward", "move_back")
func _ready():
pass # Replace with function body.
origpos = self.position
#origmpos = get_viewport().get_mouse_position()
#pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
@ -14,6 +17,9 @@ func _process(delta):
var velocity = Vector2.ZERO
if Input.get_joy_axis(0,JOY_AXIS_LEFT_X) > 0.2 || Input.get_joy_axis(0,JOY_AXIS_LEFT_Y) > 0.2 || Input.get_joy_axis(0,JOY_AXIS_LEFT_X) < -0.2 || Input.get_joy_axis(0,JOY_AXIS_LEFT_Y) < -0.2:
velocity = (Vector2.RIGHT.rotated(rotation) * -50000 * delta * Input.get_joy_axis(0,JOY_AXIS_LEFT_X))-Vector2.UP.rotated(rotation) * -50000 *delta * Input.get_joy_axis(0,JOY_AXIS_LEFT_Y)
elif Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
#var mousepos = get_viewport().get_mouse_position() - origmpos
self.position = Vector2(origpos.x+(Global.mousepos.x*5), origpos.y+(Global.mousepos.y*5))
else:
if Input.is_action_pressed("ui_left"):
xm = -1
@ -24,6 +30,8 @@ func _process(delta):
if Input.is_action_pressed("ui_down"):
ym = 1
velocity = (Vector2.RIGHT.rotated(rotation) * -50000 * xm * delta)-Vector2.UP.rotated(rotation) * -50000 * ym * delta
origpos = self.position
#origmpos = get_viewport().get_mouse_position()
#if Input.get_joy_axis(0,JOY_AXIS_LEFT_Y) != 0:
# velocity = Vector2.UP.rotated(rotation) * -400 * Input.get_joy_axis(0,JOY_AXIS_LEFT_Y)
position += velocity * delta

View file

@ -15,6 +15,10 @@ run/main_scene="res://bootclick.tscn"
config/features=PackedStringArray("4.1", "GL Compatibility")
config/icon="res://icon.png"
[autoload]
Global="*res://global.gd"
[display]
window/size/viewport_width=1280

View file

@ -29,6 +29,7 @@ func _input(event):
func _level():
# This is like autoloading the scene, only
# it happens after already loading the main scene.
Global.live = 1
if randi() % 2 == 0:
get_tree().change_scene_to_file("res://backgounds/galaxy.tscn")
else: