r3-next/levels/ast1.gd

51 lines
1.8 KiB
GDScript3
Raw Normal View History

2024-10-29 22:37:39 +01:00
extends Sprite
2023-09-07 19:22:40 +02:00
2023-09-08 21:50:34 +02:00
var origpos
var ctime
#var origmpos
2023-09-07 19:22:40 +02:00
# 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():
2024-10-29 22:37:39 +01:00
#Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
2023-09-08 21:50:34 +02:00
origpos = self.position
ctime = Time.get_ticks_msec()
Global.origmpos = get_viewport().get_mouse_position()
2023-12-02 21:44:54 +01:00
2023-09-08 21:50:34 +02:00
#pass # Replace with function body.
2023-09-07 19:22:40 +02:00
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
2023-12-02 21:44:54 +01:00
Global.xm = 0
Global.ym = 0
2023-09-07 19:22:40 +02:00
var velocity = Vector2.ZERO
2023-10-09 18:37:22 +02:00
if Global.live == 1:
2024-10-29 22:37:39 +01:00
if Input.get_joy_axis(0,JOY_ANALOG_LX) > 0.2 || Input.get_joy_axis(0,JOY_ANALOG_LY) > 0.2 || Input.get_joy_axis(0,JOY_ANALOG_LX) < -0.2 || Input.get_joy_axis(0,JOY_ANALOG_LY) < -0.2:
Global.xm = Input.get_joy_axis(0,JOY_ANALOG_LX)
Global.ym = Input.get_joy_axis(0,JOY_ANALOG_LY)
2023-10-09 18:37:22 +02:00
else:
2024-10-29 22:37:39 +01:00
#Global.xm = Input.get_last_mouse_velocity().x / 100
#Global.ym = Input.get_last_mouse_velocity().y / 100
if Input.is_action_pressed("ui_left"):
2023-12-02 21:44:54 +01:00
Global.xm = -1
2024-10-29 22:37:39 +01:00
if Input.is_action_pressed("ui_right"):
2023-12-02 21:44:54 +01:00
Global.xm = 1
2024-10-29 22:37:39 +01:00
if Input.is_action_pressed("ui_up"):
2023-12-02 21:44:54 +01:00
Global.ym = -1
2024-10-29 22:37:39 +01:00
if Input.is_action_pressed("ui_down"):
2023-12-02 21:44:54 +01:00
Global.ym = 1
velocity = (Vector2.RIGHT.rotated(rotation) * -100 * Global.xm * delta)-Vector2.UP.rotated(rotation) * -100 * Global.ym * delta
ctime = Time.get_ticks_msec()
2024-01-14 03:59:55 +01:00
#elif !Global.sk && Global.live == null:
# _sk()
2023-12-02 21:44:54 +01:00
2023-09-07 19:22:40 +02:00
#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)
2023-12-02 21:44:54 +01:00
position += velocity
2023-09-07 19:22:40 +02:00
#pass
2023-12-02 21:44:54 +01:00
func _sk():
Global.sk = true
#get_tree().change_scene_to_file("res://bootclick.tscn")
var selftest = load("res://selftest.tscn").instantiate()
get_tree().root.add_child.call_deferred(selftest)