This commit is contained in:
2024-10-27 18:43:35 +01:00
parent f1eec54972
commit e242f59c0b
5082 changed files with 66034 additions and 0 deletions

View 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()

View 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"]