Restructuring of Nodes and Scenes. Added WorldCamera. Added a Main Scene.

This commit is contained in:
gdz
2025-12-07 14:15:24 +01:00
parent 2a5fdec16a
commit de8a4e5e91
16 changed files with 128 additions and 81 deletions

24
Scenes/Player/player.gd Normal file
View File

@@ -0,0 +1,24 @@
extends Area2D
class_name Player
const GROUP = "player"
const _movementSpeed = 2
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
if Input.is_action_pressed("MoveUp"):
$AnimatedSprite2D.global_position += Vector2.UP * 2
if Input.is_action_pressed("MoveDown"):
$AnimatedSprite2D.global_position += Vector2.DOWN * 2
if Input.is_action_pressed("MoveLeft"):
$AnimatedSprite2D.global_position += Vector2.LEFT * 2
if Input.is_action_pressed("MoveRight"):
$AnimatedSprite2D.global_position += Vector2.RIGHT * 2
$Camera2D.global_position = $AnimatedSprite2D.global_position

View File

@@ -0,0 +1 @@
uid://q6cxagn6igja

34
Scenes/Player/player.tscn Normal file
View File

@@ -0,0 +1,34 @@
[gd_scene load_steps=5 format=3 uid="uid://dh8pjs2s1kud3"]
[ext_resource type="Script" uid="uid://q6cxagn6igja" path="res://Scenes/Player/player.gd" id="1_a3d8c"]
[ext_resource type="Texture2D" uid="uid://04ecsvg7ausn" path="res://icon.svg" id="2_xpcdj"]
[sub_resource type="SpriteFrames" id="SpriteFrames_c3an2"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": ExtResource("2_xpcdj")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_vjcy3"]
size = Vector2(32, 32)
[node name="Player" type="Area2D" groups=["player"]]
script = ExtResource("1_a3d8c")
metadata/_edit_group_ = true
metadata/_edit_lock_ = true
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
position = Vector2(4.76837e-07, -4.76837e-07)
scale = Vector2(0.25, 0.25)
sprite_frames = SubResource("SpriteFrames_c3an2")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_vjcy3")
[node name="PlayerCamera" type="Camera2D" parent="."]
zoom = Vector2(4, 4)