diff --git a/Spawner.gd b/Spawner.gd index 66369b5..59af8f7 100644 --- a/Spawner.gd +++ b/Spawner.gd @@ -9,7 +9,7 @@ var wave_count = start_wave func _ready(): if start_wave != 0: - await get_tree().create_timer(5).timeout + await get_tree().create_timer(2).timeout waves = waves.slice(start_wave) spawn_loop() diff --git a/TrajectoryDisplay.gd b/TrajectoryDisplay.gd index 9917c7c..7767f77 100644 --- a/TrajectoryDisplay.gd +++ b/TrajectoryDisplay.gd @@ -9,8 +9,10 @@ func _ready(): func _physics_process(delta): #global_rotation = $"..".linear_velocity.angle() $ShapeCast2D.target_position = to_local($"..".linear_velocity * 1000) - points[1] = to_local($ShapeCast2D.get_collision_point(0)) + + if $ShapeCast2D.get_collider(0) != null and ["Player", "Shield" if target_shield else "None"].has($ShapeCast2D.get_collider(0).name): + points[1] = to_local($ShapeCast2D.get_collision_point(0)) visible = true else: visible = false diff --git a/Turret.gd b/Turret.gd index c9da595..5a8ff93 100644 --- a/Turret.gd +++ b/Turret.gd @@ -3,5 +3,8 @@ extends Node2D var target: Node2D func _process(delta): - if target: - look_at(target.global_position + target.linear_velocity) + if target and is_instance_valid(target): + if target.is_class("RigidBody2D"): + look_at(target.global_position + target.linear_velocity) + else: + look_at(target.global_position) diff --git a/eart-bubble.png b/eart-bubble.png new file mode 100644 index 0000000..dd1cf2c Binary files /dev/null and b/eart-bubble.png differ diff --git a/eart-bubble.png.import b/eart-bubble.png.import new file mode 100644 index 0000000..a932ba4 --- /dev/null +++ b/eart-bubble.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://du4hmctktlccq" +path="res://.godot/imported/eart-bubble.png-2fc5e96b7339e253e89864691565e3b2.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://eart-bubble.png" +dest_files=["res://.godot/imported/eart-bubble.png-2fc5e96b7339e253e89864691565e3b2.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/eart-shield-break.png b/eart-shield-break.png new file mode 100644 index 0000000..58dc4d9 Binary files /dev/null and b/eart-shield-break.png differ diff --git a/eart-shield-break.png.import b/eart-shield-break.png.import new file mode 100644 index 0000000..9bcd6b1 --- /dev/null +++ b/eart-shield-break.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dysewmpj8nvgx" +path="res://.godot/imported/eart-shield-break.png-3237feb9c3d0823340d07b2ee9703679.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://eart-shield-break.png" +dest_files=["res://.godot/imported/eart-shield-break.png-3237feb9c3d0823340d07b2ee9703679.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/eart-shield.png b/eart-shield.png new file mode 100644 index 0000000..0aa1f16 Binary files /dev/null and b/eart-shield.png differ diff --git a/eart-shield.png.import b/eart-shield.png.import new file mode 100644 index 0000000..97782fd --- /dev/null +++ b/eart-shield.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cc3nl13t7c4mj" +path="res://.godot/imported/eart-shield.png-3d03d60086a7a4ca3ffd8412d33b1963.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://eart-shield.png" +dest_files=["res://.godot/imported/eart-shield.png-3d03d60086a7a4ca3ffd8412d33b1963.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/eart-shoot.png b/eart-shoot.png new file mode 100644 index 0000000..4f291f5 Binary files /dev/null and b/eart-shoot.png differ diff --git a/eart-shoot.png.import b/eart-shoot.png.import new file mode 100644 index 0000000..abc2807 --- /dev/null +++ b/eart-shoot.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ckrd5s78myn2" +path="res://.godot/imported/eart-shoot.png-1a3d97f9ee3df5e958c6e421bbc0a007.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://eart-shoot.png" +dest_files=["res://.godot/imported/eart-shoot.png-1a3d97f9ee3df5e958c6e421bbc0a007.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/eart.gd b/eart.gd new file mode 100644 index 0000000..ebffe73 --- /dev/null +++ b/eart.gd @@ -0,0 +1,30 @@ +extends StaticBody2D + +func shoot(): + + $Turret.target = find_target() + + if not $Turret.target: + return + + $Turret/AnimatedSprite2D.play("shoot") + + await $Turret/AnimatedSprite2D.animation_finished + $Turret/Gun.shoot() + + $Turret/AnimatedSprite2D.play("default") + + $Turret.target = find_target() + + $ShootTimer.start(1) + + +func find_target(): + + if len(get_tree().get_nodes_in_group("enemy")) <= 0: + print("Error! nothing to heal") + return null + + var enemies = get_tree().get_nodes_in_group("enemy") + + return enemies[randi_range(0, len(enemies)-1)] diff --git a/eart.png b/eart.png new file mode 100644 index 0000000..b6e3ffc Binary files /dev/null and b/eart.png differ diff --git a/eart.png.import b/eart.png.import new file mode 100644 index 0000000..9114d07 --- /dev/null +++ b/eart.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bt6i05dav4ew5" +path="res://.godot/imported/eart.png-2bd558ee91f97d82f4e38d57e7eba5f3.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://eart.png" +dest_files=["res://.godot/imported/eart.png-2bd558ee91f97d82f4e38d57e7eba5f3.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/eart.tres b/eart.tres new file mode 100644 index 0000000..886e17f --- /dev/null +++ b/eart.tres @@ -0,0 +1,12 @@ +[gd_resource type="Resource" script_class="WaveEnemy" load_steps=4 format=3 uid="uid://c805aej5v7cvr"] + +[ext_resource type="Script" path="res://wave_enemy.gd" id="1_0iu7m"] +[ext_resource type="PackedScene" uid="uid://cjvg8kxt7u5yk" path="res://eart.tscn" id="1_hy2xe"] +[ext_resource type="SpriteFrames" uid="uid://dh2kuw87g8lsx" path="res://ircle_portal.tres" id="2_nxpif"] + +[resource] +script = ExtResource("1_0iu7m") +enemy = ExtResource("1_hy2xe") +boss = false +portal_texture = ExtResource("2_nxpif") +check_distance = 100 diff --git a/eart.tscn b/eart.tscn new file mode 100644 index 0000000..9d700f2 --- /dev/null +++ b/eart.tscn @@ -0,0 +1,171 @@ +[gd_scene load_steps=26 format=3 uid="uid://cjvg8kxt7u5yk"] + +[ext_resource type="Script" path="res://eart.gd" id="1_xkxbf"] +[ext_resource type="Script" path="res://Turret.gd" id="3_jlwo0"] +[ext_resource type="Texture2D" uid="uid://bt6i05dav4ew5" path="res://eart.png" id="3_k6o1h"] +[ext_resource type="Texture2D" uid="uid://ckrd5s78myn2" path="res://eart-shoot.png" id="4_ry8nw"] +[ext_resource type="Script" path="res://Gun.gd" id="5_tefa8"] +[ext_resource type="PackedScene" uid="uid://dl02ccyielpnj" path="res://shield bullet.tscn" id="6_cxgsw"] +[ext_resource type="PackedScene" uid="uid://c3s8as813frjc" path="res://shield.tscn" id="7_w0oyy"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_x6kbk"] +atlas = ExtResource("3_k6o1h") +region = Rect2(0, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_uavfs"] +atlas = ExtResource("4_ry8nw") +region = Rect2(0, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_4kt48"] +atlas = ExtResource("4_ry8nw") +region = Rect2(128, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_m4kjs"] +atlas = ExtResource("4_ry8nw") +region = Rect2(256, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_80ps8"] +atlas = ExtResource("4_ry8nw") +region = Rect2(384, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ocyed"] +atlas = ExtResource("4_ry8nw") +region = Rect2(512, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_festk"] +atlas = ExtResource("4_ry8nw") +region = Rect2(640, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_7qs7e"] +atlas = ExtResource("4_ry8nw") +region = Rect2(768, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_2lsh6"] +atlas = ExtResource("4_ry8nw") +region = Rect2(896, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ude0u"] +atlas = ExtResource("4_ry8nw") +region = Rect2(1024, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_u4tdc"] +atlas = ExtResource("4_ry8nw") +region = Rect2(1152, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_dcqkk"] +atlas = ExtResource("4_ry8nw") +region = Rect2(1280, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_2ovns"] +atlas = ExtResource("4_ry8nw") +region = Rect2(1408, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_n3uow"] +atlas = ExtResource("4_ry8nw") +region = Rect2(1536, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_wksfy"] +atlas = ExtResource("4_ry8nw") +region = Rect2(1664, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_v8s4u"] +atlas = ExtResource("4_ry8nw") +region = Rect2(1792, 0, 128, 128) + +[sub_resource type="SpriteFrames" id="SpriteFrames_1fj5a"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_x6kbk") +}], +"loop": true, +"name": &"default", +"speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_uavfs") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_4kt48") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_m4kjs") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_80ps8") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ocyed") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_festk") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_7qs7e") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_2lsh6") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ude0u") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_u4tdc") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_dcqkk") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_2ovns") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_n3uow") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_wksfy") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_v8s4u") +}], +"loop": false, +"name": &"shoot", +"speed": 12.0 +}] + +[sub_resource type="CircleShape2D" id="CircleShape2D_03ifk"] +radius = 44.1475 + +[node name="Eart" type="StaticBody2D" groups=["destructible"]] +script = ExtResource("1_xkxbf") + +[node name="ShootTimer" type="Timer" parent="."] +one_shot = true +autostart = true + +[node name="Turret" type="Node2D" parent="."] +script = ExtResource("3_jlwo0") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="Turret"] +position = Vector2(14, 0) +rotation = -1.5708 +sprite_frames = SubResource("SpriteFrames_1fj5a") +animation = &"shoot" +autoplay = "default" + +[node name="Gun" type="Marker2D" parent="Turret"] +position = Vector2(106, 0) +script = ExtResource("5_tefa8") +bullet = ExtResource("6_cxgsw") +bullet_speed = 300 + +[node name="RayCast2D" type="RayCast2D" parent="Turret"] +target_position = Vector2(1000, 0) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_03ifk") + +[node name="Shield" parent="." instance=ExtResource("7_w0oyy")] +scale = Vector2(2, 2) + +[connection signal="timeout" from="ShootTimer" to="." method="shoot"] diff --git a/eptagon.tscn b/eptagon.tscn index 60003de..233b17b 100644 --- a/eptagon.tscn +++ b/eptagon.tscn @@ -33,13 +33,13 @@ animations = [{ }], "loop": true, "name": &"default", -"speed": 5.0 +"speed": 3.0 }] [sub_resource type="CircleShape2D" id="CircleShape2D_03ifk"] radius = 36.0139 -[node name="Eptagon" type="StaticBody2D" groups=["destructible"]] +[node name="Eptagon" type="StaticBody2D" groups=["destructible", "enemy"]] script = ExtResource("1_d0pdl") [node name="Sprite2D" type="Sprite2D" parent="."] @@ -60,7 +60,6 @@ autoplay = "default" position = Vector2(56, 0) script = ExtResource("2_sea5o") bullet = ExtResource("4_cyd7j") -bullet_speed = 750 [node name="Collider" type="CollisionShape2D" parent="."] shape = SubResource("CircleShape2D_03ifk") diff --git a/ircle.tscn b/ircle.tscn index 44da364..c1b9586 100644 --- a/ircle.tscn +++ b/ircle.tscn @@ -155,5 +155,8 @@ shape = SubResource("CircleShape2D_yns8h") [node name="LaserFX" type="AudioStreamPlayer2D" parent="."] stream = ExtResource("5_tkxjf") +[node name="ShieldMarker" type="Marker2D" parent="."] +scale = Vector2(6, 6) + [connection signal="timeout" from="Line2D/VisibleTimer" to="Line2D" method="set_transparent"] [connection signal="timeout" from="Timer" to="." method="fire_laser"] diff --git a/main.gd b/main.gd index c8bf701..88d0c28 100644 --- a/main.gd +++ b/main.gd @@ -3,6 +3,10 @@ var config = ConfigFile.new() # Called when the node enters the scene tree for the first time. func _init(): + + if OS.is_debug_build(): + Engine.set_time_scale(0.25) + if config.load("user://settings.cfg") == OK: var player = load(config.get_value("gameplay", "class", "res://player-row.tscn")).instantiate() player.position = Vector2(1920/2, 1080/2) diff --git a/main.tscn b/main.tscn index 01639cd..0300133 100644 --- a/main.tscn +++ b/main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=116 format=3 uid="uid://bmd4m7lqj4v0x"] +[gd_scene load_steps=117 format=3 uid="uid://bmd4m7lqj4v0x"] [ext_resource type="Script" path="res://main.gd" id="1_3dydx"] [ext_resource type="Script" path="res://Spawner.gd" id="1_ifu8g"] @@ -13,6 +13,7 @@ [ext_resource type="Script" path="res://wave_enemy.gd" id="7_54h7d"] [ext_resource type="Texture2D" uid="uid://cwquv3mq5kk1d" path="res://countdown-spritesheet.png" id="8_e1eub"] [ext_resource type="Resource" uid="uid://dd8me0deake37" path="res://eptagon_enemy.tres" id="9_q67ak"] +[ext_resource type="Resource" uid="uid://c805aej5v7cvr" path="res://eart.tres" id="10_jib8h"] [ext_resource type="AudioStream" uid="uid://dn65uapn0wsok" path="res://impactMetal_002.ogg" id="11_acuni"] [ext_resource type="Script" path="res://CollisionCheck.gd" id="11_ryeyk"] [ext_resource type="FontFile" uid="uid://bnguin7bsyx6e" path="res://Kenney Future.ttf" id="11_s4q6p"] @@ -112,16 +113,16 @@ wait_for_killed = true [sub_resource type="Resource" id="Resource_61v84"] script = ExtResource("4_um0x7") -enemies = Array[ExtResource("7_54h7d")]([ExtResource("9_q67ak")]) -quantities = Array[int]([1]) -spawning_duration = 1.0 +enemies = Array[ExtResource("7_54h7d")]([ExtResource("10_jib8h"), ExtResource("3_xmk5u")]) +quantities = Array[int]([1, 2]) +spawning_duration = 3.0 wait = 5.0 wait_for_killed = true [sub_resource type="Resource" id="Resource_82qld"] script = ExtResource("4_um0x7") -enemies = Array[ExtResource("7_54h7d")]([ExtResource("3_xmk5u"), ExtResource("5_xdrk0"), ExtResource("5_e24vf")]) -quantities = Array[int]([10, 10, 10]) +enemies = Array[ExtResource("7_54h7d")]([ExtResource("3_xmk5u"), ExtResource("5_xdrk0"), ExtResource("5_e24vf"), ExtResource("10_jib8h")]) +quantities = Array[int]([10, 10, 10, 4]) spawning_duration = 20.0 wait = 2.0 wait_for_killed = true @@ -669,6 +670,7 @@ script = ExtResource("1_3dydx") script = ExtResource("1_ifu8g") waves = Array[ExtResource("4_um0x7")]([SubResource("Resource_ur7l5"), SubResource("Resource_kupyp"), SubResource("Resource_o8cet"), SubResource("Resource_0cevq"), SubResource("Resource_eppj0"), SubResource("Resource_rpu1y"), SubResource("Resource_4b1vo"), SubResource("Resource_gg7kj"), SubResource("Resource_fjkob"), SubResource("Resource_5sdy5"), SubResource("Resource_61v84"), SubResource("Resource_82qld"), SubResource("Resource_2j32b")]) wave_label = NodePath("../UI/Wave Count") +start_wave = 8 [node name="Timer" type="Timer" parent="Spawner"] wait_time = 0.1 diff --git a/player-iamond.tscn b/player-iamond.tscn index 44f7e8a..68fbc04 100644 --- a/player-iamond.tscn +++ b/player-iamond.tscn @@ -205,3 +205,5 @@ color_ramp = SubResource("Gradient_urfxb") [node name="CollisionShape2D" type="CollisionShape2D" parent="." index="3"] rotation = -1.5708 shape = SubResource("CapsuleShape2D_bf2qx") + +[node name="ShieldMarker" type="Marker2D" parent="." index="4"] diff --git a/player-ite.tscn b/player-ite.tscn index 7b2a01f..b050b05 100644 --- a/player-ite.tscn +++ b/player-ite.tscn @@ -276,3 +276,7 @@ collision_mask = 3 [node name="LaserFX" type="AudioStreamPlayer2D" parent="." index="5"] stream = ExtResource("9_thl05") bus = &"SFX" + +[node name="ShieldMarker" type="Marker2D" parent="." index="6"] +position = Vector2(10.5, 0) +scale = Vector2(2, 2) diff --git a/player-row.gd b/player-row.gd index 552b047..0707f74 100644 --- a/player-row.gd +++ b/player-row.gd @@ -24,14 +24,14 @@ func _input(event): if num_quares >= max_quares: notifier.notify("All Quares in Use!") return - for child in $"../".get_node("%Ability").get_children(): - if child.value == 0 and not child.animating: - child.value = 100 - break if not $"../CollisionCheck".is_clear(get_global_mouse_position(), 60): $"../CollisionCheck".flash() notifier.notify("Too Close!") return + for child in $"../".get_node("%Ability").get_children(): + if child.value == 0 and not child.animating: + child.value = 100 + num_quares += 1 var new_quare = quare.instantiate() new_quare.position = get_global_mouse_position() diff --git a/player-row.tscn b/player-row.tscn index 6efe91a..6faa3c8 100644 --- a/player-row.tscn +++ b/player-row.tscn @@ -205,3 +205,7 @@ bus = &"SFX" [node name="ExagonFX" type="AudioStreamPlayer2D" parent="." index="4"] stream = ExtResource("4_lwgj5") bus = &"SFX" + +[node name="ShieldMarker" type="Marker2D" parent="." index="5"] +position = Vector2(4, 0) +scale = Vector2(1.5, 1.5) diff --git a/project.godot b/project.godot index 5a3cce2..e13206e 100644 --- a/project.godot +++ b/project.godot @@ -28,6 +28,11 @@ window/vsync/vsync_mode=2 version_control/plugin_name="GitPlugin" version_control/autoload_on_startup=true +[global_group] + +destructible="Destructible Objects" +enemy="Enemies" + [input] up={ diff --git a/shield bullet.tscn b/shield bullet.tscn new file mode 100644 index 0000000..d9542f2 --- /dev/null +++ b/shield bullet.tscn @@ -0,0 +1,92 @@ +[gd_scene load_steps=13 format=3 uid="uid://dl02ccyielpnj"] + +[ext_resource type="Script" path="res://shield_bullet.gd" id="1_dsvm1"] +[ext_resource type="Texture2D" uid="uid://du4hmctktlccq" path="res://eart-bubble.png" id="2_ledl3"] +[ext_resource type="Texture2D" uid="uid://djfjdlri5xdkn" path="res://dotted line.png" id="3_jaepw"] +[ext_resource type="Script" path="res://TrajectoryDisplay.gd" id="4_fyeym"] + +[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_xnhwp"] +friction = 0.0 +bounce = 1.0 + +[sub_resource type="CircleShape2D" id="CircleShape2D_b5cca"] +radius = 13.0 + +[sub_resource type="AtlasTexture" id="AtlasTexture_qjm3j"] +atlas = ExtResource("2_ledl3") +region = Rect2(0, 0, 32, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_rrdre"] +atlas = ExtResource("2_ledl3") +region = Rect2(32, 0, 32, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ghx8d"] +atlas = ExtResource("2_ledl3") +region = Rect2(64, 0, 32, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ch73m"] +atlas = ExtResource("2_ledl3") +region = Rect2(96, 0, 32, 32) + +[sub_resource type="SpriteFrames" id="SpriteFrames_pacu6"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_qjm3j") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_rrdre") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ghx8d") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ch73m") +}], +"loop": true, +"name": &"default", +"speed": 7.0 +}] + +[sub_resource type="CircleShape2D" id="CircleShape2D_13gk7"] +radius = 30.0 + +[node name="Bullet" type="RigidBody2D" groups=["bullet"]] +collision_layer = 2 +physics_material_override = SubResource("PhysicsMaterial_xnhwp") +gravity_scale = 1.66533e-16 +contact_monitor = true +max_contacts_reported = 1 +linear_velocity = Vector2(2.08165e-12, 2.08165e-12) +script = ExtResource("1_dsvm1") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(0, 1) +rotation = -1.5708 +shape = SubResource("CircleShape2D_b5cca") + +[node name="Sprite2D" type="AnimatedSprite2D" parent="."] +texture_filter = 1 +position = Vector2(11, -6) +rotation = 1.5708 +sprite_frames = SubResource("SpriteFrames_pacu6") +autoplay = "default" +offset = Vector2(7.05637, 10.7826) + +[node name="TrajectoryDisplay" type="Line2D" parent="."] +visible = false +z_index = -1 +texture_repeat = 2 +position = Vector2(-2, 0) +points = PackedVector2Array(0, 0, 100, 0) +width = 50.0 +default_color = Color(0.909804, 0.717647, 0.337255, 0.529412) +texture = ExtResource("3_jaepw") +texture_mode = 1 +script = ExtResource("4_fyeym") + +[node name="ShapeCast2D" type="ShapeCast2D" parent="TrajectoryDisplay"] +shape = SubResource("CircleShape2D_13gk7") +target_position = Vector2(500, 2.08165e-12) + +[connection signal="body_entered" from="." to="." method="hit"] diff --git a/shield.gd b/shield.gd new file mode 100644 index 0000000..c37ac2a --- /dev/null +++ b/shield.gd @@ -0,0 +1,21 @@ +extends PhysicsBody2D + +#! egregious code + +func find_collisionshape(): + if get_parent().name == "ShieldMarker": + return get_parent().get_parent().get_node("CollisionShape2D") + elif get_parent().has_node("CollisionShape2D"): + return get_parent().get_node("CollisionShape2D") + return null + +func _ready() -> void: + if find_collisionshape(): + print(find_collisionshape().get_parent().name) + find_collisionshape().set_deferred("disabled", true) + #$Collider.set_deferred("disabled", false) + +func destroy(): + if find_collisionshape(): + find_collisionshape().set_deferred("disabled", false) + $AnimatedSprite2D.play("die") diff --git a/shield.tscn b/shield.tscn new file mode 100644 index 0000000..1b8347c --- /dev/null +++ b/shield.tscn @@ -0,0 +1,127 @@ +[gd_scene load_steps=19 format=3 uid="uid://c3s8as813frjc"] + +[ext_resource type="Script" path="res://shield.gd" id="1_ni0ln"] +[ext_resource type="Texture2D" uid="uid://cc3nl13t7c4mj" path="res://eart-shield.png" id="2_2bt8h"] +[ext_resource type="Texture2D" uid="uid://dysewmpj8nvgx" path="res://eart-shield-break.png" id="3_1tta6"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_mcb3o"] +atlas = ExtResource("2_2bt8h") +region = Rect2(0, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_l8lnp"] +atlas = ExtResource("2_2bt8h") +region = Rect2(64, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_so4um"] +atlas = ExtResource("2_2bt8h") +region = Rect2(128, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_sel7y"] +atlas = ExtResource("2_2bt8h") +region = Rect2(192, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_iumxh"] +atlas = ExtResource("2_2bt8h") +region = Rect2(256, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_jb6hd"] +atlas = ExtResource("2_2bt8h") +region = Rect2(320, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_5xoy6"] +atlas = ExtResource("2_2bt8h") +region = Rect2(384, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_a5ids"] +atlas = ExtResource("3_1tta6") +region = Rect2(0, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_x2842"] +atlas = ExtResource("3_1tta6") +region = Rect2(64, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ckp3b"] +atlas = ExtResource("3_1tta6") +region = Rect2(128, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_b6w7a"] +atlas = ExtResource("3_1tta6") +region = Rect2(192, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_m7ilu"] +atlas = ExtResource("3_1tta6") +region = Rect2(256, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_w1mec"] +atlas = ExtResource("3_1tta6") +region = Rect2(320, 0, 64, 64) + +[sub_resource type="SpriteFrames" id="SpriteFrames_gcmwu"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_mcb3o") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_l8lnp") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_so4um") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_sel7y") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_iumxh") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_jb6hd") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_5xoy6") +}], +"loop": true, +"name": &"default", +"speed": 7.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_a5ids") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_x2842") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ckp3b") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_b6w7a") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_m7ilu") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_w1mec") +}], +"loop": false, +"name": &"die", +"speed": 7.0 +}] + +[sub_resource type="CircleShape2D" id="CircleShape2D_00lvq"] +radius = 25.1794 + +[node name="Shield" type="AnimatableBody2D" groups=["destructible"]] +scale = Vector2(3, 3) +script = ExtResource("1_ni0ln") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +sprite_frames = SubResource("SpriteFrames_gcmwu") +animation = &"die" +autoplay = "default" + +[node name="Collider" type="CollisionShape2D" parent="."] +position = Vector2(-1, 0) +shape = SubResource("CircleShape2D_00lvq") + +[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="queue_free"] diff --git a/shield_bullet.gd b/shield_bullet.gd new file mode 100644 index 0000000..b76dc5a --- /dev/null +++ b/shield_bullet.gd @@ -0,0 +1,29 @@ +extends RigidBody2D + +@onready var player = $"../Player" + +var shield_scene = preload("res://shield.tscn") + +func _physics_process(delta): + rotation = linear_velocity.angle() + #if linear_velocity.length() < 1100: + # apply_central_force((global_position - player.global_position).normalized() * -200) + +func hit(body): + if body.is_in_group("destructible") and body.name != "Shield": + + var shield = shield_scene.instantiate() + + + if body.has_node("ShieldMarker"): + shield.scale = Vector2.ONE + body.get_node("ShieldMarker").add_child(shield) + else: + body.add_child(shield) + + shield.position = Vector2.ZERO + + queue_free() + + else: + queue_free()