From 8efed5d4d64a568ced79988d50d230d798b3df35 Mon Sep 17 00:00:00 2001 From: Victor Turgeon Date: Sun, 15 Jan 2023 14:15:51 -0500 Subject: [PATCH] fkl;dsnak;l gjmbsdfjlabgscajmg njl,.bfnelkjqbgmf --- Enemies/basic_enemy.gd | 13 ++++- Enemies/basic_enemy.tscn | 13 ++++- Levels/level.gd | 21 +++++++ Levels/level.tscn | 108 +++++++++++++++++++++++++++++++++++- OTHERS/door.tscn | 29 ++++++++++ PickableItems/basic_item.gd | 3 + Player/player.gd | 20 ++++++- Player/player.tscn | 13 +++++ Sprites/Door_1.png | Bin 0 -> 407 bytes Sprites/Door_1.png.import | 34 ++++++++++++ Sprites/HAHAHAs.png | Bin 0 -> 2131 bytes Sprites/HAHAHAs.png.import | 34 ++++++++++++ 12 files changed, 281 insertions(+), 7 deletions(-) create mode 100644 Levels/level.gd create mode 100644 OTHERS/door.tscn create mode 100644 Sprites/Door_1.png create mode 100644 Sprites/Door_1.png.import create mode 100644 Sprites/HAHAHAs.png create mode 100644 Sprites/HAHAHAs.png.import diff --git a/Enemies/basic_enemy.gd b/Enemies/basic_enemy.gd index c80c7f3..7ca114e 100644 --- a/Enemies/basic_enemy.gd +++ b/Enemies/basic_enemy.gd @@ -5,19 +5,21 @@ extends CharacterBody2D @export var FRICTION = 1500.0; @export var HP = 100; @export var DAMAGE = 10; -@export var COOLDOWN = 2; +@export var COOLDOWN = 1; @onready var raycast = $RayCast2D; @onready var cooldown_timer = $CooldownTimer; +@onready var sprite = $AnimatedSprite2D; var player = null; var is_on_cooldown = false; +var attacking = false; func _ready(): add_to_group("enemies"); func _physics_process(delta): - if player == null: + if player == null || !attacking: return var vec_to_player = player.global_position - global_position; @@ -43,6 +45,7 @@ func take_damage(damage): kill(); func kill(): + emit_signal("is_killed"); queue_free(); func set_player(p): @@ -50,3 +53,9 @@ func set_player(p): func _on_cooldown_timer_timeout(): is_on_cooldown = false; + +func _on_area_2d_body_entered(body): + if body.name == "Player": + attacking = true; + +signal is_killed() diff --git a/Enemies/basic_enemy.tscn b/Enemies/basic_enemy.tscn index f232147..8e55507 100644 --- a/Enemies/basic_enemy.tscn +++ b/Enemies/basic_enemy.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=5 format=3 uid="uid://c661br4lh30r8"] +[gd_scene load_steps=6 format=3 uid="uid://c661br4lh30r8"] [ext_resource type="Script" path="res://Enemies/basic_enemy.gd" id="1_5vi5k"] [ext_resource type="Texture2D" uid="uid://ds4uvvrcxoay1" path="res://Sprites/placeholder_enemy.png" id="1_o8nfm"] @@ -17,6 +17,9 @@ animations = [{ [sub_resource type="RectangleShape2D" id="RectangleShape2D_47nt3"] size = Vector2(41, 64) +[sub_resource type="CircleShape2D" id="CircleShape2D_237ox"] +radius = 390.185 + [node name="BasicEnemy" type="CharacterBody2D"] script = ExtResource("1_5vi5k") @@ -38,4 +41,12 @@ default_color = Color(1, 0, 0, 0.392157) [node name="CooldownTimer" type="Timer" parent="."] +[node name="Area2D" type="Area2D" parent="."] +collision_layer = 2 +collision_mask = 2 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] +shape = SubResource("CircleShape2D_237ox") + [connection signal="timeout" from="CooldownTimer" to="." method="_on_cooldown_timer_timeout"] +[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"] diff --git a/Levels/level.gd b/Levels/level.gd new file mode 100644 index 0000000..ce75911 --- /dev/null +++ b/Levels/level.gd @@ -0,0 +1,21 @@ +extends Node2D + +@onready var doors = $Doors; + +func _ready(): + pass + +func _process(delta): + pass + +func _on_pickable_t_shirt_picked(): + doors.remove_child($Doors/FrontDoor_Left); + doors.remove_child($Doors/FrontDoor_Right); + + +func _on_outside_enemy_is_killed(): + doors.remove_child($Doors/ClassDoor); + + +func _on_shoes_picked(): + doors.remove_child($Doors/Bathroom_Top); diff --git a/Levels/level.tscn b/Levels/level.tscn index 5fe1a3c..7ffe2dd 100644 --- a/Levels/level.tscn +++ b/Levels/level.tscn @@ -1,10 +1,22 @@ -[gd_scene load_steps=4 format=3 uid="uid://b8rvp5g0vj8q1"] +[gd_scene load_steps=11 format=3 uid="uid://b8rvp5g0vj8q1"] [ext_resource type="TileSet" uid="uid://bi3tupdxmgcim" path="res://TileSets/tiles.tres" id="1_8igly"] +[ext_resource type="Script" path="res://Levels/level.gd" id="1_x3isi"] [ext_resource type="PackedScene" uid="uid://xev8p1td1icx" path="res://Player/player.tscn" id="2_raadk"] [ext_resource type="AudioStream" uid="uid://dhuxf2eklsha5" path="res://Music/school.ogg" id="3_rnkol"] +[ext_resource type="PackedScene" uid="uid://chhokm3rf6pd3" path="res://OTHERS/door.tscn" id="4_oukel"] +[ext_resource type="PackedScene" uid="uid://bbg5x0apue0ei" path="res://PickableItems/pickable_t_shirt.tscn" id="5_kahe8"] +[ext_resource type="PackedScene" uid="uid://c661br4lh30r8" path="res://Enemies/basic_enemy.tscn" id="7_qt4sv"] +[ext_resource type="PackedScene" uid="uid://degce2jvx3sli" path="res://PickableItems/pickable_shoes.tscn" id="8_qnb3g"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_8jn25"] +size = Vector2(85, 5534.75) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_5xvim"] +size = Vector2(4186, 55) [node name="Level" type="Node2D"] +script = ExtResource("1_x3isi") [node name="Floor1" type="TileMap" parent="."] tile_set = ExtResource("1_8igly") @@ -37,3 +49,97 @@ position = Vector2(3075, 488) stream = ExtResource("3_rnkol") volume_db = -6.0 autoplay = true + +[node name="Outside_Wall" type="Node2D" parent="."] + +[node name="StaticBody2D" type="StaticBody2D" parent="Outside_Wall"] +position = Vector2(1029, 0) + +[node name="CollisionShape2D2" type="CollisionShape2D" parent="Outside_Wall/StaticBody2D"] +position = Vector2(4094.5, 2720.63) +shape = SubResource("RectangleShape2D_8jn25") + +[node name="CollisionShape2D3" type="CollisionShape2D" parent="Outside_Wall/StaticBody2D"] +position = Vector2(0, 2770) +shape = SubResource("RectangleShape2D_8jn25") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Outside_Wall/StaticBody2D"] +position = Vector2(2023, -0.5) +shape = SubResource("RectangleShape2D_5xvim") + +[node name="CollisionShape2D4" type="CollisionShape2D" parent="Outside_Wall/StaticBody2D"] +position = Vector2(2023, 5393) +shape = SubResource("RectangleShape2D_5xvim") + +[node name="Doors" type="Node2D" parent="."] + +[node name="FrontDoor_Left" parent="Doors" instance=ExtResource("4_oukel")] +position = Vector2(2906, 758) +scale = Vector2(4.47547, 4.07547) + +[node name="FrontDoor_Right" parent="Doors" instance=ExtResource("4_oukel")] +position = Vector2(3239, 762) +rotation = -3.14159 +scale = Vector2(4.47547, 4.07547) + +[node name="ClassDoor" parent="Doors" instance=ExtResource("4_oukel")] +position = Vector2(2763, 1339) +rotation = 1.57079 +scale = Vector2(3.57152, 3.25231) + +[node name="Bathroom_Top" parent="Doors" instance=ExtResource("4_oukel")] +position = Vector2(3368, 1473) +rotation = 1.57079 +scale = Vector2(3.57152, 3.25231) + +[node name="Bathroom_Bottom" parent="Doors" instance=ExtResource("4_oukel")] +position = Vector2(3368, 1984) +rotation = 4.71238 +scale = Vector2(3.57152, 3.25231) + +[node name="Cafeteria" parent="Doors" instance=ExtResource("4_oukel")] +position = Vector2(2763, 2436) +rotation = 4.71238 +scale = Vector2(3.57152, 3.25231) + +[node name="Locker" parent="Doors" instance=ExtResource("4_oukel")] +position = Vector2(3388, 2494) +rotation = 4.71238 +scale = Vector2(3.57152, 3.25231) + +[node name="Gym" parent="Doors" instance=ExtResource("4_oukel")] +position = Vector2(3388, 3579) +rotation = 4.71238 +scale = Vector2(3.57152, 3.25231) + +[node name="BackDoor_Left" parent="Doors" instance=ExtResource("4_oukel")] +position = Vector2(2906, 4086) +scale = Vector2(4.47547, 4.07547) + +[node name="BackDoor_Right" parent="Doors" instance=ExtResource("4_oukel")] +position = Vector2(3239, 4090) +rotation = -3.14159 +scale = Vector2(4.47547, 4.07547) + +[node name="pickable_t_shirt" parent="." instance=ExtResource("5_kahe8")] +position = Vector2(3586, 650) +rotation = 0.286545 + +[node name="Outside_Enemy" parent="." instance=ExtResource("7_qt4sv")] +position = Vector2(3939, 657) + +[node name="Class_Enemy01" parent="." instance=ExtResource("7_qt4sv")] +position = Vector2(2248, 1257) + +[node name="Class_Enemy02" parent="." instance=ExtResource("7_qt4sv")] +position = Vector2(2310, 1138) + +[node name="Class_Enemy03" parent="." instance=ExtResource("7_qt4sv")] +position = Vector2(2367, 1350) + +[node name="shoes" parent="." instance=ExtResource("8_qnb3g")] +position = Vector2(2595, 969) + +[connection signal="picked" from="pickable_t_shirt" to="." method="_on_pickable_t_shirt_picked"] +[connection signal="is_killed" from="Outside_Enemy" to="." method="_on_outside_enemy_is_killed"] +[connection signal="picked" from="shoes" to="." method="_on_shoes_picked"] diff --git a/OTHERS/door.tscn b/OTHERS/door.tscn new file mode 100644 index 0000000..8aa6535 --- /dev/null +++ b/OTHERS/door.tscn @@ -0,0 +1,29 @@ +[gd_scene load_steps=3 format=3 uid="uid://chhokm3rf6pd3"] + +[ext_resource type="Texture2D" uid="uid://q82l3e6t4whv" path="res://Sprites/HAHAHAs.png" id="1_6fehd"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_76cdb"] +size = Vector2(63, 7) + +[node name="Door" type="StaticBody2D"] + +[node name="Sprite2D" type="Sprite2D" parent="."] +position = Vector2(0, 6) +scale = Vector2(0.279902, 0.279902) +texture = ExtResource("1_6fehd") + +[node name="Sprite2D2" type="Sprite2D" parent="."] +position = Vector2(-8, 3) +rotation = 0.0752773 +scale = Vector2(0.245176, 0.245176) +texture = ExtResource("1_6fehd") + +[node name="Sprite2D3" type="Sprite2D" parent="."] +position = Vector2(14, 11) +rotation = -0.215964 +scale = Vector2(0.222094, 0.310601) +texture = ExtResource("1_6fehd") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(0.5, 0.5) +shape = SubResource("RectangleShape2D_76cdb") diff --git a/PickableItems/basic_item.gd b/PickableItems/basic_item.gd index 5c3c2b7..617dfae 100644 --- a/PickableItems/basic_item.gd +++ b/PickableItems/basic_item.gd @@ -9,4 +9,7 @@ func _on_body_entered(body): func pickup_routine(player): player.pickup(self); + emit_signal("picked"); queue_free(); + +signal picked(); diff --git a/Player/player.gd b/Player/player.gd index b638f9f..e8a8899 100644 --- a/Player/player.gd +++ b/Player/player.gd @@ -6,6 +6,10 @@ extends CharacterBody2D @export var HP = 100; @onready var raycast = $RayCast2D; +@onready var sprite = $AnimatedSprite2D; + +var animation_count = 0; + var current_weapon = null; var weapons = [null,null,null]; @@ -40,9 +44,11 @@ func attack(): current_weapon.fire(velocity); func take_damage(damage): - HP = HP - damage; - if HP <= 0: - kill(); + if sprite.animation != "damage": + HP = HP - damage; + sprite.play("damage"); + if HP <= 0: + kill(); func pickup(item): if item.Type == "weapon": @@ -87,3 +93,11 @@ func _on_area_2d_area_exited(area): $"../School_Bass".volume_db(-80); $"../School_Flute".volume_db(-80); $"../School_Brass".volume_db(-80); + + +func _on_animated_sprite_2d_animation_finished(): + if sprite.animation == "damage": + animation_count+=1; + if animation_count > 3: + animation_count = 0; + sprite.play("default"); diff --git a/Player/player.tscn b/Player/player.tscn index 46e87cd..6f51fb4 100644 --- a/Player/player.tscn +++ b/Player/player.tscn @@ -8,6 +8,17 @@ animations = [{ "frames": [{ "duration": 1.0, "texture": ExtResource("2_bqbmq") +}, { +"duration": 1.0, +"texture": null +}], +"loop": true, +"name": &"damage", +"speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": ExtResource("2_bqbmq") }], "loop": true, "name": &"default", @@ -39,3 +50,5 @@ visible = false points = PackedVector2Array(0, 0, 2000, 0) width = 5.0 default_color = Color(1, 0, 0, 0.392157) + +[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animated_sprite_2d_animation_finished"] diff --git a/Sprites/Door_1.png b/Sprites/Door_1.png new file mode 100644 index 0000000000000000000000000000000000000000..1cc56570d726c438a7de922382e234548b5ab081 GIT binary patch literal 407 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=jKx9jP7LeL$-D%z%{^TlLn`9l zPP67~au9Jneu!V{u~W_(pEo+OOsh9+*|@EcKVmbBceeKSB%Kez8OKrtgqqrB@Ko`u zTAZm)fA{dF!J}~JJ@w2CLJEEitVfs+xC^ibILu+->R@lsY+%xWii$WeiU_DTFg;>S z;93Bb6n0?z$Y8)40Mx>{prL|c29pL*k|n^whQWsssJM_RmFte^4GV^wX_u=%pENkW z;C^0MTG6gMTI>HlJCwt}`tCzZ)^~{#vs65N1X$Gi9+%j&AJCO5iMqe$=t&wZFzW1m08_{}RGj&E&3zqe&6ByS2$lhSdx#FN=g|4F=BY&^Bfz^6H k^AKQo@})+2ruq6ZXaU(AKnwzxf+vG0Pgg&ebxsLQ0NOc_U;qFB literal 0 HcmV?d00001 diff --git a/Sprites/Door_1.png.import b/Sprites/Door_1.png.import new file mode 100644 index 0000000..e52c6c8 --- /dev/null +++ b/Sprites/Door_1.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://de3lmcqcag5ay" +path="res://.godot/imported/Door_1.png-0b82fd4258b936d355687545c7459cb5.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Sprites/Door_1.png" +dest_files=["res://.godot/imported/Door_1.png-0b82fd4258b936d355687545c7459cb5.ctex"] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/bptc_ldr=0 +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/Sprites/HAHAHAs.png b/Sprites/HAHAHAs.png new file mode 100644 index 0000000000000000000000000000000000000000..b91c94dd50193c9298844cedc9c0aee61cc91505 GIT binary patch literal 2131 z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