r3-next/levels/antenna.gd

42 lines
1.8 KiB
GDScript3
Raw Normal View History

2023-08-14 04:54:27 +02:00
extends Sprite2D
2023-09-08 21:50:34 +02:00
var origpos
#var origmpos
2023-08-14 04:54:27 +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():
2023-09-08 21:50:34 +02:00
origpos = self.position
#origmpos = get_viewport().get_mouse_position()
#pass # Replace with function body.
2023-08-14 04:54:27 +02:00
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
var xm = 0
var ym = 0
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:
2023-09-07 19:22:40 +02:00
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)
2023-09-08 21:50:34 +02:00
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))
2023-08-14 04:54:27 +02:00
else:
2023-09-14 18:47:04 +02:00
if Input.is_action_pressed("ui_left") || Input.is_key_pressed(KEY_A):
2023-08-14 04:54:27 +02:00
xm = -1
2023-09-14 18:47:04 +02:00
if Input.is_action_pressed("ui_right") || Input.is_key_pressed(KEY_D):
2023-08-14 04:54:27 +02:00
xm = 1
2023-09-14 18:47:04 +02:00
if Input.is_action_pressed("ui_up") || Input.is_key_pressed(KEY_W):
2023-08-14 04:54:27 +02:00
ym = -1
2023-09-14 18:47:04 +02:00
if Input.is_action_pressed("ui_down") || Input.is_key_pressed(KEY_S):
2023-08-14 04:54:27 +02:00
ym = 1
2023-09-07 19:22:40 +02:00
velocity = (Vector2.RIGHT.rotated(rotation) * -50000 * xm * delta)-Vector2.UP.rotated(rotation) * -50000 * ym * delta
2023-09-08 21:50:34 +02:00
origpos = self.position
#origmpos = get_viewport().get_mouse_position()
2023-08-14 04:54:27 +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)
position += velocity * delta
2023-09-09 22:02:22 +02:00
if position.x < 782 && position.x > 496:
if position.y < 468 && position.y > 270:
Global.live = 3
2023-08-14 04:54:27 +02:00
#pass