Rename Player to Unit
This commit is contained in:
parent
75a720eb45
commit
beabc319e5
@ -14,7 +14,7 @@ func _init():
|
|||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
homes = tiles.filter(is_home)
|
homes = tiles.filter(is_home)
|
||||||
$Player.position = homes[0].position
|
$Unit.position = homes[0].position
|
||||||
next_home = homes[1].position
|
next_home = homes[1].position
|
||||||
homes = [homes[0], homes[1], homes[3], homes[2]]
|
homes = [homes[0], homes[1], homes[3], homes[2]]
|
||||||
pass
|
pass
|
||||||
@ -25,8 +25,9 @@ func is_home(tile):
|
|||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
if $Player.position != next_home:
|
var move_speed = delta * 60.0
|
||||||
$Player.position = $Player.position.move_toward(next_home, 4)
|
if $Unit.position != next_home:
|
||||||
|
$Unit.position = $Unit.position.move_toward(next_home, move_speed * 8)
|
||||||
else:
|
else:
|
||||||
x += 1
|
x += 1
|
||||||
next_home = homes[x % 4].position
|
next_home = homes[x % 4].position
|
||||||
|
@ -6,4 +6,4 @@
|
|||||||
[node name="Field" type="Node2D"]
|
[node name="Field" type="Node2D"]
|
||||||
script = ExtResource("1_6uvjw")
|
script = ExtResource("1_6uvjw")
|
||||||
|
|
||||||
[node name="Player" parent="." instance=ExtResource("2_oi7aa")]
|
[node name="Unit" parent="." instance=ExtResource("2_jhvjp")]
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
extends Node2D
|
|
||||||
|
|
||||||
var yvel = 1
|
|
||||||
var yoff = 0
|
|
||||||
|
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
|
||||||
func _ready():
|
|
||||||
$Sprite2D.texture = PakAssetLoader.load_file("user://data/units.pak/tomomo_00_00.dat")
|
|
||||||
$Sprite2D.position = get_global_transform().origin
|
|
||||||
$Sprite2D.position.y -= 128
|
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
||||||
func _process(_delta):
|
|
||||||
var pos = get_global_transform().origin
|
|
||||||
pos.y += -128 + yoff
|
|
||||||
yvel -= 1
|
|
||||||
if yvel < -9:
|
|
||||||
yvel = 9
|
|
||||||
pos.y += yvel
|
|
||||||
yoff += yvel
|
|
||||||
$Sprite2D.position = pos
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
|||||||
[gd_scene load_steps=2 format=3 uid="uid://dtm0201qhcn4d"]
|
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://Player/player.gd" id="1_6ggpr"]
|
|
||||||
|
|
||||||
[node name="Player" type="Node2D"]
|
|
||||||
z_index = 1
|
|
||||||
script = ExtResource("1_6ggpr")
|
|
||||||
metadata/_edit_group_ = true
|
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
|
||||||
top_level = true
|
|
||||||
z_index = 2
|
|
||||||
position = Vector2(2.08165e-12, -128)
|
|
21
Unit/unit.gd
Normal file
21
Unit/unit.gd
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
extends Node2D
|
||||||
|
|
||||||
|
var yvel = 1
|
||||||
|
var yoff = 0
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
$UnitSprite.texture = PakAssetLoader.load_file("user://data/units.pak/tomomo_00_00.dat")
|
||||||
|
$UnitSprite.position = get_parent().to_global(position)
|
||||||
|
$UnitSprite/AnimationPlayer.play("move")
|
||||||
|
$UnitSprite/AnimationPlayer.speed_scale = 1
|
||||||
|
|
||||||
|
$RingSprite.texture = PakAssetLoader.load_file("user://data/system.pak/playerring1.dat")
|
||||||
|
$RingSprite/AnimationPlayer.play("spin")
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(_delta):
|
||||||
|
$UnitSprite.position = get_parent().to_global(position)
|
||||||
|
pass
|
134
Unit/unit.tscn
Normal file
134
Unit/unit.tscn
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
[gd_scene load_steps=9 format=3 uid="uid://dtm0201qhcn4d"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://Unit/unit.gd" id="1_6ggpr"]
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_ijbbj"]
|
||||||
|
length = 0.001
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath(".:rotation")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [0.0]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_wu12n"]
|
||||||
|
resource_name = "spin"
|
||||||
|
length = 7.00001
|
||||||
|
loop_mode = 1
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath(".:rotation")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = false
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 7),
|
||||||
|
"transitions": PackedFloat32Array(1, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [0.0, 6.28319]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_fvvof"]
|
||||||
|
_data = {
|
||||||
|
"RESET": SubResource("Animation_ijbbj"),
|
||||||
|
"spin": SubResource("Animation_wu12n")
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_nsm8w"]
|
||||||
|
length = 0.001
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath(".:scale")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(1, 1)]
|
||||||
|
}
|
||||||
|
tracks/1/type = "value"
|
||||||
|
tracks/1/imported = false
|
||||||
|
tracks/1/enabled = true
|
||||||
|
tracks/1/path = NodePath(".:offset")
|
||||||
|
tracks/1/interp = 1
|
||||||
|
tracks/1/loop_wrap = true
|
||||||
|
tracks/1/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(2.08165e-12, -128)]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_yme65"]
|
||||||
|
resource_name = "idle"
|
||||||
|
length = 1.2
|
||||||
|
loop_mode = 2
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath(".:scale")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 1.2),
|
||||||
|
"transitions": PackedFloat32Array(-2, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(1, 1), Vector2(1.05, 0.97)]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_mqx3b"]
|
||||||
|
resource_name = "move"
|
||||||
|
length = 0.116668
|
||||||
|
loop_mode = 2
|
||||||
|
step = 0.0166667
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath(".:offset")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.116667),
|
||||||
|
"transitions": PackedFloat32Array(0.435275, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(2.08165e-12, -128), Vector2(2.08165e-12, -158)]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_8dthf"]
|
||||||
|
_data = {
|
||||||
|
"RESET": SubResource("Animation_nsm8w"),
|
||||||
|
"idle": SubResource("Animation_yme65"),
|
||||||
|
"move": SubResource("Animation_mqx3b")
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Unit" type="Node2D"]
|
||||||
|
z_index = 1
|
||||||
|
script = ExtResource("1_6ggpr")
|
||||||
|
metadata/_edit_group_ = true
|
||||||
|
|
||||||
|
[node name="RingSprite" type="Sprite2D" parent="."]
|
||||||
|
flip_v = true
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="RingSprite"]
|
||||||
|
libraries = {
|
||||||
|
"": SubResource("AnimationLibrary_fvvof")
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="UnitSprite" type="Sprite2D" parent="."]
|
||||||
|
top_level = true
|
||||||
|
z_index = 2
|
||||||
|
offset = Vector2(2.08165e-12, -128)
|
||||||
|
flip_h = true
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="UnitSprite"]
|
||||||
|
libraries = {
|
||||||
|
"": SubResource("AnimationLibrary_8dthf")
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user