Enemy
This commit is contained in:
23
scenes/Game/Background/background.tscn
Normal file
23
scenes/Game/Background/background.tscn
Normal file
@ -0,0 +1,23 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://by4cti43klsp2"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://5bcs7peqaotp" path="res://scenes/Game/Background/parallax_background.tscn" id="1_ofe3s"]
|
||||
[ext_resource type="Texture2D" uid="uid://csqkeotrgdjmn" path="res://assets/Sunny Land Collection Files/Sunny Land Collection Files/Assets/Environments/Forest of Illusion/Forest of Illusion Expansion Pack/Layers/tiles.png" id="2_dhtsg"]
|
||||
|
||||
[node name="Background" type="Node2D"]
|
||||
|
||||
[node name="ParallaxBackground" parent="." instance=ExtResource("1_ofe3s")]
|
||||
|
||||
[node name="ParallaxBackground2" type="ParallaxBackground" parent="."]
|
||||
|
||||
[node name="ParallaxLayer" type="ParallaxLayer" parent="ParallaxBackground2"]
|
||||
|
||||
[node name="Tiles" type="Sprite2D" parent="ParallaxBackground2"]
|
||||
position = Vector2(575.5, 298.5)
|
||||
scale = Vector2(1.99479, 2.57721)
|
||||
texture = ExtResource("2_dhtsg")
|
||||
|
||||
[node name="Tiles2" type="Sprite2D" parent="ParallaxBackground2"]
|
||||
position = Vector2(575.5, 349)
|
||||
rotation = 3.14159
|
||||
scale = Vector2(1.99479, 2.57721)
|
||||
texture = ExtResource("2_dhtsg")
|
12
scenes/Game/Background/parallax_background.gd
Normal file
12
scenes/Game/Background/parallax_background.gd
Normal file
@ -0,0 +1,12 @@
|
||||
extends ParallaxBackground
|
||||
|
||||
const scrolling_seed = 100
|
||||
|
||||
# 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:
|
||||
#scroll_offset.x -= scrolling_seed * delta
|
14
scenes/Game/Background/parallax_background.tscn
Normal file
14
scenes/Game/Background/parallax_background.tscn
Normal file
@ -0,0 +1,14 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://5bcs7peqaotp"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/Game/Background/parallax_background.gd" id="1_8gnjn"]
|
||||
[ext_resource type="Texture2D" uid="uid://pevtm2psr3ap" path="res://assets/Sunny Land Collection Files/Sunny Land Collection Files/Assets/Environments/Forest of Illusion/Forest of Illusion Expansion Pack/Layers/back.png" id="1_hlk2w"]
|
||||
|
||||
[node name="ParallaxBackground" type="ParallaxBackground"]
|
||||
script = ExtResource("1_8gnjn")
|
||||
|
||||
[node name="ParallaxLayer" type="ParallaxLayer" parent="."]
|
||||
|
||||
[node name="Back" type="Sprite2D" parent="ParallaxLayer"]
|
||||
position = Vector2(575.5, 326.5)
|
||||
scale = Vector2(1.99479, 2.37868)
|
||||
texture = ExtResource("1_hlk2w")
|
11
scenes/Game/Background/static_body_2d.gd
Normal file
11
scenes/Game/Background/static_body_2d.gd
Normal file
@ -0,0 +1,11 @@
|
||||
extends StaticBody2D
|
||||
|
||||
|
||||
# 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:
|
||||
pass
|
48
scenes/Game/Enemy/enemy.gd
Normal file
48
scenes/Game/Enemy/enemy.gd
Normal file
@ -0,0 +1,48 @@
|
||||
extends CharacterBody2D
|
||||
signal hurt
|
||||
|
||||
@onready var player: CharacterBody2D = $"../../Player"
|
||||
@onready var timer: Timer = $Deathcounter
|
||||
|
||||
const SPEED = 150
|
||||
var inarea = false
|
||||
var alive = true
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
velocity.y += get_gravity().y * delta
|
||||
if inarea and alive:
|
||||
if player.global_position.x < self.global_position.x:
|
||||
get_node("AnimatedSprite2D").flip_h = true
|
||||
velocity.x -= SPEED * delta
|
||||
elif player.global_position.x > self.global_position.x:
|
||||
get_node("AnimatedSprite2D").flip_h = false
|
||||
velocity.x += SPEED * delta
|
||||
else:
|
||||
velocity.x = 0
|
||||
move_and_slide()
|
||||
|
||||
|
||||
|
||||
func _on_player_detection_body_entered(body: Node2D) -> void:
|
||||
if body.name == "Player":
|
||||
inarea = true
|
||||
|
||||
|
||||
func _on_player_detection_body_exited(body: Node2D) -> void:
|
||||
if body.name == "Player":
|
||||
inarea = false
|
||||
|
||||
|
||||
func _on_killingzone_body_entered(body: Node2D) -> void:
|
||||
if body.name == "Player":
|
||||
if player.global_position.y < self.global_position.y - 10 :
|
||||
get_node("AnimatedSprite2D").play("death")
|
||||
alive = false
|
||||
timer.start()
|
||||
elif alive:
|
||||
print("HURT")
|
||||
hurt.emit()
|
||||
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
queue_free()
|
147
scenes/Game/Enemy/enemy.tscn
Normal file
147
scenes/Game/Enemy/enemy.tscn
Normal file
@ -0,0 +1,147 @@
|
||||
[gd_scene load_steps=20 format=3 uid="uid://cwwrv2mwnu2q3"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://dqcyw3f15vsiq" path="res://assets/Sunny Land Collection Files/Sunny Land Collection Files/Assets/Characters/Players/Fiery Imp/hurt/hurt-sheet.png" id="1_t1n78"]
|
||||
[ext_resource type="Script" path="res://scenes/Game/Enemy/enemy.gd" id="1_xbhdf"]
|
||||
[ext_resource type="Texture2D" uid="uid://duhulhqkla6ar" path="res://assets/Sunny Land Collection Files/Sunny Land Collection Files/Assets/Characters/Players/Fiery Imp/idle/idle-preview.png" id="2_bhei3"]
|
||||
[ext_resource type="Texture2D" uid="uid://15wural1fsr6" path="res://assets/Sunny Land Collection Files/Sunny Land Collection Files/Assets/Characters/Players/Fiery Imp/jump/jump-preview.png" id="3_omigw"]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_24tgy"]
|
||||
radius = 8.0
|
||||
height = 26.0
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_jmn8m"]
|
||||
atlas = ExtResource("1_t1n78")
|
||||
region = Rect2(0, 0, 51, 45)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_168ap"]
|
||||
atlas = ExtResource("1_t1n78")
|
||||
region = Rect2(51, 0, 51, 45)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_q0wcd"]
|
||||
atlas = ExtResource("2_bhei3")
|
||||
region = Rect2(0, 0, 51, 45)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_5djji"]
|
||||
atlas = ExtResource("2_bhei3")
|
||||
region = Rect2(51, 0, 51, 45)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_v7g0l"]
|
||||
atlas = ExtResource("2_bhei3")
|
||||
region = Rect2(102, 0, 51, 45)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_pl311"]
|
||||
atlas = ExtResource("2_bhei3")
|
||||
region = Rect2(153, 0, 51, 45)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_neu2a"]
|
||||
atlas = ExtResource("3_omigw")
|
||||
region = Rect2(0, 0, 51, 45)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fm5fc"]
|
||||
atlas = ExtResource("3_omigw")
|
||||
region = Rect2(51, 0, 51, 45)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_tnvti"]
|
||||
atlas = ExtResource("3_omigw")
|
||||
region = Rect2(102, 0, 51, 45)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_mmuno"]
|
||||
atlas = ExtResource("3_omigw")
|
||||
region = Rect2(153, 0, 51, 45)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_lh0nl"]
|
||||
atlas = ExtResource("3_omigw")
|
||||
region = Rect2(204, 0, 51, 45)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_hpwl4"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_jmn8m")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_168ap")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"death",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_q0wcd")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_5djji")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_v7g0l")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_pl311")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"idle",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_neu2a")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_fm5fc")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_tnvti")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_mmuno")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_lh0nl")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"jump",
|
||||
"speed": 5.0
|
||||
}]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_5ntll"]
|
||||
radius = 156.003
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_o6lk6"]
|
||||
height = 34.0
|
||||
|
||||
[node name="enemy" type="CharacterBody2D"]
|
||||
script = ExtResource("1_xbhdf")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(0, -13)
|
||||
shape = SubResource("CapsuleShape2D_24tgy")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
position = Vector2(0, -23)
|
||||
sprite_frames = SubResource("SpriteFrames_hpwl4")
|
||||
animation = &"death"
|
||||
autoplay = "idle"
|
||||
frame_progress = 0.760876
|
||||
|
||||
[node name="PlayerDetection" type="Area2D" parent="."]
|
||||
visible = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="PlayerDetection"]
|
||||
position = Vector2(0, -10)
|
||||
shape = SubResource("CircleShape2D_5ntll")
|
||||
|
||||
[node name="killingzone" type="Area2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="killingzone"]
|
||||
position = Vector2(0, -12)
|
||||
shape = SubResource("CapsuleShape2D_o6lk6")
|
||||
debug_color = Color(0.987816, 0.0454308, 0.255515, 0.42)
|
||||
|
||||
[node name="Deathcounter" type="Timer" parent="."]
|
||||
wait_time = 0.6
|
||||
|
||||
[connection signal="body_entered" from="PlayerDetection" to="." method="_on_player_detection_body_entered"]
|
||||
[connection signal="body_exited" from="PlayerDetection" to="." method="_on_player_detection_body_exited"]
|
||||
[connection signal="body_entered" from="killingzone" to="." method="_on_killingzone_body_entered"]
|
||||
[connection signal="timeout" from="Deathcounter" to="." method="_on_timer_timeout"]
|
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")
|
11
scenes/Game/floor.gd
Normal file
11
scenes/Game/floor.gd
Normal file
@ -0,0 +1,11 @@
|
||||
extends CollisionShape2D
|
||||
|
||||
|
||||
# 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:
|
||||
pass
|
178
scenes/Game/world.tscn
Normal file
178
scenes/Game/world.tscn
Normal file
File diff suppressed because one or more lines are too long
12
scenes/Main/main.gd
Normal file
12
scenes/Main/main.gd
Normal file
@ -0,0 +1,12 @@
|
||||
extends Node2D
|
||||
|
||||
|
||||
|
||||
func _on_quit_pressed() -> void:
|
||||
get_tree().quit()
|
||||
|
||||
|
||||
|
||||
func _on_play_pressed() -> void:
|
||||
get_tree().change_scene_to_file("res://scenes/Game/world.tscn")
|
||||
|
36
scenes/Main/main.tscn
Normal file
36
scenes/Main/main.tscn
Normal file
@ -0,0 +1,36 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://dj6mfxvovjlr8"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/Main/main.gd" id="1_yctla"]
|
||||
[ext_resource type="Texture2D" uid="uid://dh0b1ghx4jn8s" path="res://assets/Sunny Land Collection Files/Sunny Land Collection Files/Assets/Environments/Colorful Environment/Preview.png" id="2_0hl46"]
|
||||
|
||||
[node name="Main" type="Node2D"]
|
||||
script = ExtResource("1_yctla")
|
||||
|
||||
[node name="ParallaxBackground" type="ParallaxBackground" parent="."]
|
||||
|
||||
[node name="Preview" type="Sprite2D" parent="ParallaxBackground"]
|
||||
position = Vector2(576.5, 323)
|
||||
scale = Vector2(4.48828, 3.65909)
|
||||
texture = ExtResource("2_0hl46")
|
||||
|
||||
[node name="Play" type="Button" parent="."]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 138.0
|
||||
offset_top = 183.0
|
||||
offset_right = 356.0
|
||||
offset_bottom = 282.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
text = "Play"
|
||||
|
||||
[node name="Quit" type="Button" parent="."]
|
||||
offset_left = 790.0
|
||||
offset_top = 444.0
|
||||
offset_right = 1026.0
|
||||
offset_bottom = 559.0
|
||||
text = "Quit"
|
||||
|
||||
[connection signal="pressed" from="Play" to="." method="_on_play_pressed"]
|
||||
[connection signal="pressed" from="Quit" to="." method="_on_quit_pressed"]
|
Reference in New Issue
Block a user