diff --git a/Assets/Traps/Mine/49.png b/Assets/Traps/Mine/49.png new file mode 100644 index 0000000..d0865b9 Binary files /dev/null and b/Assets/Traps/Mine/49.png differ diff --git a/Assets/Traps/Mine/49.png.import b/Assets/Traps/Mine/49.png.import new file mode 100644 index 0000000..69fd500 --- /dev/null +++ b/Assets/Traps/Mine/49.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dn22pudsmyrrg" +path="res://.godot/imported/49.png-9f286fae1b269b6439fe04a6433109bb.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Traps/Mine/49.png" +dest_files=["res://.godot/imported/49.png-9f286fae1b269b6439fe04a6433109bb.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 diff --git a/Assets/Traps/Mine/54.png b/Assets/Traps/Mine/54.png new file mode 100644 index 0000000..e565662 Binary files /dev/null and b/Assets/Traps/Mine/54.png differ diff --git a/Assets/Traps/Mine/54.png.import b/Assets/Traps/Mine/54.png.import new file mode 100644 index 0000000..d28a943 --- /dev/null +++ b/Assets/Traps/Mine/54.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://sb3dotm5napj" +path="res://.godot/imported/54.png-c39b6232e9a5800056e940740f3c68c8.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Traps/Mine/54.png" +dest_files=["res://.godot/imported/54.png-c39b6232e9a5800056e940740f3c68c8.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 diff --git a/Assets/Traps/Mine/55.png b/Assets/Traps/Mine/55.png new file mode 100644 index 0000000..e8de983 Binary files /dev/null and b/Assets/Traps/Mine/55.png differ diff --git a/Assets/Traps/Mine/55.png.import b/Assets/Traps/Mine/55.png.import new file mode 100644 index 0000000..cbb943f --- /dev/null +++ b/Assets/Traps/Mine/55.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://by0c26bla5hce" +path="res://.godot/imported/55.png-8fa0ef2c7e91afba070877ff7f61c4f4.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Traps/Mine/55.png" +dest_files=["res://.godot/imported/55.png-8fa0ef2c7e91afba070877ff7f61c4f4.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 diff --git a/Assets/Traps/Mine/56.png b/Assets/Traps/Mine/56.png new file mode 100644 index 0000000..9ae9188 Binary files /dev/null and b/Assets/Traps/Mine/56.png differ diff --git a/Assets/Traps/Mine/56.png.import b/Assets/Traps/Mine/56.png.import new file mode 100644 index 0000000..701f6b5 --- /dev/null +++ b/Assets/Traps/Mine/56.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cspjuelhbbavu" +path="res://.godot/imported/56.png-9cad383dff8247b0648b1c73f3490744.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Traps/Mine/56.png" +dest_files=["res://.godot/imported/56.png-9cad383dff8247b0648b1c73f3490744.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 diff --git a/Game/Maps/map_1.gd b/Game/Maps/map_1.gd index 28b8620..75a12a3 100644 --- a/Game/Maps/map_1.gd +++ b/Game/Maps/map_1.gd @@ -8,7 +8,7 @@ const COBOLD = preload("res://Game/Mobs/cobold.tscn") const enemies = [FORKMAN, COBOLD, ORK] -var lives = 20 +var lives = 2 func _ready() -> void: get_node("SidePanel").Update_Lives(lives) @@ -28,5 +28,12 @@ func decrease_life(damage) -> void: lives -= damage get_node("SidePanel").Update_Lives(lives) if lives == 0: - print("DEAD") + game_over() + +func game_over()-> void: + get_node("Timer").stop() + var enemy = get_node("Path2D").get_children() + for i in enemy: + i.get_children()[0].set_process(false) + i.get_children()[0].name diff --git a/Game/Mobs/enemy.gd b/Game/Mobs/enemy.gd index 6438609..2aa78f9 100644 --- a/Game/Mobs/enemy.gd +++ b/Game/Mobs/enemy.gd @@ -8,7 +8,9 @@ var damage = 0 var current_health = 0 var current_shield = 0 -var last_position: Vector2 = Vector2.ZERO # To store the previous position +var last_position: Vector2 = Vector2.ZERO # for previous position + +static var NAMES = ["Forkman", "Cobold", "Ork"] func _ready() -> void: last_position = get_parent().position @@ -119,5 +121,14 @@ func AnimatedSprite2D_animation_finished() -> void: func Collision_Handler(body: Node2D): if body.get_parent().name.contains("StickTrap"): - enemy_hurt(25) - get_node("CharacterBody2D/AnimatedSprite2D").play("hurt") + if not body.get_parent().get_if_moving_state(): + enemy_hurt(25) + get_node("CharacterBody2D/AnimatedSprite2D").play("hurt") + if body.get_parent().name.contains("Mine"): + if not body.get_parent().get_if_moving_state(): + var surrounding_enemies = body.get_node("Area2D").get_overlapping_bodies() + for i in surrounding_enemies: + if i. get_parent().name in NAMES: + enemy_hurt(100) + body.get_parent().Explode_Mine() + diff --git a/Game/Traps/mine.tscn b/Game/Traps/mine.tscn new file mode 100644 index 0000000..adf62cb --- /dev/null +++ b/Game/Traps/mine.tscn @@ -0,0 +1,58 @@ +[gd_scene load_steps=9 format=3 uid="uid://ctbmgsp8dfel3"] + +[ext_resource type="Script" uid="uid://3gn70ilm20tw" path="res://Game/Traps/traps.gd" id="1_6fgim"] +[ext_resource type="Texture2D" uid="uid://dn22pudsmyrrg" path="res://Assets/Traps/Mine/49.png" id="2_6m2fs"] +[ext_resource type="Texture2D" uid="uid://sb3dotm5napj" path="res://Assets/Traps/Mine/54.png" id="3_57sxm"] +[ext_resource type="Texture2D" uid="uid://by0c26bla5hce" path="res://Assets/Traps/Mine/55.png" id="4_a3dnl"] +[ext_resource type="Texture2D" uid="uid://cspjuelhbbavu" path="res://Assets/Traps/Mine/56.png" id="5_a1ih2"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_m1bdk"] +radius = 32.0 + +[sub_resource type="SpriteFrames" id="SpriteFrames_fp50i"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": ExtResource("3_57sxm") +}, { +"duration": 1.0, +"texture": ExtResource("4_a3dnl") +}, { +"duration": 1.0, +"texture": ExtResource("5_a1ih2") +}], +"loop": false, +"name": &"Explode", +"speed": 3.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": ExtResource("2_6m2fs") +}], +"loop": true, +"name": &"idle", +"speed": 0.0 +}] + +[sub_resource type="CircleShape2D" id="CircleShape2D_uiyu1"] + +[node name="Mine" type="Node2D"] +script = ExtResource("1_6fgim") + +[node name="CharacterBody2D" type="CharacterBody2D" parent="."] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D"] +scale = Vector2(0.6, 0.6) +shape = SubResource("CircleShape2D_m1bdk") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="CharacterBody2D"] +scale = Vector2(0.2, 0.207) +sprite_frames = SubResource("SpriteFrames_fp50i") +animation = &"Explode" +autoplay = "idle" + +[node name="Area2D" type="Area2D" parent="CharacterBody2D"] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D/Area2D"] +scale = Vector2(4, 4) +shape = SubResource("CircleShape2D_uiyu1") diff --git a/Game/Traps/traps.gd b/Game/Traps/traps.gd index c238a5f..2085c44 100644 --- a/Game/Traps/traps.gd +++ b/Game/Traps/traps.gd @@ -4,14 +4,25 @@ var follower = false func _ready() -> void: follower = true + if name.contains("Mine"): + get_node("CharacterBody2D/AnimatedSprite2D").connect("animation_finished", Callable(self, "Remove_Mine")) set_process_input(true) func _process(delta: float) -> void: if follower: position = get_viewport().get_mouse_position() +func get_if_moving_state(): + return follower func _input(event): if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed: if abs(position) <= get_viewport().get_mouse_position(): follower = false + +func Explode_Mine() -> void: + get_node("CharacterBody2D/AnimatedSprite2D").scale = Vector2(1,1) + get_node("CharacterBody2D/AnimatedSprite2D").play("Explode") + +func Remove_Mine() -> void: + queue_free() diff --git a/Game/sidepanel.gd b/Game/sidepanel.gd index eaa5131..a208411 100644 --- a/Game/sidepanel.gd +++ b/Game/sidepanel.gd @@ -5,8 +5,12 @@ extends Panel @onready var stickspawner: Button = $HBoxContainer4/HBoxContainer4/Button2 const STICK_TRAP = preload("res://Game/Traps/stick_trap.tscn") +@onready var minespawner: Button = $HBoxContainer4/HBoxContainer4/Button3 +const MINE = preload("res://Game/Traps/mine.tscn") + func _ready() -> void: stickspawner.connect("button_up", Spawn_Stick) + minespawner.connect("button_up", Spawn_Mine) func Update_Lives(lives) -> void: livelabel.text = "Lives: " + str(lives) @@ -15,3 +19,8 @@ func Spawn_Stick() -> void: var stick = STICK_TRAP.instantiate() stick.name = "StickTrap-" + str(randi()) get_parent().add_child(stick) + +func Spawn_Mine() -> void: + var mine = MINE.instantiate() + mine.name = "Mine-" + str(randi()) + get_parent().add_child(mine)