save game, player damage, player death, enemy damage, enemy death
This commit is contained in:
parent
68b998652c
commit
a5fa34bd4a
BIN
assets/graphics/player/death/Player Death 64x64.png
Normal file
BIN
assets/graphics/player/death/Player Death 64x64.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
34
assets/graphics/player/death/Player Death 64x64.png.import
Normal file
34
assets/graphics/player/death/Player Death 64x64.png.import
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://fjan00ormd84"
|
||||||
|
path="res://.godot/imported/Player Death 64x64.png-0c6ff54e7d9aad74b66dce47376541f8.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/graphics/player/death/Player Death 64x64.png"
|
||||||
|
dest_files=["res://.godot/imported/Player Death 64x64.png-0c6ff54e7d9aad74b66dce47376541f8.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
BIN
assets/graphics/player/hurt/Player Hurt 48x48.png
Normal file
BIN
assets/graphics/player/hurt/Player Hurt 48x48.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
34
assets/graphics/player/hurt/Player Hurt 48x48.png.import
Normal file
34
assets/graphics/player/hurt/Player Hurt 48x48.png.import
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://djicmvbecbmr8"
|
||||||
|
path="res://.godot/imported/Player Hurt 48x48.png-a720e51cb19103e76b22ab6c1b81302d.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/graphics/player/hurt/Player Hurt 48x48.png"
|
||||||
|
dest_files=["res://.godot/imported/Player Hurt 48x48.png-a720e51cb19103e76b22ab6c1b81302d.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
@ -39,3 +39,13 @@ shoot={
|
|||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":88,"key_label":0,"unicode":120,"location":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":88,"key_label":0,"unicode":120,"location":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
save={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
load={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":76,"key_label":0,"unicode":108,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
@ -20,4 +20,5 @@ rotation = 3.14159
|
|||||||
scale = Vector2(0.06, 0.06)
|
scale = Vector2(0.06, 0.06)
|
||||||
texture = ExtResource("2_y25gk")
|
texture = ExtResource("2_y25gk")
|
||||||
|
|
||||||
|
[connection signal="area_entered" from="." to="." method="_on_area_entered"]
|
||||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||||
|
@ -482,5 +482,8 @@ position = Vector2(630, 375)
|
|||||||
|
|
||||||
[node name="enemies" type="Node2D" parent="."]
|
[node name="enemies" type="Node2D" parent="."]
|
||||||
|
|
||||||
[node name="Slime" parent="enemies" instance=ExtResource("11_dinhu")]
|
[node name="Slime" parent="enemies" groups=["shootables"] instance=ExtResource("11_dinhu")]
|
||||||
position = Vector2(467, 343)
|
position = Vector2(467, 343)
|
||||||
|
|
||||||
|
[node name="Slime2" parent="enemies" groups=["shootables"] instance=ExtResource("11_dinhu")]
|
||||||
|
position = Vector2(586, 280)
|
||||||
|
@ -1,16 +1,74 @@
|
|||||||
[gd_scene load_steps=28 format=3 uid="uid://boqg1nyudmkh4"]
|
[gd_scene load_steps=44 format=3 uid="uid://boqg1nyudmkh4"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://b7rahgxxw1yuw" path="res://scripts/player.gd" id="1_3vyb7"]
|
[ext_resource type="Script" uid="uid://b7rahgxxw1yuw" path="res://scripts/player.gd" id="1_3vyb7"]
|
||||||
[ext_resource type="Texture2D" uid="uid://c3uwl6agc6dhb" path="res://assets/graphics/player/jump_fall/player jump 48x48.png" id="2_dqkch"]
|
[ext_resource type="Texture2D" uid="uid://c3uwl6agc6dhb" path="res://assets/graphics/player/jump_fall/player jump 48x48.png" id="2_dqkch"]
|
||||||
[ext_resource type="Texture2D" uid="uid://be0vnx023iw65" path="res://assets/graphics/player/idle/Player Idle 48x48.png" id="2_g2els"]
|
[ext_resource type="Texture2D" uid="uid://be0vnx023iw65" path="res://assets/graphics/player/idle/Player Idle 48x48.png" id="2_g2els"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://fjan00ormd84" path="res://assets/graphics/player/death/Player Death 64x64.png" id="2_tuyoq"]
|
||||||
[ext_resource type="Texture2D" uid="uid://dmmtik7twhga4" path="res://assets/graphics/player/run/player run 48x48.png" id="3_qhqgy"]
|
[ext_resource type="Texture2D" uid="uid://dmmtik7twhga4" path="res://assets/graphics/player/run/player run 48x48.png" id="3_qhqgy"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://djicmvbecbmr8" path="res://assets/graphics/player/hurt/Player Hurt 48x48.png" id="3_qlg0r"]
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_8cj0n"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_8cj0n"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_pf23h"]
|
||||||
|
atlas = ExtResource("2_tuyoq")
|
||||||
|
region = Rect2(0, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_dt7fs"]
|
||||||
|
atlas = ExtResource("2_tuyoq")
|
||||||
|
region = Rect2(48, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_wqfne"]
|
||||||
|
atlas = ExtResource("2_tuyoq")
|
||||||
|
region = Rect2(96, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_wnwbv"]
|
||||||
|
atlas = ExtResource("2_tuyoq")
|
||||||
|
region = Rect2(144, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_gl8cc"]
|
||||||
|
atlas = ExtResource("2_tuyoq")
|
||||||
|
region = Rect2(192, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_487ah"]
|
||||||
|
atlas = ExtResource("2_tuyoq")
|
||||||
|
region = Rect2(240, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_md1ol"]
|
||||||
|
atlas = ExtResource("2_tuyoq")
|
||||||
|
region = Rect2(288, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_bj30b"]
|
||||||
|
atlas = ExtResource("2_tuyoq")
|
||||||
|
region = Rect2(336, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_jc3p3"]
|
||||||
|
atlas = ExtResource("2_tuyoq")
|
||||||
|
region = Rect2(384, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_hax0n"]
|
||||||
|
atlas = ExtResource("2_tuyoq")
|
||||||
|
region = Rect2(432, 0, 48, 48)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_i4ail"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_i4ail"]
|
||||||
atlas = ExtResource("2_dqkch")
|
atlas = ExtResource("2_dqkch")
|
||||||
region = Rect2(96, 0, 48, 48)
|
region = Rect2(96, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_l71n6"]
|
||||||
|
atlas = ExtResource("3_qlg0r")
|
||||||
|
region = Rect2(0, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_ke2ow"]
|
||||||
|
atlas = ExtResource("3_qlg0r")
|
||||||
|
region = Rect2(48, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_ujl30"]
|
||||||
|
atlas = ExtResource("3_qlg0r")
|
||||||
|
region = Rect2(96, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_31cv2"]
|
||||||
|
atlas = ExtResource("3_qlg0r")
|
||||||
|
region = Rect2(144, 0, 48, 48)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qhqgy"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_qhqgy"]
|
||||||
atlas = ExtResource("2_g2els")
|
atlas = ExtResource("2_g2els")
|
||||||
region = Rect2(0, 0, 48, 48)
|
region = Rect2(0, 0, 48, 48)
|
||||||
@ -95,6 +153,41 @@ region = Rect2(336, 0, 48, 48)
|
|||||||
animations = [{
|
animations = [{
|
||||||
"frames": [{
|
"frames": [{
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_pf23h")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_dt7fs")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_wqfne")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_wnwbv")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_gl8cc")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_487ah")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_md1ol")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_bj30b")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_jc3p3")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_hax0n")
|
||||||
|
}],
|
||||||
|
"loop": false,
|
||||||
|
"name": &"death",
|
||||||
|
"speed": 12.0
|
||||||
|
}, {
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
"texture": SubResource("AtlasTexture_i4ail")
|
"texture": SubResource("AtlasTexture_i4ail")
|
||||||
}],
|
}],
|
||||||
"loop": false,
|
"loop": false,
|
||||||
@ -103,6 +196,23 @@ animations = [{
|
|||||||
}, {
|
}, {
|
||||||
"frames": [{
|
"frames": [{
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_l71n6")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_ke2ow")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_ujl30")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_31cv2")
|
||||||
|
}],
|
||||||
|
"loop": false,
|
||||||
|
"name": &"hurt",
|
||||||
|
"speed": 12.0
|
||||||
|
}, {
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
"texture": SubResource("AtlasTexture_qhqgy")
|
"texture": SubResource("AtlasTexture_qhqgy")
|
||||||
}, {
|
}, {
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
@ -205,7 +315,7 @@ one_shot = true
|
|||||||
texture_filter = 1
|
texture_filter = 1
|
||||||
position = Vector2(0, -7)
|
position = Vector2(0, -7)
|
||||||
sprite_frames = SubResource("SpriteFrames_jej6c")
|
sprite_frames = SubResource("SpriteFrames_jej6c")
|
||||||
animation = &"fall"
|
animation = &"death"
|
||||||
autoplay = "idle"
|
autoplay = "idle"
|
||||||
|
|
||||||
[node name="Camera2D" type="Camera2D" parent="."]
|
[node name="Camera2D" type="Camera2D" parent="."]
|
||||||
|
@ -1,10 +1,22 @@
|
|||||||
[gd_scene load_steps=9 format=3 uid="uid://dpltbyp8ku2mi"]
|
[gd_scene load_steps=12 format=3 uid="uid://dpltbyp8ku2mi"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://cuaxw7eh73a1i" path="res://scripts/slime.gd" id="1_p2gj0"]
|
[ext_resource type="Script" uid="uid://cuaxw7eh73a1i" path="res://scripts/slime.gd" id="1_p2gj0"]
|
||||||
[ext_resource type="Texture2D" uid="uid://dwwlva8pi3da2" path="res://assets/graphics/enemies/slime_purple (1).png" id="2_n6pvg"]
|
[ext_resource type="Texture2D" uid="uid://dwwlva8pi3da2" path="res://assets/graphics/enemies/slime_purple (1).png" id="2_n6pvg"]
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_pjw23"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_pjw23"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_p2gj0"]
|
||||||
|
atlas = ExtResource("2_n6pvg")
|
||||||
|
region = Rect2(24, 48, 24, 24)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_n6pvg"]
|
||||||
|
atlas = ExtResource("2_n6pvg")
|
||||||
|
region = Rect2(48, 48, 24, 24)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_pjw23"]
|
||||||
|
atlas = ExtResource("2_n6pvg")
|
||||||
|
region = Rect2(72, 48, 24, 24)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_2npkn"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_2npkn"]
|
||||||
atlas = ExtResource("2_n6pvg")
|
atlas = ExtResource("2_n6pvg")
|
||||||
region = Rect2(0, 24, 24, 24)
|
region = Rect2(0, 24, 24, 24)
|
||||||
@ -25,6 +37,20 @@ region = Rect2(72, 24, 24, 24)
|
|||||||
animations = [{
|
animations = [{
|
||||||
"frames": [{
|
"frames": [{
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_p2gj0")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_n6pvg")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_pjw23")
|
||||||
|
}],
|
||||||
|
"loop": false,
|
||||||
|
"name": &"hurt",
|
||||||
|
"speed": 10.0
|
||||||
|
}, {
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
"texture": SubResource("AtlasTexture_2npkn")
|
"texture": SubResource("AtlasTexture_2npkn")
|
||||||
}, {
|
}, {
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
@ -37,7 +63,7 @@ animations = [{
|
|||||||
"texture": SubResource("AtlasTexture_v5wyi")
|
"texture": SubResource("AtlasTexture_v5wyi")
|
||||||
}],
|
}],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
"name": &"default",
|
"name": &"idle",
|
||||||
"speed": 12.0
|
"speed": 12.0
|
||||||
}]
|
}]
|
||||||
|
|
||||||
@ -53,8 +79,8 @@ debug_color = Color(0.932998, 0.222862, 0.34393, 0.42)
|
|||||||
texture_filter = 1
|
texture_filter = 1
|
||||||
position = Vector2(0, -3)
|
position = Vector2(0, -3)
|
||||||
sprite_frames = SubResource("SpriteFrames_0l8pv")
|
sprite_frames = SubResource("SpriteFrames_0l8pv")
|
||||||
autoplay = "default"
|
animation = &"idle"
|
||||||
frame_progress = 0.665587
|
autoplay = "idle"
|
||||||
|
|
||||||
[node name="RightCast" type="RayCast2D" parent="."]
|
[node name="RightCast" type="RayCast2D" parent="."]
|
||||||
target_position = Vector2(13, 0)
|
target_position = Vector2(13, 0)
|
||||||
@ -71,3 +97,4 @@ position = Vector2(8, 0)
|
|||||||
target_position = Vector2(0, 10)
|
target_position = Vector2(0, 10)
|
||||||
|
|
||||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||||
|
[connection signal="animation_finished" from="SlimeGraphic" to="." method="_on_slime_graphic_animation_finished"]
|
||||||
|
@ -21,3 +21,10 @@ func _on_body_entered(body: Node2D) -> void:
|
|||||||
if body.is_in_group("shootables"):
|
if body.is_in_group("shootables"):
|
||||||
print("This is shootable")
|
print("This is shootable")
|
||||||
bulletDamageSignal.emit(body, self)
|
bulletDamageSignal.emit(body, self)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_area_entered(area: Area2D) -> void:
|
||||||
|
print("Bullet hitting")
|
||||||
|
if area.is_in_group("shootables"):
|
||||||
|
print("This is shootable")
|
||||||
|
bulletDamageSignal.emit(area, self)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
signal playerDamage
|
signal playerDamageSignal(health, maxhealth)
|
||||||
|
signal playerDeathSignal
|
||||||
signal destroySignal(body)
|
signal destroySignal(body)
|
||||||
signal levelChangeSignal(level)
|
signal levelChangeSignal(level)
|
||||||
|
|
||||||
@ -16,6 +17,11 @@ var enemy:CharacterStats
|
|||||||
var player:CharacterStats
|
var player:CharacterStats
|
||||||
var playerCurrentHealth:int
|
var playerCurrentHealth:int
|
||||||
|
|
||||||
|
var enemiesDict = {}
|
||||||
|
|
||||||
|
var saveObject = {}
|
||||||
|
var loadIntent = false
|
||||||
|
|
||||||
# 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() -> void:
|
func _ready() -> void:
|
||||||
enemy = load("res://scripts/rscs/slimeStats.tres")
|
enemy = load("res://scripts/rscs/slimeStats.tres")
|
||||||
@ -29,7 +35,20 @@ func _ready() -> void:
|
|||||||
timer.start()
|
timer.start()
|
||||||
|
|
||||||
func reset():
|
func reset():
|
||||||
|
enemiesDict.clear()
|
||||||
timeAvailable = timers[currentLevel]
|
timeAvailable = timers[currentLevel]
|
||||||
|
playerCurrentHealth = player.max_health
|
||||||
|
|
||||||
|
if loadIntent:
|
||||||
|
var saved_game:SavedGame = load("res://scripts/rscs/gameSaveStats.tres")
|
||||||
|
saveObject = saved_game.gameData
|
||||||
|
playerCurrentHealth = saveObject["PlayerHealth"]
|
||||||
|
timeAvailable = saveObject["TimeAvailable"]
|
||||||
|
loadIntent = false
|
||||||
|
return saveObject
|
||||||
|
|
||||||
|
return{}
|
||||||
|
|
||||||
|
|
||||||
func secondCounter():
|
func secondCounter():
|
||||||
timeAvailable -=1
|
timeAvailable -=1
|
||||||
@ -38,9 +57,12 @@ func secondCounter():
|
|||||||
print("You lose")
|
print("You lose")
|
||||||
levelChangeSignal.emit(levels[currentLevel])
|
levelChangeSignal.emit(levels[currentLevel])
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
pass
|
if Input.is_action_just_pressed("save"):
|
||||||
|
saveGame()
|
||||||
|
if Input.is_action_just_pressed("load"):
|
||||||
|
loadGame()
|
||||||
|
|
||||||
|
|
||||||
func _on_trigger(effect: Variant, body: Variant) -> void:
|
func _on_trigger(effect: Variant, body: Variant) -> void:
|
||||||
@ -49,13 +71,24 @@ func _on_trigger(effect: Variant, body: Variant) -> void:
|
|||||||
"player_hurt":
|
"player_hurt":
|
||||||
if body is Player:
|
if body is Player:
|
||||||
print("hurt the player")
|
print("hurt the player")
|
||||||
playerDamage.emit()
|
#playerDamage.emit()
|
||||||
#if not body is Player:
|
#if not body is Player:
|
||||||
# body.queue_free()
|
# body.queue_free()
|
||||||
|
|
||||||
func bulletDamage(body, bullet):
|
func bulletDamage(body, bullet):
|
||||||
print("GC know about bullet hit")
|
print("GC know about bullet hit")
|
||||||
body.queue_free()
|
if body is Slime:
|
||||||
|
#give damage to this individual enemy
|
||||||
|
enemiesDict[body]["health"] -= player.rangeDamage
|
||||||
|
if enemiesDict[body]["health"] <=0:
|
||||||
|
print("enemy is dead")
|
||||||
|
removeEnemyFromLevel(body)
|
||||||
|
destroySignal.emit(body)
|
||||||
|
else:
|
||||||
|
print("enemy is damaged")
|
||||||
|
body.handle_damage()
|
||||||
|
func removeEnemyFromLevel(body)->void:
|
||||||
|
enemiesDict.erase(body)
|
||||||
|
|
||||||
func coinCollected(body, coin):
|
func coinCollected(body, coin):
|
||||||
print("GC knows coin collected")
|
print("GC knows coin collected")
|
||||||
@ -71,9 +104,50 @@ func totalCoinCount(count):
|
|||||||
|
|
||||||
func playerAttacked(body, slime):
|
func playerAttacked(body, slime):
|
||||||
print("GC knows slime attack")
|
print("GC knows slime attack")
|
||||||
print("Damge : "+str(enemy.meleeDamage) )
|
print("Damge : "+str(enemiesDict[slime]["damage"]) )
|
||||||
print("Player health : "+str(playerCurrentHealth))
|
print("Player health : "+str(playerCurrentHealth))
|
||||||
playerCurrentHealth -= enemy.meleeDamage
|
playerCurrentHealth -= enemiesDict[slime]["damage"]
|
||||||
if playerCurrentHealth <=0:
|
if playerCurrentHealth <=0:
|
||||||
print("YOU DEAD")
|
print("YOU DEAD")
|
||||||
|
playerDeathSignal.emit()
|
||||||
|
else:
|
||||||
|
print("taking damage")
|
||||||
|
playerDamageSignal.emit(playerCurrentHealth, player.max_health)
|
||||||
|
|
||||||
|
func deathComplete()->void:
|
||||||
|
levelChangeSignal.emit(levels[currentLevel])
|
||||||
|
|
||||||
|
func addEnemyToLevel(slime)->void:
|
||||||
|
var randHealth:int = randi() % 20
|
||||||
|
var randDamage:int = randi() % 10
|
||||||
|
var enemyStat = {
|
||||||
|
"health": enemy.health + randHealth,
|
||||||
|
"damage": enemy.meleeDamage + randDamage
|
||||||
|
}
|
||||||
|
enemiesDict[slime] = enemyStat
|
||||||
|
func saveGame()->void:
|
||||||
|
saveObject["enemies"]={}
|
||||||
|
var index = 0
|
||||||
|
|
||||||
|
#create an object with all critical game data
|
||||||
|
print("Game Level "+str(currentLevel) )
|
||||||
|
print("Time Remaining "+str(timeAvailable))
|
||||||
|
print("Player Health "+str(playerCurrentHealth))
|
||||||
|
# bad guy stuff....
|
||||||
|
for key in enemiesDict:
|
||||||
|
var tempObj = {}
|
||||||
|
tempObj["health"]=enemiesDict[key]["health"]
|
||||||
|
tempObj["damage"]=enemiesDict[key]["damage"]
|
||||||
|
tempObj["global_position"] = key.global_position
|
||||||
|
saveObject["enemies"]["slime"+str(index)]=tempObj
|
||||||
|
index +=1
|
||||||
|
saveObject["GameLevel"] = currentLevel
|
||||||
|
saveObject["TimeAvailable"] = timeAvailable
|
||||||
|
saveObject["PlayerHealth"] = playerCurrentHealth
|
||||||
|
var saved_game:SavedGame = SavedGame.new()
|
||||||
|
saved_game.gameData = saveObject
|
||||||
|
ResourceSaver.save(saved_game, "res://scripts/rscs/gameSaveStats.tres")
|
||||||
|
|
||||||
|
func loadGame()->void:
|
||||||
|
loadIntent = true
|
||||||
|
levelChangeSignal.emit(levels[saveObject["GameLevel"]])
|
||||||
|
@ -15,14 +15,17 @@ var upJump:bool = false
|
|||||||
var direction
|
var direction
|
||||||
enum FaceDirection{LEFT, RIGHT}
|
enum FaceDirection{LEFT, RIGHT}
|
||||||
var facing:FaceDirection = FaceDirection.RIGHT
|
var facing:FaceDirection = FaceDirection.RIGHT
|
||||||
enum State{IDLE, RUN,JUMP,FALLING}
|
enum State{IDLE, RUN,JUMP,FALLING, HURT, DEATH}
|
||||||
var current_state:State = State.IDLE
|
var current_state:State = State.IDLE
|
||||||
|
|
||||||
var pushTarget
|
var pushTarget
|
||||||
var pushEnabled := false
|
var pushEnabled := false
|
||||||
|
|
||||||
|
signal playerDeathCompleteSignal
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
# Add the gravity.
|
# Add the gravity.
|
||||||
|
if current_state != State.HURT and current_state != State.DEATH:
|
||||||
handle_input()
|
handle_input()
|
||||||
handle_movement(delta)
|
handle_movement(delta)
|
||||||
handle_states()
|
handle_states()
|
||||||
@ -30,6 +33,15 @@ func _physics_process(delta: float) -> void:
|
|||||||
move_and_slide()
|
move_and_slide()
|
||||||
handle_collisions()
|
handle_collisions()
|
||||||
|
|
||||||
|
func handle_damage(health, maxhealth)->void:
|
||||||
|
print("player takes damage")
|
||||||
|
current_state = State.HURT
|
||||||
|
|
||||||
|
func handle_death()->void:
|
||||||
|
print("player is dead")
|
||||||
|
current_state = State.DEATH
|
||||||
|
|
||||||
|
|
||||||
func handle_states() -> void:
|
func handle_states() -> void:
|
||||||
match current_state:
|
match current_state:
|
||||||
State.IDLE when velocity.x !=0:
|
State.IDLE when velocity.x !=0:
|
||||||
@ -60,6 +72,10 @@ func handle_animation() -> void:
|
|||||||
State.JUMP:
|
State.JUMP:
|
||||||
if upJump:
|
if upJump:
|
||||||
player_graphic.play("jump")
|
player_graphic.play("jump")
|
||||||
|
State.HURT:
|
||||||
|
player_graphic.play("hurt")
|
||||||
|
State.DEATH:
|
||||||
|
player_graphic.play("death")
|
||||||
|
|
||||||
func handle_movement(delta:float) -> void:
|
func handle_movement(delta:float) -> void:
|
||||||
if direction == 0:
|
if direction == 0:
|
||||||
@ -131,3 +147,7 @@ func _on_animation_finished() -> void:
|
|||||||
match current_state:
|
match current_state:
|
||||||
State.JUMP:
|
State.JUMP:
|
||||||
upJump = false
|
upJump = false
|
||||||
|
State.HURT:
|
||||||
|
current_state = State.IDLE
|
||||||
|
State.DEATH:
|
||||||
|
playerDeathCompleteSignal.emit()
|
||||||
|
23
scripts/rscs/gameSaveStats.tres
Normal file
23
scripts/rscs/gameSaveStats.tres
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
[gd_resource type="Resource" script_class="SavedGame" load_steps=2 format=3 uid="uid://cib08qg83a6o6"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://c3kd5uh5y8ml1" path="res://scripts/rscs/savedgame.gd" id="1_v2d26"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_v2d26")
|
||||||
|
gameData = {
|
||||||
|
"GameLevel": 0,
|
||||||
|
"PlayerHealth": 100,
|
||||||
|
"TimeAvailable": 7,
|
||||||
|
"enemies": {
|
||||||
|
"slime0": {
|
||||||
|
"damage": 33,
|
||||||
|
"global_position": Vector2(489.403, 343),
|
||||||
|
"health": 66
|
||||||
|
},
|
||||||
|
"slime1": {
|
||||||
|
"damage": 25,
|
||||||
|
"global_position": Vector2(626.901, 280),
|
||||||
|
"health": 61
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,5 +8,5 @@ health = 100
|
|||||||
max_health = 100
|
max_health = 100
|
||||||
starting_health = 100
|
starting_health = 100
|
||||||
meleeDamage = 10
|
meleeDamage = 10
|
||||||
rangeDamage = 0
|
rangeDamage = 30
|
||||||
metadata/_custom_type_script = "uid://r408skwtvisy"
|
metadata/_custom_type_script = "uid://r408skwtvisy"
|
||||||
|
3
scripts/rscs/savedgame.gd
Normal file
3
scripts/rscs/savedgame.gd
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
class_name SavedGame extends Resource
|
||||||
|
|
||||||
|
@export var gameData:Dictionary
|
1
scripts/rscs/savedgame.gd.uid
Normal file
1
scripts/rscs/savedgame.gd.uid
Normal file
@ -0,0 +1 @@
|
|||||||
|
uid://c3kd5uh5y8ml1
|
@ -4,9 +4,9 @@
|
|||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("1_ppipo")
|
script = ExtResource("1_ppipo")
|
||||||
health = 100
|
health = 50
|
||||||
max_health = 100
|
max_health = 50
|
||||||
starting_health = 100
|
starting_health = 50
|
||||||
meleeDamage = 25
|
meleeDamage = 25
|
||||||
rangeDamage = 0
|
rangeDamage = 0
|
||||||
metadata/_custom_type_script = "uid://r408skwtvisy"
|
metadata/_custom_type_script = "uid://r408skwtvisy"
|
||||||
|
@ -2,15 +2,21 @@ class_name SceneManager extends Node2D
|
|||||||
var bulletArray =[]
|
var bulletArray =[]
|
||||||
var totalAllowedBullets = 7
|
var totalAllowedBullets = 7
|
||||||
var bullet = preload("res://scenes/bullet.tscn")
|
var bullet = preload("res://scenes/bullet.tscn")
|
||||||
|
var slime=preload("res://scenes/slime.tscn")
|
||||||
|
|
||||||
@onready var triggers: Node2D = $"../triggers"
|
@onready var triggers: Node2D = $"../triggers"
|
||||||
@onready var coins: Node2D = $"../coins"
|
@onready var coins: Node2D = $"../coins"
|
||||||
@onready var enemies: Node2D = $"../enemies"
|
@onready var enemies: Node2D = $"../enemies"
|
||||||
|
@onready var player: Player = $"../Player"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 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() -> void:
|
func _ready() -> void:
|
||||||
Gamecontroller.reset()
|
var loadObject = Gamecontroller.reset()
|
||||||
|
print("LOAD OBJECT:::::")
|
||||||
|
print(loadObject)
|
||||||
|
loadSceneInfo(loadObject)
|
||||||
|
|
||||||
if triggers:
|
if triggers:
|
||||||
for obj in triggers.get_children():
|
for obj in triggers.get_children():
|
||||||
@ -24,12 +30,18 @@ func _ready() -> void:
|
|||||||
|
|
||||||
Gamecontroller.destroySignal.connect(destroy)
|
Gamecontroller.destroySignal.connect(destroy)
|
||||||
Gamecontroller.levelChangeSignal.connect(changeScene)
|
Gamecontroller.levelChangeSignal.connect(changeScene)
|
||||||
|
Gamecontroller.playerDamageSignal.connect(player.handle_damage)
|
||||||
|
Gamecontroller.playerDeathSignal.connect(player.handle_death)
|
||||||
|
|
||||||
|
player.playerDeathCompleteSignal.connect(Gamecontroller.deathComplete)
|
||||||
|
|
||||||
|
|
||||||
func updateEnemies():
|
func updateEnemies():
|
||||||
for obj in enemies.get_children():
|
for obj in enemies.get_children():
|
||||||
if obj is Slime:
|
if obj is Slime:
|
||||||
if not obj.playerDamageSignal.is_connected(Gamecontroller.playerAttacked):
|
if not obj.playerDamageSignal.is_connected(Gamecontroller.playerAttacked):
|
||||||
obj.playerDamageSignal.connect(Gamecontroller.playerAttacked)
|
obj.playerDamageSignal.connect(Gamecontroller.playerAttacked)
|
||||||
|
Gamecontroller.addEnemyToLevel(obj)
|
||||||
|
|
||||||
|
|
||||||
func updateCoins():
|
func updateCoins():
|
||||||
@ -72,3 +84,22 @@ func destroy(body):
|
|||||||
body.queue_free()
|
body.queue_free()
|
||||||
func changeScene(level):
|
func changeScene(level):
|
||||||
get_tree().call_deferred("change_scene_to_file", level)
|
get_tree().call_deferred("change_scene_to_file", level)
|
||||||
|
func loadSceneInfo(loadObject)->void:
|
||||||
|
print("make the scene")
|
||||||
|
if loadObject.size()<1:
|
||||||
|
print("bailing out")
|
||||||
|
return
|
||||||
|
#remove current bad guys
|
||||||
|
if enemies:
|
||||||
|
for obj in enemies.get_children():
|
||||||
|
if obj is Slime:
|
||||||
|
obj.queue_free()
|
||||||
|
|
||||||
|
#build and place save game badguys
|
||||||
|
var enemiesList = loadObject["enemies"]
|
||||||
|
for key in enemiesList:
|
||||||
|
print(enemiesList[key])
|
||||||
|
# create a slime
|
||||||
|
var badguy = slime.instantiate()
|
||||||
|
enemies.add_child(badguy)
|
||||||
|
badguy.global_position = enemiesList[key]["global_position"]
|
||||||
|
@ -10,10 +10,22 @@ var direction = 1
|
|||||||
|
|
||||||
signal playerDamageSignal(body, slime)
|
signal playerDamageSignal(body, slime)
|
||||||
|
|
||||||
|
enum State{IDLE, HURT, DEATH}
|
||||||
|
var currentState = State.IDLE
|
||||||
|
|
||||||
|
|
||||||
# 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() -> void:
|
func _ready() -> void:
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
func updateAnimation()->void:
|
||||||
|
match currentState:
|
||||||
|
State.IDLE:
|
||||||
|
slime_graphic.play("idle")
|
||||||
|
State.HURT:
|
||||||
|
slime_graphic.play("hurt")
|
||||||
|
|
||||||
|
func handle_damage()->void:
|
||||||
|
currentState = State.HURT
|
||||||
|
|
||||||
# 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: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
@ -26,9 +38,15 @@ func _process(delta: float) -> void:
|
|||||||
slime_graphic.flip_h = false
|
slime_graphic.flip_h = false
|
||||||
|
|
||||||
position.x += direction * speed * delta
|
position.x += direction * speed * delta
|
||||||
|
updateAnimation()
|
||||||
|
|
||||||
func _on_body_entered(body: Node2D) -> void:
|
func _on_body_entered(body: Node2D) -> void:
|
||||||
if body is Player:
|
if body is Player:
|
||||||
print("Slime attack!")
|
print("Slime attack!")
|
||||||
playerDamageSignal.emit(body, self)
|
playerDamageSignal.emit(body, self)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_slime_graphic_animation_finished() -> void:
|
||||||
|
match currentState:
|
||||||
|
State.HURT:
|
||||||
|
currentState = State.IDLE
|
||||||
|
Loading…
Reference in New Issue
Block a user