diff --git a/backgounds/galaxy.gd b/backgounds/galaxy.gd index 44887b2..95f8acc 100644 --- a/backgounds/galaxy.gd +++ b/backgounds/galaxy.gd @@ -2,7 +2,7 @@ extends Node2D # Called when the node enters the scene tree for the first time. -var galaxy = load("res://levels/galaxy.tscn").instantiate() +var galaxy = load("res://levels/galaxy/galaxy.tscn").instantiate() func _ready(): get_tree().root.add_child.call_deferred(galaxy) diff --git a/levels/galaxy.tscn b/levels/galaxy.tscn deleted file mode 100644 index ca9ff86..0000000 --- a/levels/galaxy.tscn +++ /dev/null @@ -1,12 +0,0 @@ -[gd_scene load_steps=3 format=3 uid="uid://mtl88mcwaqk0"] - -[ext_resource type="Texture2D" uid="uid://8lioamk650y7" path="res://sprites/css.png" id="1_dnk62"] -[ext_resource type="Script" path="res://levels/galaxy.gd" id="1_vnag2"] - -[node name="galaxy" type="Node2D"] -script = ExtResource("1_vnag2") - -[node name="css1" type="Sprite2D" parent="."] -position = Vector2(852, 455) -scale = Vector2(0.3, 0.3) -texture = ExtResource("1_dnk62") diff --git a/levels/galaxy/css1.gd b/levels/galaxy/css1.gd new file mode 100644 index 0000000..77a8d90 --- /dev/null +++ b/levels/galaxy/css1.gd @@ -0,0 +1,30 @@ +extends Sprite2D + + +# 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. + + +# 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: + velocity = (Vector2.RIGHT.rotated(rotation) * -400 * Input.get_joy_axis(0,JOY_AXIS_LEFT_X))-Vector2.UP.rotated(rotation) * -400 * Input.get_joy_axis(0,JOY_AXIS_LEFT_Y) + else: + if Input.is_action_pressed("ui_left"): + xm = -1 + if Input.is_action_pressed("ui_right"): + xm = 1 + if Input.is_action_pressed("ui_up"): + ym = -1 + if Input.is_action_pressed("ui_down"): + ym = 1 + velocity = (Vector2.RIGHT.rotated(rotation) * -400 * xm)-Vector2.UP.rotated(rotation) * -400 * ym + #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 + #pass diff --git a/levels/galaxy.gd b/levels/galaxy/galaxy.gd similarity index 100% rename from levels/galaxy.gd rename to levels/galaxy/galaxy.gd diff --git a/levels/galaxy/galaxy.tscn b/levels/galaxy/galaxy.tscn new file mode 100644 index 0000000..1d4aa78 --- /dev/null +++ b/levels/galaxy/galaxy.tscn @@ -0,0 +1,14 @@ +[gd_scene load_steps=4 format=3 uid="uid://mtl88mcwaqk0"] + +[ext_resource type="Texture2D" uid="uid://8lioamk650y7" path="res://sprites/css.png" id="1_hfecx"] +[ext_resource type="Script" path="res://levels/galaxy/galaxy.gd" id="1_w4ic2"] +[ext_resource type="Script" path="res://levels/galaxy/css1.gd" id="3_mowmg"] + +[node name="galaxy" type="Node2D"] +script = ExtResource("1_w4ic2") + +[node name="css1" type="Sprite2D" parent="."] +position = Vector2(852, 455) +scale = Vector2(0.3, 0.3) +texture = ExtResource("1_hfecx") +script = ExtResource("3_mowmg")