This commit is contained in:
Page Asgardius 2023-08-13 19:54:27 -07:00
parent a341ff5ece
commit 8e7c92d7d7
5 changed files with 45 additions and 13 deletions

View file

@ -2,7 +2,7 @@ extends Node2D
# Called when the node enters the scene tree for the first time. # 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(): func _ready():
get_tree().root.add_child.call_deferred(galaxy) get_tree().root.add_child.call_deferred(galaxy)

View file

@ -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")

30
levels/galaxy/css1.gd Normal file
View file

@ -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

14
levels/galaxy/galaxy.tscn Normal file
View file

@ -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")