diff --git a/Enemies/basic_enemy.gd b/Enemies/basic_enemy.gd index 27e1b39..c80c7f3 100644 --- a/Enemies/basic_enemy.gd +++ b/Enemies/basic_enemy.gd @@ -4,7 +4,7 @@ extends CharacterBody2D @export var ACCELERATION = 1000.0; @export var FRICTION = 1500.0; @export var HP = 100; -@export var DAMAGE = 34; +@export var DAMAGE = 10; @export var COOLDOWN = 2; @onready var raycast = $RayCast2D; diff --git a/Enemies/basic_enemy.tscn b/Enemies/basic_enemy.tscn index 3b52baa..f232147 100644 --- a/Enemies/basic_enemy.tscn +++ b/Enemies/basic_enemy.tscn @@ -31,6 +31,7 @@ shape = SubResource("RectangleShape2D_47nt3") target_position = Vector2(35, 0) [node name="Line2D" type="Line2D" parent="RayCast2D"] +visible = false points = PackedVector2Array(0, 0, 35, 0) width = 5.0 default_color = Color(1, 0, 0, 0.392157) diff --git a/Enemies/urinal_mimic.gd b/Enemies/urinal_mimic.gd new file mode 100644 index 0000000..5432758 --- /dev/null +++ b/Enemies/urinal_mimic.gd @@ -0,0 +1,59 @@ +extends CharacterBody2D + +@export var MAX_SPEED = 500.0; +@export var ACCELERATION = 1000.0; +@export var FRICTION = 1500.0; +@export var HP = 1; +@export var DAMAGE = 25; +@export var COOLDOWN = 10; + +@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 || !attacking: + return + + var vec_to_player = player.global_position - global_position; + vec_to_player = vec_to_player.normalized(); + raycast.rotation = atan2(vec_to_player.y,vec_to_player.x); + velocity = velocity.move_toward(vec_to_player * MAX_SPEED,ACCELERATION*delta); + move_and_slide(); + + if raycast.is_colliding(): + var coll = raycast.get_collider(); + if coll.name == "Player": + attack(coll); + +func attack(collider): + collider.take_damage(DAMAGE); + kill() + +func take_damage(damage): + HP = HP - damage; + if HP <= 0: + kill(); + +func kill(): + queue_free(); + +func set_player(p): + player = p; + +func _on_cooldown_timer_timeout(): + is_on_cooldown = false; + +func _on_area_2d_body_entered(body): + if body.name == "Player": + sprite.play("default"); + +func _on_animated_sprite_2d_animation_finished(): + attacking = true; diff --git a/Enemies/urinal_mimic.tscn b/Enemies/urinal_mimic.tscn new file mode 100644 index 0000000..d2f06a0 --- /dev/null +++ b/Enemies/urinal_mimic.tscn @@ -0,0 +1,103 @@ +[gd_scene load_steps=14 format=3 uid="uid://p7aa6t787b3d"] + +[ext_resource type="Script" path="res://Enemies/urinal_mimic.gd" id="1_2ga4k"] +[ext_resource type="Texture2D" uid="uid://clw15m8cxj22p" path="res://Sprites/Urinol.png" id="2_3n7wy"] +[ext_resource type="Texture2D" uid="uid://t2d8ft40y5c0" path="res://Sprites/Urinol_MIMIC.png" id="3_fjxqr"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_rqcqj"] +atlas = ExtResource("3_fjxqr") +region = Rect2(0, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_hcf1j"] +atlas = ExtResource("3_fjxqr") +region = Rect2(64, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_smam5"] +atlas = ExtResource("3_fjxqr") +region = Rect2(128, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_mvcd5"] +atlas = ExtResource("3_fjxqr") +region = Rect2(192, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_uyisr"] +atlas = ExtResource("3_fjxqr") +region = Rect2(256, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_r27p5"] +atlas = ExtResource("3_fjxqr") +region = Rect2(320, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_qbor8"] +atlas = ExtResource("3_fjxqr") +region = Rect2(384, 0, 64, 64) + +[sub_resource type="SpriteFrames" id="SpriteFrames_e70cb"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": ExtResource("2_3n7wy") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_rqcqj") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_hcf1j") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_smam5") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_mvcd5") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_uyisr") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_r27p5") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_qbor8") +}], +"loop": true, +"name": &"default", +"speed": 5.0 +}] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_jn4wv"] +size = Vector2(23, 21) + +[sub_resource type="CircleShape2D" id="CircleShape2D_0y76e"] +radius = 120.037 + +[node name="urinal_mimic" type="CharacterBody2D"] +script = ExtResource("1_2ga4k") + +[node name="RayCast2D" type="RayCast2D" parent="."] +target_position = Vector2(30, 0) + +[node name="Line2D" type="Line2D" parent="RayCast2D"] +visible = false +points = PackedVector2Array(0, 0, 30, 0) +width = 4.0 +default_color = Color(0.752941, 0, 0, 1) + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +position = Vector2(0, 21) +frames = SubResource("SpriteFrames_e70cb") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(0.5, -0.5) +shape = SubResource("RectangleShape2D_jn4wv") + +[node name="Area2D" type="Area2D" parent="."] +collision_layer = 2 +collision_mask = 2 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] +shape = SubResource("CircleShape2D_0y76e") + +[node name="CooldownTimer" type="Timer" parent="."] + +[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animated_sprite_2d_animation_finished"] +[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"] diff --git a/GameJam-Vanier.csproj b/GameJam-Vanier.csproj index 4210b40..2762b39 100644 --- a/GameJam-Vanier.csproj +++ b/GameJam-Vanier.csproj @@ -1,4 +1,4 @@ - + net6.0 true diff --git a/GameJam-Vanier.csproj.old.2 b/GameJam-Vanier.csproj.old.2 new file mode 100644 index 0000000..4210b40 --- /dev/null +++ b/GameJam-Vanier.csproj.old.2 @@ -0,0 +1,7 @@ + + + net6.0 + true + GameJamVanier + + \ No newline at end of file diff --git a/Player/player.tscn b/Player/player.tscn index 5ce5edf..46e87cd 100644 --- a/Player/player.tscn +++ b/Player/player.tscn @@ -18,6 +18,8 @@ animations = [{ size = Vector2(40, 64) [node name="Player" type="CharacterBody2D"] +collision_layer = 3 +collision_mask = 3 script = ExtResource("1_mbyc2") [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] diff --git a/Sprites/Urinol.png b/Sprites/Urinol.png new file mode 100644 index 0000000..4a5cea4 Binary files /dev/null and b/Sprites/Urinol.png differ diff --git a/Sprites/Urinol.png.import b/Sprites/Urinol.png.import new file mode 100644 index 0000000..3061fb5 --- /dev/null +++ b/Sprites/Urinol.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://clw15m8cxj22p" +path="res://.godot/imported/Urinol.png-3d48a5dd6a4ef8c95cb84ee41f232b9e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Sprites/Urinol.png" +dest_files=["res://.godot/imported/Urinol.png-3d48a5dd6a4ef8c95cb84ee41f232b9e.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/Urinol_MIMIC.png b/Sprites/Urinol_MIMIC.png new file mode 100644 index 0000000..46587a7 Binary files /dev/null and b/Sprites/Urinol_MIMIC.png differ diff --git a/Sprites/Urinol_MIMIC.png.import b/Sprites/Urinol_MIMIC.png.import new file mode 100644 index 0000000..7a87897 --- /dev/null +++ b/Sprites/Urinol_MIMIC.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://t2d8ft40y5c0" +path="res://.godot/imported/Urinol_MIMIC.png-edbfaed3e6aa9e657a1159072b3b4576.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Sprites/Urinol_MIMIC.png" +dest_files=["res://.godot/imported/Urinol_MIMIC.png-edbfaed3e6aa9e657a1159072b3b4576.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/test_level001.tscn b/test_level001.tscn index 174934d..6da1cbd 100644 --- a/test_level001.tscn +++ b/test_level001.tscn @@ -2,9 +2,9 @@ [ext_resource type="PackedScene" uid="uid://xev8p1td1icx" path="res://Player/player.tscn" id="1_51g8b"] [ext_resource type="Texture2D" uid="uid://d3y4rna66nylu" path="res://TileSets/Tiles Set GameJam.png" id="2_xwre6"] -[ext_resource type="PackedScene" uid="uid://c661br4lh30r8" path="res://Enemies/basic_enemy.tscn" id="3_e1d3p"] [ext_resource type="PackedScene" uid="uid://bbg5x0apue0ei" path="res://PickableItems/pickable_t_shirt.tscn" id="4_5egyc"] [ext_resource type="PackedScene" uid="uid://degce2jvx3sli" path="res://PickableItems/pickable_shoes.tscn" id="5_4b36u"] +[ext_resource type="PackedScene" uid="uid://p7aa6t787b3d" path="res://Enemies/urinal_mimic.tscn" id="5_sfqul"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_aemot"] resource_name = "Test" @@ -140,29 +140,11 @@ position = Vector2(67.9902, 68.8737) [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="StaticBody2D"] polygon = PackedVector2Array(409, 497, 687, 497, 687, 367, 1681, 367, 1683, 639, 1967, 643, 1963, 85, 415, 85) -[node name="BasicEnemy" parent="." instance=ExtResource("3_e1d3p")] -position = Vector2(843, 709) - -[node name="BasicEnemy2" parent="." instance=ExtResource("3_e1d3p")] -position = Vector2(1555, 856) - -[node name="BasicEnemy3" parent="." instance=ExtResource("3_e1d3p")] -position = Vector2(1034, 520) - -[node name="BasicEnemy4" parent="." instance=ExtResource("3_e1d3p")] -position = Vector2(774, -108) - -[node name="BasicEnemy5" parent="." instance=ExtResource("3_e1d3p")] -position = Vector2(1383, -193) - -[node name="BasicEnemy6" parent="." instance=ExtResource("3_e1d3p")] -position = Vector2(948, 660) - -[node name="BasicEnemy7" parent="." instance=ExtResource("3_e1d3p")] -position = Vector2(1322, 618) - [node name="pickable_t_shirt" parent="." instance=ExtResource("4_5egyc")] position = Vector2(172, 127) [node name="shoes" parent="." instance=ExtResource("5_4b36u")] position = Vector2(51, 155) + +[node name="urinal_mimic" parent="." instance=ExtResource("5_sfqul")] +position = Vector2(704, 372)