diff --git a/Prefabs/Berries/Berry.tscn b/Prefabs/Berries/Berry.tscn new file mode 100644 index 0000000..1930f3c --- /dev/null +++ b/Prefabs/Berries/Berry.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=4 format=3 uid="uid://cuxasb6eg47gw"] + +[ext_resource type="Script" uid="uid://byjsgr18ieauy" path="res://Scripts/BerryLogic.cs" id="1_0wwwo"] +[ext_resource type="Texture2D" uid="uid://keupgfuijdl7" path="res://Textures/Berries/Berry.png" id="1_g0wxr"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_7lihs"] +size = Vector2(183, 203) + +[node name="Berry" type="Node2D"] +script = ExtResource("1_0wwwo") + +[node name="Sprite" type="Sprite2D" parent="."] +scale = Vector2(1.52344, 1.52344) +texture = ExtResource("1_g0wxr") + +[node name="Hitbox" type="Area2D" parent="."] + +[node name="Shape" type="CollisionShape2D" parent="Hitbox"] +shape = SubResource("RectangleShape2D_7lihs") +debug_color = Color(0.713726, 0, 0.321569, 0.156863) + +[connection signal="area_entered" from="Hitbox" to="." method="_on_hitbox_area_entered"] diff --git a/Scenes/Game.tscn b/Scenes/Game.tscn index 0e007c2..7767490 100644 --- a/Scenes/Game.tscn +++ b/Scenes/Game.tscn @@ -1,13 +1,21 @@ -[gd_scene load_steps=3 format=3 uid="uid://bgt46l5p8qrwc"] +[gd_scene load_steps=5 format=3 uid="uid://bgt46l5p8qrwc"] [ext_resource type="Script" uid="uid://dfv3cmvcskd6t" path="res://Scripts/Player.cs" id="1_gl6un"] [ext_resource type="Texture2D" uid="uid://5ecdlqnn0u6g" path="res://Textures/Icons/Bird1.png" id="1_iukft"] +[ext_resource type="Script" uid="uid://bdwdadvx0axam" path="res://Scripts/Berries.cs" id="1_kldst"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_j5yw3"] +radius = 117.004 [node name="Game" type="Node2D"] [node name="Center" type="Node2D" parent="."] position = Vector2(960, 540) +[node name="Berries" type="Node2D" parent="."] +position = Vector2(960, 0) +script = ExtResource("1_kldst") + [node name="Player" type="Node2D" parent="."] position = Vector2(960, 978) script = ExtResource("1_gl6un") @@ -15,3 +23,10 @@ script = ExtResource("1_gl6un") [node name="Texture" type="Sprite2D" parent="Player"] scale = Vector2(1.675, 1.675) texture = ExtResource("1_iukft") + +[node name="Hitbox" type="Area2D" parent="Player"] +position = Vector2(-5, 23) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Player/Hitbox"] +shape = SubResource("CircleShape2D_j5yw3") +debug_color = Color(1, 1, 1, 0.188235) diff --git a/Scripts/Berries.cs b/Scripts/Berries.cs new file mode 100644 index 0000000..38b6931 --- /dev/null +++ b/Scripts/Berries.cs @@ -0,0 +1,29 @@ +using Godot; +using System; + +public partial class Berries : Node2D { + private float SpawnBerryTimer = 0f; + + public override void _Process(double delta) { + Vector2 Pos = Position; + Pos.Y += 500f * (float)delta; + + SpawnBerryTimer += (float)delta; + + int ScreenWidth = DisplayServer.WindowGetSize().X; + + if (SpawnBerryTimer > 1.0) { + SpawnBerryTimer = 0f; + + PackedScene Berry = GD.Load("res://Prefabs/Berries/Berry.tscn"); + + Node2D BerryInstance = Berry.Instantiate(); + + BerryInstance.Position = new Vector2(x: new Random().Next(-(ScreenWidth / 2), ScreenWidth / 2), y: -100 - Position.Y); + + AddChild(BerryInstance); + } + + Position = Pos; + } +} diff --git a/Scripts/Berries.cs.uid b/Scripts/Berries.cs.uid new file mode 100644 index 0000000..ad11ef6 --- /dev/null +++ b/Scripts/Berries.cs.uid @@ -0,0 +1 @@ +uid://bdwdadvx0axam diff --git a/Scripts/BerryLogic.cs b/Scripts/BerryLogic.cs new file mode 100644 index 0000000..6b80004 --- /dev/null +++ b/Scripts/BerryLogic.cs @@ -0,0 +1,8 @@ +using Godot; +using System; + +public partial class BerryLogic : Node2D { + private void _on_hitbox_area_entered(Area2D area) { + QueueFree(); + } +} diff --git a/Scripts/BerryLogic.cs.uid b/Scripts/BerryLogic.cs.uid new file mode 100644 index 0000000..e7d0fc6 --- /dev/null +++ b/Scripts/BerryLogic.cs.uid @@ -0,0 +1 @@ +uid://byjsgr18ieauy diff --git a/Textures/Berries/Berry.png b/Textures/Berries/Berry.png new file mode 100644 index 0000000..0530437 Binary files /dev/null and b/Textures/Berries/Berry.png differ diff --git a/Textures/Berries/Berry.png.import b/Textures/Berries/Berry.png.import new file mode 100644 index 0000000..f8aae6c --- /dev/null +++ b/Textures/Berries/Berry.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://keupgfuijdl7" +path="res://.godot/imported/Berry.png-99fceefd2d38bc29952b8ccbf9da3f8e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Textures/Berries/Berry.png" +dest_files=["res://.godot/imported/Berry.png-99fceefd2d38bc29952b8ccbf9da3f8e.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/Textures/Berries/UltraBerry.png b/Textures/Berries/UltraBerry.png new file mode 100644 index 0000000..a5471d6 Binary files /dev/null and b/Textures/Berries/UltraBerry.png differ diff --git a/Textures/Berries/UltraBerry.png.import b/Textures/Berries/UltraBerry.png.import new file mode 100644 index 0000000..9dc5174 --- /dev/null +++ b/Textures/Berries/UltraBerry.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://7fwiqc21hiyt" +path="res://.godot/imported/UltraBerry.png-529cb931871380681f93b86879fe758b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Textures/Berries/UltraBerry.png" +dest_files=["res://.godot/imported/UltraBerry.png-529cb931871380681f93b86879fe758b.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