Enemy
This commit is contained in:
191
scenes/Game/Player/pla5ED6.tmp
Normal file
191
scenes/Game/Player/pla5ED6.tmp
Normal file
@ -0,0 +1,191 @@
|
||||
[gd_scene load_steps=28 format=3 uid="uid://cwhk7ysxws0s0"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/Game/Player/player.gd" id="1_f437e"]
|
||||
[ext_resource type="Texture2D" uid="uid://uobvqa86mtra" path="res://assets/Sunny Land Collection Files/Sunny Land Collection Files/Assets/Characters/Players/Squirrel/idle/spritesheet.png" id="2_r3s32"]
|
||||
[ext_resource type="Texture2D" uid="uid://dsxamfhimcg4y" path="res://assets/Sunny Land Collection Files/Sunny Land Collection Files/Assets/Characters/Players/Squirrel/hurt/spritesheet.png" id="3_srffp"]
|
||||
[ext_resource type="Texture2D" uid="uid://bua1m1rj2utkk" path="res://assets/Sunny Land Collection Files/Sunny Land Collection Files/Assets/Characters/Players/Squirrel/jump/spritesheet.png" id="4_ks4c0"]
|
||||
[ext_resource type="Texture2D" uid="uid://bpiyhyvswfjcn" path="res://assets/Sunny Land Collection Files/Sunny Land Collection Files/Assets/Characters/Players/Squirrel/run/spritesheets.png" id="5_f3bx4"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_dqyxk"]
|
||||
atlas = ExtResource("3_srffp")
|
||||
region = Rect2(0, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_xsbq4"]
|
||||
atlas = ExtResource("3_srffp")
|
||||
region = Rect2(90, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_vn7gu"]
|
||||
atlas = ExtResource("2_r3s32")
|
||||
region = Rect2(0, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qmgau"]
|
||||
atlas = ExtResource("2_r3s32")
|
||||
region = Rect2(90, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_f50k5"]
|
||||
atlas = ExtResource("2_r3s32")
|
||||
region = Rect2(180, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_37eky"]
|
||||
atlas = ExtResource("2_r3s32")
|
||||
region = Rect2(270, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_4pd0r"]
|
||||
atlas = ExtResource("2_r3s32")
|
||||
region = Rect2(360, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_t0f3l"]
|
||||
atlas = ExtResource("2_r3s32")
|
||||
region = Rect2(450, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_7e1p8"]
|
||||
atlas = ExtResource("2_r3s32")
|
||||
region = Rect2(540, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qinjk"]
|
||||
atlas = ExtResource("2_r3s32")
|
||||
region = Rect2(630, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_j3m0v"]
|
||||
atlas = ExtResource("4_ks4c0")
|
||||
region = Rect2(0, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_r8mn1"]
|
||||
atlas = ExtResource("4_ks4c0")
|
||||
region = Rect2(90, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_n5oix"]
|
||||
atlas = ExtResource("4_ks4c0")
|
||||
region = Rect2(180, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_kvbtk"]
|
||||
atlas = ExtResource("4_ks4c0")
|
||||
region = Rect2(270, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_edg0r"]
|
||||
atlas = ExtResource("5_f3bx4")
|
||||
region = Rect2(0, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_knuog"]
|
||||
atlas = ExtResource("5_f3bx4")
|
||||
region = Rect2(90, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ftbig"]
|
||||
atlas = ExtResource("5_f3bx4")
|
||||
region = Rect2(180, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ruuj8"]
|
||||
atlas = ExtResource("5_f3bx4")
|
||||
region = Rect2(270, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_v6bmq"]
|
||||
atlas = ExtResource("5_f3bx4")
|
||||
region = Rect2(360, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_rlkj5"]
|
||||
atlas = ExtResource("5_f3bx4")
|
||||
region = Rect2(450, 0, 90, 58)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_fql3i"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_dqyxk")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_xsbq4")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"hurt",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_vn7gu")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_qmgau")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_f50k5")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_37eky")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_4pd0r")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_t0f3l")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_7e1p8")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_qinjk")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"idle",
|
||||
"speed": 7.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_j3m0v")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_r8mn1")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_n5oix")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_kvbtk")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"jump",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_edg0r")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_knuog")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_ftbig")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_ruuj8")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_v6bmq")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_rlkj5")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"run",
|
||||
"speed": 12.0
|
||||
}]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_gqjua"]
|
||||
radius = 8.0
|
||||
height = 24.0
|
||||
|
||||
[node name="Player" type="CharacterBody2D"]
|
||||
script = ExtResource("1_f437e")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
position = Vector2(4, -19)
|
||||
sprite_frames = SubResource("SpriteFrames_fql3i")
|
||||
animation = &"idle"
|
||||
autoplay = "idle"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(1, -11)
|
||||
shape = SubResource("CapsuleShape2D_gqjua")
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
ignore_rotation = false
|
||||
zoom = Vector2(1.6, 1.6)
|
49
scenes/Game/Player/player.gd
Normal file
49
scenes/Game/Player/player.gd
Normal file
@ -0,0 +1,49 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
|
||||
const SPEED = 400.0
|
||||
const JUMP_VELOCITY = -400.0
|
||||
|
||||
var jumped = false
|
||||
@onready var animation = get_node("AnimatedSprite2D")
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
animation.play("idle")
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
# Add the gravity.
|
||||
if not is_on_floor():
|
||||
velocity += get_gravity() * delta
|
||||
|
||||
# Handle jump.
|
||||
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
|
||||
velocity.y = JUMP_VELOCITY
|
||||
if animation.animation != "jump" : animation.play("jump")
|
||||
|
||||
elif is_on_floor():
|
||||
if animation.animation == "jump" : animation.play("idle")
|
||||
|
||||
|
||||
# Get the input direction and handle the movement/deceleration.
|
||||
# As good practice, you should replace UI actions with custom gameplay actions.
|
||||
var direction := Input.get_axis("ui_left", "ui_right")
|
||||
|
||||
if direction > 0:
|
||||
if animation.animation == "idle" : animation.play("run")
|
||||
animation.flip_h = false
|
||||
elif direction < 0:
|
||||
if animation.animation == "idle" : animation.play("run")
|
||||
animation.flip_h = true
|
||||
else:
|
||||
if animation.animation == "run" : animation.play("idle")
|
||||
|
||||
if direction:
|
||||
velocity.x = direction * SPEED
|
||||
else:
|
||||
velocity.x = move_toward(velocity.x, 0, SPEED)
|
||||
|
||||
#if global_position.y > 700:
|
||||
#print("DEAD")
|
||||
|
||||
move_and_slide()
|
187
scenes/Game/Player/player.tscn
Normal file
187
scenes/Game/Player/player.tscn
Normal file
@ -0,0 +1,187 @@
|
||||
[gd_scene load_steps=28 format=3 uid="uid://cwhk7ysxws0s0"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/Game/Player/player.gd" id="1_f437e"]
|
||||
[ext_resource type="Texture2D" uid="uid://uobvqa86mtra" path="res://assets/Sunny Land Collection Files/Sunny Land Collection Files/Assets/Characters/Players/Squirrel/idle/spritesheet.png" id="2_r3s32"]
|
||||
[ext_resource type="Texture2D" uid="uid://dsxamfhimcg4y" path="res://assets/Sunny Land Collection Files/Sunny Land Collection Files/Assets/Characters/Players/Squirrel/hurt/spritesheet.png" id="3_srffp"]
|
||||
[ext_resource type="Texture2D" uid="uid://bua1m1rj2utkk" path="res://assets/Sunny Land Collection Files/Sunny Land Collection Files/Assets/Characters/Players/Squirrel/jump/spritesheet.png" id="4_ks4c0"]
|
||||
[ext_resource type="Texture2D" uid="uid://bpiyhyvswfjcn" path="res://assets/Sunny Land Collection Files/Sunny Land Collection Files/Assets/Characters/Players/Squirrel/run/spritesheets.png" id="5_f3bx4"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_dqyxk"]
|
||||
atlas = ExtResource("3_srffp")
|
||||
region = Rect2(0, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_xsbq4"]
|
||||
atlas = ExtResource("3_srffp")
|
||||
region = Rect2(90, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_vn7gu"]
|
||||
atlas = ExtResource("2_r3s32")
|
||||
region = Rect2(0, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qmgau"]
|
||||
atlas = ExtResource("2_r3s32")
|
||||
region = Rect2(90, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_f50k5"]
|
||||
atlas = ExtResource("2_r3s32")
|
||||
region = Rect2(180, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_37eky"]
|
||||
atlas = ExtResource("2_r3s32")
|
||||
region = Rect2(270, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_4pd0r"]
|
||||
atlas = ExtResource("2_r3s32")
|
||||
region = Rect2(360, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_t0f3l"]
|
||||
atlas = ExtResource("2_r3s32")
|
||||
region = Rect2(450, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_7e1p8"]
|
||||
atlas = ExtResource("2_r3s32")
|
||||
region = Rect2(540, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qinjk"]
|
||||
atlas = ExtResource("2_r3s32")
|
||||
region = Rect2(630, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_j3m0v"]
|
||||
atlas = ExtResource("4_ks4c0")
|
||||
region = Rect2(0, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_r8mn1"]
|
||||
atlas = ExtResource("4_ks4c0")
|
||||
region = Rect2(90, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_n5oix"]
|
||||
atlas = ExtResource("4_ks4c0")
|
||||
region = Rect2(180, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_kvbtk"]
|
||||
atlas = ExtResource("4_ks4c0")
|
||||
region = Rect2(270, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_edg0r"]
|
||||
atlas = ExtResource("5_f3bx4")
|
||||
region = Rect2(0, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_knuog"]
|
||||
atlas = ExtResource("5_f3bx4")
|
||||
region = Rect2(90, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ftbig"]
|
||||
atlas = ExtResource("5_f3bx4")
|
||||
region = Rect2(180, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ruuj8"]
|
||||
atlas = ExtResource("5_f3bx4")
|
||||
region = Rect2(270, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_v6bmq"]
|
||||
atlas = ExtResource("5_f3bx4")
|
||||
region = Rect2(360, 0, 90, 58)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_rlkj5"]
|
||||
atlas = ExtResource("5_f3bx4")
|
||||
region = Rect2(450, 0, 90, 58)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_fql3i"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_dqyxk")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_xsbq4")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"hurt",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_vn7gu")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_qmgau")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_f50k5")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_37eky")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_4pd0r")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_t0f3l")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_7e1p8")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_qinjk")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"idle",
|
||||
"speed": 7.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_j3m0v")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_r8mn1")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_n5oix")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_kvbtk")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"jump",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_edg0r")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_knuog")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_ftbig")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_ruuj8")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_v6bmq")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_rlkj5")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"run",
|
||||
"speed": 12.0
|
||||
}]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_gqjua"]
|
||||
radius = 8.0
|
||||
height = 24.0
|
||||
|
||||
[node name="Player" type="CharacterBody2D"]
|
||||
script = ExtResource("1_f437e")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
position = Vector2(4, -19)
|
||||
sprite_frames = SubResource("SpriteFrames_fql3i")
|
||||
animation = &"idle"
|
||||
autoplay = "idle"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(1, -11)
|
||||
shape = SubResource("CapsuleShape2D_gqjua")
|
Reference in New Issue
Block a user