feat: add gameScene; add player movement;
This commit is contained in:
+19
-3
@@ -1,11 +1,27 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
@export var move_speed: float = 100
|
||||
@export var hp: int = 10
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
var damage: float = 2
|
||||
print(damage)
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
var move_vector: Vector2 = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
|
||||
velocity = move_vector * move_speed
|
||||
if velocity.x > 0:
|
||||
$AnimatedSprite2D.play("move_right")
|
||||
print(velocity)
|
||||
if velocity.x < 0:
|
||||
$AnimatedSprite2D.play("move_left")
|
||||
print(velocity)
|
||||
if velocity.y > 0:
|
||||
$AnimatedSprite2D.play("move_down")
|
||||
print(velocity)
|
||||
if velocity.y < 0:
|
||||
$AnimatedSprite2D.play("move_up")
|
||||
print(velocity)
|
||||
move_and_slide()
|
||||
|
||||
+140
-3
@@ -1,17 +1,154 @@
|
||||
[gd_scene format=3 uid="uid://5viursrnvdyf"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://duilaa5lwqeup" path="res://Scenes/Player/player.gd" id="1_a3d8c"]
|
||||
[ext_resource type="Texture2D" uid="uid://d34tbjs6umyv0" path="res://Ninja Adventure - Asset Pack/Actor/Characters/EggGirl/SeparateAnim/Item.png" id="1_uvnfx"]
|
||||
[ext_resource type="Texture2D" uid="uid://cjbvc07lh4x1b" path="res://Ninja Adventure - Asset Pack/Actor/Characters/KnightGold/SeparateAnim/Walk.png" id="2_a3d8c"]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_bqpwv"]
|
||||
radius = 7.0
|
||||
height = 16.0
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_a3d8c"]
|
||||
atlas = ExtResource("2_a3d8c")
|
||||
region = Rect2(0, 0, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_74mp2"]
|
||||
atlas = ExtResource("2_a3d8c")
|
||||
region = Rect2(0, 16, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_oikmp"]
|
||||
atlas = ExtResource("2_a3d8c")
|
||||
region = Rect2(0, 32, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_06tpx"]
|
||||
atlas = ExtResource("2_a3d8c")
|
||||
region = Rect2(0, 48, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_xpcdj"]
|
||||
atlas = ExtResource("2_a3d8c")
|
||||
region = Rect2(32, 0, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_mtuoh"]
|
||||
atlas = ExtResource("2_a3d8c")
|
||||
region = Rect2(32, 16, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_htcer"]
|
||||
atlas = ExtResource("2_a3d8c")
|
||||
region = Rect2(32, 32, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_dd0ac"]
|
||||
atlas = ExtResource("2_a3d8c")
|
||||
region = Rect2(32, 48, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_0u5uq"]
|
||||
atlas = ExtResource("2_a3d8c")
|
||||
region = Rect2(48, 0, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_jlvik"]
|
||||
atlas = ExtResource("2_a3d8c")
|
||||
region = Rect2(48, 16, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_gk6dx"]
|
||||
atlas = ExtResource("2_a3d8c")
|
||||
region = Rect2(48, 32, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_jhyir"]
|
||||
atlas = ExtResource("2_a3d8c")
|
||||
region = Rect2(48, 48, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_7g0yx"]
|
||||
atlas = ExtResource("2_a3d8c")
|
||||
region = Rect2(16, 0, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_dey5f"]
|
||||
atlas = ExtResource("2_a3d8c")
|
||||
region = Rect2(16, 16, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_r5xpd"]
|
||||
atlas = ExtResource("2_a3d8c")
|
||||
region = Rect2(16, 32, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ks1b7"]
|
||||
atlas = ExtResource("2_a3d8c")
|
||||
region = Rect2(16, 48, 16, 16)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_bqpwv"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_a3d8c")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_74mp2")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_oikmp")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_06tpx")
|
||||
}],
|
||||
"loop": 1,
|
||||
"name": &"move_down",
|
||||
"speed": 6.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_xpcdj")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_mtuoh")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_htcer")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_dd0ac")
|
||||
}],
|
||||
"loop": 1,
|
||||
"name": &"move_left",
|
||||
"speed": 6.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_0u5uq")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_jlvik")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_gk6dx")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_jhyir")
|
||||
}],
|
||||
"loop": 1,
|
||||
"name": &"move_right",
|
||||
"speed": 6.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_7g0yx")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_dey5f")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_r5xpd")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_ks1b7")
|
||||
}],
|
||||
"loop": 1,
|
||||
"name": &"move_up",
|
||||
"speed": 6.0
|
||||
}]
|
||||
|
||||
[node name="CharacterBody2D" type="CharacterBody2D" unique_id=1991398375]
|
||||
motion_mode = 1
|
||||
script = ExtResource("1_a3d8c")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=129222135]
|
||||
shape = SubResource("CapsuleShape2D_bqpwv")
|
||||
|
||||
[node name="Item" type="Sprite2D" parent="." unique_id=1055747904]
|
||||
texture = ExtResource("1_uvnfx")
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." unique_id=721334358]
|
||||
sprite_frames = SubResource("SpriteFrames_bqpwv")
|
||||
animation = &"move_down"
|
||||
|
||||
Reference in New Issue
Block a user