commit 613fc89bab7e80bbe0a4c3978f03414ff6dead1c Author: zerothelootrat Date: Mon Jun 3 05:29:11 2024 -0400 Initial repo diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8ad74f7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4709183 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Godot 4+ specific ignores +.godot/ diff --git a/Assets/Enemy_Laser.png b/Assets/Enemy_Laser.png new file mode 100644 index 0000000..6943142 Binary files /dev/null and b/Assets/Enemy_Laser.png differ diff --git a/Assets/Enemy_Laser.png.import b/Assets/Enemy_Laser.png.import new file mode 100644 index 0000000..5d5ba29 --- /dev/null +++ b/Assets/Enemy_Laser.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://drigokboj4r5u" +path="res://.godot/imported/Enemy_Laser.png-8e71eb193e066963426ab7ba1d968bf4.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Enemy_Laser.png" +dest_files=["res://.godot/imported/Enemy_Laser.png-8e71eb193e066963426ab7ba1d968bf4.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/Assets/Missile_Container.png b/Assets/Missile_Container.png new file mode 100644 index 0000000..09c4f2a Binary files /dev/null and b/Assets/Missile_Container.png differ diff --git a/Assets/Missile_Container.png.import b/Assets/Missile_Container.png.import new file mode 100644 index 0000000..99eaf38 --- /dev/null +++ b/Assets/Missile_Container.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ba5j4p3o33aye" +path="res://.godot/imported/Missile_Container.png-ea1779a71f50724f19398cf8ceec6752.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Missile_Container.png" +dest_files=["res://.godot/imported/Missile_Container.png-ea1779a71f50724f19398cf8ceec6752.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/Assets/Missile_art1.png b/Assets/Missile_art1.png new file mode 100644 index 0000000..f228339 Binary files /dev/null and b/Assets/Missile_art1.png differ diff --git a/Assets/Missile_art1.png.import b/Assets/Missile_art1.png.import new file mode 100644 index 0000000..c4766a7 --- /dev/null +++ b/Assets/Missile_art1.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b7o2hcw00iic0" +path="res://.godot/imported/Missile_art1.png-97fedf9bd339e7630efd265e170d9a05.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Missile_art1.png" +dest_files=["res://.godot/imported/Missile_art1.png-97fedf9bd339e7630efd265e170d9a05.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/Assets/TIE_Fighter_Tilesheet.png b/Assets/TIE_Fighter_Tilesheet.png new file mode 100644 index 0000000..ee3b421 Binary files /dev/null and b/Assets/TIE_Fighter_Tilesheet.png differ diff --git a/Assets/TIE_Fighter_Tilesheet.png.import b/Assets/TIE_Fighter_Tilesheet.png.import new file mode 100644 index 0000000..18658b3 --- /dev/null +++ b/Assets/TIE_Fighter_Tilesheet.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://besujnvoryjpx" +path="res://.godot/imported/TIE_Fighter_Tilesheet.png-20dbd6b650b7861abc30b2f829fcc83f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/TIE_Fighter_Tilesheet.png" +dest_files=["res://.godot/imported/TIE_Fighter_Tilesheet.png-20dbd6b650b7861abc30b2f829fcc83f.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/Assets/Xwing_tileset_Alphapng.png b/Assets/Xwing_tileset_Alphapng.png new file mode 100644 index 0000000..010a3b0 Binary files /dev/null and b/Assets/Xwing_tileset_Alphapng.png differ diff --git a/Assets/Xwing_tileset_Alphapng.png.import b/Assets/Xwing_tileset_Alphapng.png.import new file mode 100644 index 0000000..7e0a7cc --- /dev/null +++ b/Assets/Xwing_tileset_Alphapng.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cetru5kowfvem" +path="res://.godot/imported/Xwing_tileset_Alphapng.png-6409f04d3b28f4a45889a5011169b7a5.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Xwing_tileset_Alphapng.png" +dest_files=["res://.godot/imported/Xwing_tileset_Alphapng.png-6409f04d3b28f4a45889a5011169b7a5.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/Assets/player_laser.png b/Assets/player_laser.png new file mode 100644 index 0000000..8a263ef Binary files /dev/null and b/Assets/player_laser.png differ diff --git a/Assets/player_laser.png.import b/Assets/player_laser.png.import new file mode 100644 index 0000000..c281317 --- /dev/null +++ b/Assets/player_laser.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bqcadowyi7s5v" +path="res://.godot/imported/player_laser.png-940afffeb223a28d1d940832c1c8c87a.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/player_laser.png" +dest_files=["res://.godot/imported/player_laser.png-940afffeb223a28d1d940832c1c8c87a.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/Scenes/PlayerLaser.gd b/Scenes/PlayerLaser.gd new file mode 100644 index 0000000..fba2c00 --- /dev/null +++ b/Scenes/PlayerLaser.gd @@ -0,0 +1,11 @@ +extends Area2D + +var speed = 1000 + +func _physics_process(delta): + global_position.y += -speed * delta + +func _on_area_entered(area): + if area.is_in_group("enemies"): + area.take_damage(1) + queue_free() diff --git a/Scenes/PlayerLaser.tscn b/Scenes/PlayerLaser.tscn new file mode 100644 index 0000000..b654b70 --- /dev/null +++ b/Scenes/PlayerLaser.tscn @@ -0,0 +1,30 @@ +[gd_scene load_steps=5 format=3 uid="uid://pwxmgtdyo48e"] + +[ext_resource type="Texture2D" uid="uid://bqcadowyi7s5v" path="res://Assets/player_laser.png" id="1_ncg07"] +[ext_resource type="Script" path="res://Scenes/PlayerLaser.gd" id="1_pqlo3"] + +[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_chvsx"] +radius = 3.0 +height = 64.0 + +[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_u0b0p"] +radius = 3.0 +height = 64.0 + +[node name="PlayerLaser" type="Area2D"] +collision_layer = 8 +collision_mask = 5 +script = ExtResource("1_pqlo3") + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("1_ncg07") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(-9, -2) +shape = SubResource("CapsuleShape2D_chvsx") + +[node name="CollisionShape2D2" type="CollisionShape2D" parent="."] +position = Vector2(9, -2) +shape = SubResource("CapsuleShape2D_u0b0p") + +[connection signal="area_entered" from="." to="." method="_on_area_entered"] diff --git a/Scenes/enemy_laser.tscn b/Scenes/enemy_laser.tscn new file mode 100644 index 0000000..15b104d --- /dev/null +++ b/Scenes/enemy_laser.tscn @@ -0,0 +1,30 @@ +[gd_scene load_steps=5 format=3 uid="uid://b7f571cxmtnrg"] + +[ext_resource type="Script" path="res://Scripts/enemy_laser.gd" id="1_8v0e3"] +[ext_resource type="Texture2D" uid="uid://drigokboj4r5u" path="res://Assets/Enemy_Laser.png" id="1_ejt2f"] + +[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_w6ao2"] +radius = 4.0 +height = 80.0 + +[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_mii0d"] +radius = 4.0 +height = 80.0 + +[node name="Area2D" type="Area2D"] +collision_layer = 16 +collision_mask = 3 +script = ExtResource("1_8v0e3") + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("1_ejt2f") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(-63, 1) +shape = SubResource("CapsuleShape2D_w6ao2") + +[node name="CollisionShape2D2" type="CollisionShape2D" parent="."] +position = Vector2(61, 1) +shape = SubResource("CapsuleShape2D_mii0d") + +[connection signal="area_entered" from="." to="." method="_on_area_entered"] diff --git a/Scenes/enemy_spawner.tscn b/Scenes/enemy_spawner.tscn new file mode 100644 index 0000000..f74016a --- /dev/null +++ b/Scenes/enemy_spawner.tscn @@ -0,0 +1,29 @@ +[gd_scene load_steps=2 format=3 uid="uid://cksss7drlqdum"] + +[ext_resource type="Script" path="res://Scripts/enemy_spawner.gd" id="1_urjlx"] + +[node name="EnemySpawner" type="Node2D"] +script = ExtResource("1_urjlx") + +[node name="SpawnPositions" type="Node2D" parent="."] + +[node name="SpawnPosition_01" type="Marker2D" parent="SpawnPositions"] +position = Vector2(70, 0) + +[node name="SpawnPosition_02" type="Marker2D" parent="SpawnPositions"] +position = Vector2(170, 0) + +[node name="SpawnPosition_03" type="Marker2D" parent="SpawnPositions"] +position = Vector2(270, 0) + +[node name="SpawnPosition_04" type="Marker2D" parent="SpawnPositions"] +position = Vector2(370, 0) + +[node name="SpawnPosition_05" type="Marker2D" parent="SpawnPositions"] +position = Vector2(470, 0) + +[node name="SpawnTimer" type="Timer" parent="."] +wait_time = 2.0 +autostart = true + +[connection signal="timeout" from="SpawnTimer" to="." method="_on_spawn_timer_timeout"] diff --git a/Scenes/enemy_xwing.tscn b/Scenes/enemy_xwing.tscn new file mode 100644 index 0000000..efc5709 --- /dev/null +++ b/Scenes/enemy_xwing.tscn @@ -0,0 +1,54 @@ +[gd_scene load_steps=5 format=3 uid="uid://bosls7rmiowe1"] + +[ext_resource type="Texture2D" uid="uid://cetru5kowfvem" path="res://Assets/Xwing_tileset_Alphapng.png" id="1_6o3l6"] +[ext_resource type="Script" path="res://Scripts/enemy_xwing.gd" id="1_rtl0e"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_j5lso"] +atlas = ExtResource("1_6o3l6") +region = Rect2(0, 0, 174, 138) + +[sub_resource type="SpriteFrames" id="SpriteFrames_7n0lo"] +animations = [{ +"frames": [], +"loop": true, +"name": &"death", +"speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_j5lso") +}], +"loop": true, +"name": &"default", +"speed": 5.0 +}] + +[node name="Area2D" type="Area2D" groups=["enemies"]] +collision_layer = 4 +collision_mask = 11 +script = ExtResource("1_rtl0e") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +sprite_frames = SubResource("SpriteFrames_7n0lo") +autoplay = "default" + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."] +polygon = PackedVector2Array(-11, 60, -15, 57, -17, 51, -19, 42, -17, 41, -19, 32, -22, -19, -37, -19, -43, -22, -67, -22, -67, 10, -64, 14, -68, 17, -73, 16, -75, 11, -74, 8, -74, -20, -74, -47, -66, -47, -26, -69, 9, -68, 52, -46, 59, -46, 59, 13, 59, 17, 52, 18, 50, 14, 49, 9, 50, 6, 50, -4, 50, -21, 43, -23, 23, -21, 20, -17, 7, -17, 3, 32, 1, 41, 2, 43, 2, 51, -2, 59, -7, 61) + +[node name="death_timer" type="Timer" parent="."] +wait_time = 0.025 + +[node name="Marker2D" type="Marker2D" parent="."] +position = Vector2(-8, -33) + +[node name="RayCast2D" type="RayCast2D" parent="."] +position = Vector2(-8, 66) +target_position = Vector2(0, 877) +collision_mask = 11 + +[node name="Firing_timer" type="Timer" parent="."] +wait_time = 3.0 + +[connection signal="area_entered" from="." to="." method="_on_area_entered"] +[connection signal="timeout" from="death_timer" to="." method="_on_death_timer_timeout"] +[connection signal="timeout" from="Firing_timer" to="." method="_on_firing_timer_timeout"] diff --git a/Scenes/missile.tscn b/Scenes/missile.tscn new file mode 100644 index 0000000..171cdc7 --- /dev/null +++ b/Scenes/missile.tscn @@ -0,0 +1,25 @@ +[gd_scene load_steps=4 format=3 uid="uid://d1k6v4vsiebym"] + +[ext_resource type="Script" path="res://Scripts/missile.gd" id="1_mehcn"] +[ext_resource type="Texture2D" uid="uid://b7o2hcw00iic0" path="res://Assets/Missile_art1.png" id="1_o2mt4"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_680qv"] +size = Vector2(10, 52) + +[node name="Missile" type="Area2D"] +collision_layer = 8 +collision_mask = 5 +script = ExtResource("1_mehcn") + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("1_o2mt4") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(0, -17) +shape = SubResource("RectangleShape2D_680qv") + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."] +polygon = PackedVector2Array(-3, -8, -88, -161, 95, -161, 3, -8) +disabled = true + +[connection signal="area_entered" from="." to="." method="_on_area_entered"] diff --git a/Scenes/missile_pickup.tscn b/Scenes/missile_pickup.tscn new file mode 100644 index 0000000..6cb2edb --- /dev/null +++ b/Scenes/missile_pickup.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=4 format=3 uid="uid://c86ciqhnl2swc"] + +[ext_resource type="Script" path="res://Scripts/missile_pickup.gd" id="1_0iljv"] +[ext_resource type="Texture2D" uid="uid://ba5j4p3o33aye" path="res://Assets/Missile_Container.png" id="1_nti3e"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_ul5ug"] +size = Vector2(21, 27) + +[node name="missile_pickup" type="Area2D"] +collision_layer = 2 +collision_mask = 10 +script = ExtResource("1_0iljv") + +[node name="Sprite2D" type="Sprite2D" parent="."] +scale = Vector2(0.35, 0.35) +texture = ExtResource("1_nti3e") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(-0.5, -0.5) +shape = SubResource("RectangleShape2D_ul5ug") + +[node name="pickup_despawn" type="Timer" parent="."] +wait_time = 30.0 +one_shot = true + +[connection signal="area_entered" from="." to="." method="_on_area_entered"] +[connection signal="timeout" from="pickup_despawn" to="." method="_on_pickup_despawn_timeout"] diff --git a/Scenes/player.tscn b/Scenes/player.tscn new file mode 100644 index 0000000..c418501 --- /dev/null +++ b/Scenes/player.tscn @@ -0,0 +1,75 @@ +[gd_scene load_steps=9 format=3 uid="uid://bte8o05kqyhvc"] + +[ext_resource type="Script" path="res://Scripts/player.gd" id="1_k4l00"] +[ext_resource type="Texture2D" uid="uid://besujnvoryjpx" path="res://Assets/TIE_Fighter_Tilesheet.png" id="1_sd6i4"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_f6sf8"] +atlas = ExtResource("1_sd6i4") +region = Rect2(0, 0, 74, 69) + +[sub_resource type="AtlasTexture" id="AtlasTexture_sjrp2"] +atlas = ExtResource("1_sd6i4") +region = Rect2(0, 69, 74, 69) + +[sub_resource type="AtlasTexture" id="AtlasTexture_nsx53"] +atlas = ExtResource("1_sd6i4") +region = Rect2(74, 69, 74, 69) + +[sub_resource type="AtlasTexture" id="AtlasTexture_fjfji"] +atlas = ExtResource("1_sd6i4") +region = Rect2(148, 69, 74, 69) + +[sub_resource type="AtlasTexture" id="AtlasTexture_50ply"] +atlas = ExtResource("1_sd6i4") +region = Rect2(222, 69, 74, 69) + +[sub_resource type="SpriteFrames" id="SpriteFrames_8uxfx"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_f6sf8") +}], +"loop": true, +"name": &"default", +"speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_sjrp2") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_nsx53") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_fjfji") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_50ply") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_nsx53") +}], +"loop": false, +"name": &"shoot", +"speed": 20.0 +}] + +[node name="player" type="Area2D"] +collision_layer = 2 +collision_mask = 21 +script = ExtResource("1_k4l00") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +sprite_frames = SubResource("SpriteFrames_8uxfx") +animation = &"shoot" +frame = 4 +frame_progress = 1.0 + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."] +visible = false +polygon = PackedVector2Array(-34, 30, -27, 30, -27, 6, -26, 6, -25, 4, -16, 4, -16, 6, -13, 6, -12, 9, -7, 14, 2, 14, 6, 10, 12, 6, 14, 3, 19, 3, 22, 6, 24, 9, 24, 30, 31, 30, 31, -31, 24, -31, 23, -30, 23, -5, 22, -5, 21, -3, 19, -2, 13, -2, 12, -5, 9, -6, 8, -9, 5, -11, -9, -11, -13, -9, -13, -5, -16, -5, -17, -2, -24, -2, -26, -4, -28, -5, -28, -31, -34, -31, -35, -30, -35, 0, -35, 27) + +[node name="muzzle" type="Marker2D" parent="."] +position = Vector2(-2, -38) + +[connection signal="area_entered" from="." to="." method="_on_area_entered"] diff --git a/Scenes/world.gd b/Scenes/world.gd new file mode 100644 index 0000000..2d34657 --- /dev/null +++ b/Scenes/world.gd @@ -0,0 +1,66 @@ +extends Node2D + +#asset preloading +var Laser = preload("res://Scenes/PlayerLaser.tscn") +var missile = preload("res://Scenes/missile.tscn") +var missile_refil = preload("res://Scenes/missile_pickup.tscn") +var enemy_laser = preload("res://Scenes/enemy_laser.tscn") +@onready var player = $player + +#mixed variables for hud +var score = 0 +var max_health = 3 +var missiles_total = 3 +var missiles_current = 3 + + +func _on_player_spawn_laser(location): + var l = Laser.instantiate() + l.global_position = location + add_child(l) + +func _on_player_spawn_missile(location): + var m = missile.instantiate() + m.global_position = location + add_child(m) + missiles_current -= 1 + $missile_count.text = "Missiles:" + "\n" + str(missiles_current) + "/" + str(missiles_total) + + +func missile_spawn(location): + #print(str(location.global_position)) + var m = missile_refil.instantiate() + m.global_position = location + add_child(m) + +func missile_container(): + #print("signal recieved") + $player.refil_missiles() + missiles_current = 3 + $missile_count.text = "Missiles:" + "\n" + str(missiles_current) + "/" + str(missiles_total) + +func player_health(current_health): + var thing = current_health * 100 / max_health + var display = $health + display.text = "Hull Integrity" + "\n" + str(thing) + "%" + +func scored(): + score += 10 + $Score.text = "Score: " + str(score) + + + + +func fire_enemy_laser(location): + var e = enemy_laser.instantiate() + e.global_position = location + add_child(e) + + + + + + + + + diff --git a/Scenes/world.tscn b/Scenes/world.tscn new file mode 100644 index 0000000..9eb9952 --- /dev/null +++ b/Scenes/world.tscn @@ -0,0 +1,47 @@ +[gd_scene load_steps=4 format=3 uid="uid://da7fcce3oxm8u"] + +[ext_resource type="Script" path="res://Scenes/world.gd" id="1_cxia5"] +[ext_resource type="PackedScene" uid="uid://bte8o05kqyhvc" path="res://Scenes/player.tscn" id="1_hbkp4"] +[ext_resource type="PackedScene" uid="uid://cksss7drlqdum" path="res://Scenes/enemy_spawner.tscn" id="1_ts8nu"] + +[node name="World" type="Node2D"] +script = ExtResource("1_cxia5") + +[node name="EnemySpawner" parent="." instance=ExtResource("1_ts8nu")] +position = Vector2(3, -1) + +[node name="bg" type="Sprite2D" parent="."] + +[node name="player" parent="." instance=ExtResource("1_hbkp4")] +position = Vector2(251, 881) + +[node name="Score" type="Label" parent="."] +offset_left = 18.0 +offset_top = 51.0 +offset_right = 130.0 +offset_bottom = 85.0 +text = "Score: 0" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="health" type="Label" parent="."] +offset_left = 400.0 +offset_top = 899.0 +offset_right = 522.0 +offset_bottom = 948.0 +text = "Hull Integrity: + 100%" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="missile_count" type="Label" parent="."] +offset_left = 13.0 +offset_top = 896.0 +offset_right = 79.0 +offset_bottom = 945.0 +text = "Missiles: +3/3" +horizontal_alignment = 1 + +[connection signal="spawn_laser" from="player" to="." method="_on_player_spawn_laser"] +[connection signal="spawn_missile" from="player" to="." method="_on_player_spawn_missile"] diff --git a/Scripts/enemy_laser.gd b/Scripts/enemy_laser.gd new file mode 100644 index 0000000..89d6e1b --- /dev/null +++ b/Scripts/enemy_laser.gd @@ -0,0 +1,18 @@ +extends Area2D + +var speed = 500 + +func _physics_process(delta): + global_position.y += speed * delta + if global_position.y > 1000: + queue_free() + + +#this is where i do stuff + + + +func _on_area_entered(area): + if area is player: + area.take_damage(1) + queue_free() diff --git a/Scripts/enemy_spawner.gd b/Scripts/enemy_spawner.gd new file mode 100644 index 0000000..db5b43e --- /dev/null +++ b/Scripts/enemy_spawner.gd @@ -0,0 +1,42 @@ +extends Node2D + +signal scored() + +var spawn_positions = null + +var enemy = preload("res://Scenes/enemy_xwing.tscn") + +func _ready(): + randomize() + spawn_positions = $SpawnPositions.get_children() + + +func spawn_enemy(): + var index = randi() % spawn_positions.size() + var enemy = enemy.instantiate() + enemy.global_position = spawn_positions[index].global_position + #connect error. unsure why. + #enemy.connect("enemy_died", get_tree().current_scene, "scored") + add_child(enemy) + +#AI Generated code, doesn't work. connect error +#func spawn_enemy(): + #var index = randi() % spawn_positions.size() + #var enemy_instance = enemy.instantiate() + #var world_node = get_node("res://Scenes/world.tscn") + #var world_script = world_node.get_script() + #enemy_instance.connect("enemy_died", world_script, 10) + #enemy_instance.global_position = spawn_positions[index].global_position + #add_child(enemy_instance) + + + +func _on_spawn_timer_timeout(): + spawn_enemy() + +func enemy_died(): + emit_signal("scored") + + +func missile_spawn(): + print("Missile") diff --git a/Scripts/enemy_xwing.gd b/Scripts/enemy_xwing.gd new file mode 100644 index 0000000..16f5f53 --- /dev/null +++ b/Scripts/enemy_xwing.gd @@ -0,0 +1,86 @@ +extends Area2D + +signal enemy_died() + +@export var speed : int = 150 + +#position where the thing shoots from +@onready var marker = $Marker2D + +#sensor location, central just for testing +@onready var ray1 = $RayCast2D + +signal missile_spawn() + +#health, duh. +var health = 3 + +#had to add for things that require sensors, going to require moving one for turrets maybe? +#for tutorial https://www.youtube.com/watch?v=V_gaCLbWqzk&ab_channel=KaanAlpar +func _ready(): + ray1.exclude_parent = true + ray1.collide_with_areas = true + + +#setting variable if it can shoot used later. +var can_shoot = true +#testing for the raycast feature. +#func _process(delta): + #print(ray1.is_colliding()) + #print(ray1.get_collider()) + +func _physics_process(delta): + #movement + global_position.y += speed * delta + #detecting player in area. + if ray1.is_colliding and ray1.get_collider() is player: + if can_shoot == true: + #shooting + fire_enemy_laser() + #starting firing timer so it cant just spam. + $Firing_timer.start() + can_shoot = false + +func take_damage(damage): + health -= damage + if health <= 0: + $death_timer.start() + #$AnimatedSprite2D.play("death") + emit_signal("enemy_died") + get_tree().current_scene.scored() + power_up_check() + #print(str(get_tree().current_scene.player.global_position)) + + + +func fire_enemy_laser(): + get_tree().current_scene.fire_enemy_laser(marker.global_position) + +func power_up_check(): + var index = randi() % 51 + + # 1 - 40 does nothing + # 40-48 spawns missiles + # 49 spawns nothing + # 50 spawns nothing + + #1-39+ 40 does nothing. + if index <= 39: + pass + # if greater than or equal to 40, and less than or equal to 48 it spawns stuff + elif index >= 40 and index <= 48: + get_tree().current_scene.missile_spawn(marker.global_position) + + #get_tree().current_scene.missile_spawn(marker.global_position) + +func _on_area_entered(area): + if area is player: + area.take_damage(1) + + +func _on_death_timer_timeout(): + queue_free() # Replace with function body. + + +func _on_firing_timer_timeout(): + can_shoot = true diff --git a/Scripts/missile.gd b/Scripts/missile.gd new file mode 100644 index 0000000..dfc037d --- /dev/null +++ b/Scripts/missile.gd @@ -0,0 +1,17 @@ +extends Area2D + +var speed = 200 +@onready var FirstStage = $CollisionShape2D +@onready var SecondStage = $CollisionPolygon2D + +func _physics_process(delta): + global_position.y += -speed * delta + + + +func _on_area_entered(area): + if area.is_in_group("enemies"): + FirstStage.disabled = true + SecondStage.disabled = false + area.take_damage(5) + queue_free() diff --git a/Scripts/missile_pickup.gd b/Scripts/missile_pickup.gd new file mode 100644 index 0000000..3e70863 --- /dev/null +++ b/Scripts/missile_pickup.gd @@ -0,0 +1,26 @@ +extends Area2D + + + +var speed = 200 + +func _ready(): + $pickup_despawn.start() + #print("ready started") + +func _physics_process(delta): + global_position.y += speed * delta + #asset clean up + if global_position.y > 980: + queue_free() + + +func _on_area_entered(area): + if area is player: + get_tree().current_scene.missile_container() + queue_free() + +#timer might be redundant, remove later +func _on_pickup_despawn_timeout(): + print("time out") + queue_free() diff --git a/Scripts/player.gd b/Scripts/player.gd new file mode 100644 index 0000000..a01cdba --- /dev/null +++ b/Scripts/player.gd @@ -0,0 +1,78 @@ +extends Area2D +class_name player + +#setting up signals +signal spawn_laser(location) +signal spawn_missile(location) + +#loading the muzzle position on load +@onready var muzzle = $muzzle + +#speed, health and direction, direction is for future animations vector sets up an Axis. +var speed = 250 +var health = 3 +var direction = "none" +var input_vector = Vector2() + +var missile_total = 3 +var missile_current = 3 +#mostly movement stuff below, + some firing commands, check happens between every frame +func _physics_process(delta): + input_vector.x = 0 + if Input.is_action_pressed("move_right"): + input_vector.x += 1 + direction = "right" + if Input.is_action_pressed("move_left"): + input_vector.x -= 1 + direction = "left" + + input_vector.y = 0 + if Input.is_action_pressed("move_forward"): + #print("fwd") + input_vector.y -= 1 + if Input.is_action_pressed("move_back"): + input_vector.y += 1 + global_position += input_vector * speed * delta + + if Input.is_action_just_pressed("shoot"): + $AnimatedSprite2D.play("shoot") + shoot_laser() + #$AnimatedSprite2D.play("default") + + #Missile launching signal + if Input.is_action_just_pressed("fire_missile"): + if missile_current > 0: + $AnimatedSprite2D.play("shoot") + shoot_missile() + missile_current -= 1 + print(str(missile_current)) + else: + print("No Missiles") + +#if entering an area with enemy, DO damage. +func take_damage(damage): + health -= damage + get_tree().current_scene.player_health(health) + if health <= 0: + get_tree().current_scene.player_health(health) + queue_free() + +#if entering an area with enemy = collision, does 1 damage +func _on_area_entered(area): + if area.is_in_group("enemies"): + area.take_damage(1) + +#sends laser shoot command to worl + muzzle position +func shoot_laser(): + emit_signal("spawn_laser",muzzle.global_position) + +#sends missile launch command to world + muzzle position +func shoot_missile(): + emit_signal("spawn_missile",muzzle.global_position) + + +func refil_missiles(): + if missile_current < missile_total: + missile_current = missile_total + else: + pass diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..3fe4f4a --- /dev/null +++ b/icon.svg @@ -0,0 +1 @@ + diff --git a/icon.svg.import b/icon.svg.import new file mode 100644 index 0000000..814d9c5 --- /dev/null +++ b/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://br1cr3qk2w2wy" +path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.svg" +dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.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 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..0ffac6c --- /dev/null +++ b/project.godot @@ -0,0 +1,67 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="SWGalaga" +run/main_scene="res://Scenes/world.tscn" +config/features=PackedStringArray("4.2", "Mobile") +config/icon="res://icon.svg" + +[display] + +window/size/viewport_width=540 +window/size/viewport_height=960 +window/handheld/orientation=1 + +[input] + +move_right={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"echo":false,"script":null) +] +} +move_left={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"echo":false,"script":null) +] +} +move_forward={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"echo":false,"script":null) +] +} +move_back={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"echo":false,"script":null) +] +} +shoot={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"echo":false,"script":null) +] +} +fire_missile={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"echo":false,"script":null) +] +} + +[layer_names] + +2d_physics/layer_1="env" +2d_physics/layer_2="player" +2d_physics/layer_3="enemies" +2d_physics/layer_4="player_laser" +2d_physics/layer_5="enemy_laser" + +[rendering] + +renderer/rendering_method="mobile"