Initial repo
This commit is contained in:
11
Scenes/PlayerLaser.gd
Normal file
11
Scenes/PlayerLaser.gd
Normal file
@@ -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()
|
||||
30
Scenes/PlayerLaser.tscn
Normal file
30
Scenes/PlayerLaser.tscn
Normal file
@@ -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"]
|
||||
30
Scenes/enemy_laser.tscn
Normal file
30
Scenes/enemy_laser.tscn
Normal file
@@ -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"]
|
||||
29
Scenes/enemy_spawner.tscn
Normal file
29
Scenes/enemy_spawner.tscn
Normal file
@@ -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"]
|
||||
54
Scenes/enemy_xwing.tscn
Normal file
54
Scenes/enemy_xwing.tscn
Normal file
@@ -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"]
|
||||
25
Scenes/missile.tscn
Normal file
25
Scenes/missile.tscn
Normal file
@@ -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"]
|
||||
27
Scenes/missile_pickup.tscn
Normal file
27
Scenes/missile_pickup.tscn
Normal file
@@ -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"]
|
||||
75
Scenes/player.tscn
Normal file
75
Scenes/player.tscn
Normal file
@@ -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"]
|
||||
66
Scenes/world.gd
Normal file
66
Scenes/world.gd
Normal file
@@ -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)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
47
Scenes/world.tscn
Normal file
47
Scenes/world.tscn
Normal file
@@ -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"]
|
||||
Reference in New Issue
Block a user