Add fade away component, simple AI and shooting

This commit is contained in:
2025-01-04 08:42:23 +01:00
parent 366c269817
commit f537722849
15 changed files with 347 additions and 12 deletions

View File

@@ -15,7 +15,7 @@ size = Vector2(16, 31)
[node name="Brick Player" type="CharacterBody2D"]
collision_layer = 4
collision_mask = 3
collision_mask = 11
script = ExtResource("1_8j4h4")
[node name="Root" type="Node2D" parent="."]

41
objects/bullet.tscn Normal file
View File

@@ -0,0 +1,41 @@
[gd_scene load_steps=5 format=3 uid="uid://bhc7y4xugu4q7"]
[ext_resource type="Texture2D" uid="uid://djifxc5x0dyrw" path="res://sprites/ppc_tileset.png" id="1_w543f"]
[ext_resource type="Script" path="res://scripts/components/damage.gd" id="2_qkwsu"]
[ext_resource type="Script" path="res://scripts/components/bullet.gd" id="3_keogl"]
[sub_resource type="CircleShape2D" id="CircleShape2D_txsw8"]
radius = 4.0
[node name="Bullet" type="Area2D"]
collision_layer = 8
collision_mask = 5
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_txsw8")
[node name="Sprite2D" type="Sprite2D" parent="."]
scale = Vector2(0.5, 0.5)
texture = ExtResource("1_w543f")
hframes = 12
vframes = 12
frame = 79
[node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="."]
position = Vector2(2.38419e-07, 2.38419e-07)
scale = Vector2(0.4, 0.4)
[node name="DamageComponent" type="Node" parent="." node_paths=PackedStringArray("area2d")]
script = ExtResource("2_qkwsu")
area2d = NodePath("..")
[node name="BulletComponent" type="Node2D" parent="." node_paths=PackedStringArray("root", "area2d", "visibility_notifier", "timer")]
script = ExtResource("3_keogl")
root = NodePath("..")
speed = 100.0
area2d = NodePath("..")
visibility_notifier = NodePath("../VisibleOnScreenNotifier2D")
timer = NodePath("../Timer")
[node name="Timer" type="Timer" parent="."]
autostart = true

View File

@@ -1,8 +1,9 @@
[gd_scene load_steps=5 format=3 uid="uid://54w4wisfj8v8"]
[gd_scene load_steps=6 format=3 uid="uid://54w4wisfj8v8"]
[ext_resource type="Texture2D" uid="uid://djifxc5x0dyrw" path="res://sprites/ppc_tileset.png" id="1_epuj5"]
[ext_resource type="Script" path="res://scripts/components/collectable.gd" id="2_y0k47"]
[ext_resource type="Resource" uid="uid://vql535ckoeqm" path="res://resources/collectables/coin.tres" id="3_fm2fq"]
[ext_resource type="Script" path="res://scripts/components/fade_away.gd" id="4_fx1h2"]
[sub_resource type="CircleShape2D" id="CircleShape2D_3ask2"]
radius = 9.0
@@ -24,3 +25,10 @@ frame = 51
script = ExtResource("2_y0k47")
area2d = NodePath("..")
collectable_data = ExtResource("3_fm2fq")
[node name="FadeAwayComponent" type="Node" parent="." node_paths=PackedStringArray("sprite2d", "root", "area2d")]
script = ExtResource("4_fx1h2")
sprite2d = NodePath("../Sprite2D")
fade_duration = 0.4
root = NodePath("..")
area2d = NodePath("..")

59
objects/enemy.tscn Normal file
View File

@@ -0,0 +1,59 @@
[gd_scene load_steps=8 format=3 uid="uid://bwdlmualj6xbw"]
[ext_resource type="Texture2D" uid="uid://xes6mt2dd5gu" path="res://sprites/robot_cutout.png" id="1_uh38l"]
[ext_resource type="Script" path="res://scripts/components/health.gd" id="2_o170m"]
[ext_resource type="Script" path="res://scripts/components/damage.gd" id="3_8jl3u"]
[ext_resource type="Script" path="res://scripts/components/side_to_side_movement.gd" id="4_gbsq8"]
[ext_resource type="Script" path="res://scripts/components/periodic_shooting.gd" id="5_m03v0"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_pwwji"]
size = Vector2(18, 27)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ejbqt"]
size = Vector2(18, 27)
[node name="Enemy" type="CharacterBody2D"]
collision_layer = 0
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, 0.5)
shape = SubResource("RectangleShape2D_pwwji")
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("1_uh38l")
[node name="HealthComponent" type="Node" parent="."]
script = ExtResource("2_o170m")
[node name="DamageComponent" type="Node" parent="." node_paths=PackedStringArray("area2d")]
script = ExtResource("3_8jl3u")
area2d = NodePath("../Hitbox")
[node name="SideToSideMovement" type="Node" parent="." node_paths=PackedStringArray("root", "sprite2d", "left_ray", "right_ray")]
script = ExtResource("4_gbsq8")
root = NodePath("..")
sprite2d = NodePath("../Sprite2D")
speed = 60.0
wait_time = 0.5
left_ray = NodePath("../Left Ray")
right_ray = NodePath("../Right Ray")
[node name="PeriodicShootingComponent" type="Node" parent="." node_paths=PackedStringArray("side_to_side_movement", "root")]
script = ExtResource("5_m03v0")
side_to_side_movement = NodePath("../SideToSideMovement")
root = NodePath("..")
[node name="Hitbox" type="Area2D" parent="."]
collision_layer = 8
collision_mask = 4
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"]
position = Vector2(0, 0.5)
shape = SubResource("RectangleShape2D_ejbqt")
debug_color = Color(0.913521, 0.265052, 0.323172, 0.42)
[node name="Left Ray" type="RayCast2D" parent="."]
position = Vector2(-16, 13)
[node name="Right Ray" type="RayCast2D" parent="."]
position = Vector2(16, 13)