commit a4452b69c4be4f711fc052ff1fbcd917f5be04a7 Author: Benjamin Morgan Date: Sun Oct 19 20:04:59 2025 -0600 Init commit diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f28239b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +root = true + +[*] +charset = utf-8 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..0af181c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# Godot 4+ specific ignores +.godot/ +/android/ diff --git a/Enemies/Scenes/asteroid.tscn b/Enemies/Scenes/asteroid.tscn new file mode 100644 index 0000000..33f2c24 --- /dev/null +++ b/Enemies/Scenes/asteroid.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=4 format=3 uid="uid://1jbq4x3kmhn1"] + +[ext_resource type="Script" uid="uid://cg4pd7sdvx3qc" path="res://Enemies/Scripts/asteroid.gd" id="1_wfjj5"] +[ext_resource type="Texture2D" uid="uid://cv84w0y2jg3i3" path="res://Sprites/i_are_spaceship.png" id="2_3al5e"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_p0ukn"] +radius = 6.0 + +[node name="Asteroid" type="Area2D"] +script = ExtResource("1_wfjj5") + +[node name="Sprite2D" type="Sprite2D" parent="."] +scale = Vector2(2, 2) +texture = ExtResource("2_3al5e") +region_enabled = true +region_rect = Rect2(41, 17, 6, 6) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_p0ukn") diff --git a/Enemies/Scenes/asteroidBig.tscn b/Enemies/Scenes/asteroidBig.tscn new file mode 100644 index 0000000..7d8f449 --- /dev/null +++ b/Enemies/Scenes/asteroidBig.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=4 format=3 uid="uid://dx86f17gehnea"] + +[ext_resource type="Script" uid="uid://cg4pd7sdvx3qc" path="res://Enemies/Scripts/asteroid.gd" id="1_tn6au"] +[ext_resource type="Texture2D" uid="uid://cv84w0y2jg3i3" path="res://Sprites/i_are_spaceship.png" id="2_pp4o0"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_1l7hq"] +radius = 7.0 + +[node name="Asteroid" type="Area2D"] +script = ExtResource("1_tn6au") + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("2_pp4o0") +region_enabled = true +region_rect = Rect2(32, 2, 15, 13) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(1, 0) +shape = SubResource("CircleShape2D_1l7hq") diff --git a/Enemies/Scenes/asteroidSm.tscn b/Enemies/Scenes/asteroidSm.tscn new file mode 100644 index 0000000..bbc9b38 --- /dev/null +++ b/Enemies/Scenes/asteroidSm.tscn @@ -0,0 +1,21 @@ +[gd_scene load_steps=4 format=3 uid="uid://cl6diy6jr73gw"] + +[ext_resource type="Script" uid="uid://cg4pd7sdvx3qc" path="res://Enemies/Scripts/asteroid.gd" id="1_csx0u"] +[ext_resource type="Texture2D" uid="uid://cv84w0y2jg3i3" path="res://Sprites/i_are_spaceship.png" id="2_cn0tk"] + +[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_ft5of"] +radius = 6.0 +height = 16.0 + +[node name="Asteroid" type="Area2D"] +script = ExtResource("1_csx0u") + +[node name="Sprite2D" type="Sprite2D" parent="."] +scale = Vector2(3, 3) +texture = ExtResource("2_cn0tk") +region_enabled = true +region_rect = Rect2(34, 26, 4, 5) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(0, 1) +shape = SubResource("CapsuleShape2D_ft5of") diff --git a/Enemies/Scenes/asteroidTiny.tscn b/Enemies/Scenes/asteroidTiny.tscn new file mode 100644 index 0000000..7e1a0ba --- /dev/null +++ b/Enemies/Scenes/asteroidTiny.tscn @@ -0,0 +1,21 @@ +[gd_scene load_steps=4 format=3 uid="uid://3l5rlho4v4l3"] + +[ext_resource type="Script" uid="uid://cg4pd7sdvx3qc" path="res://Enemies/Scripts/asteroid.gd" id="1_ub6x2"] +[ext_resource type="Texture2D" uid="uid://cv84w0y2jg3i3" path="res://Sprites/i_are_spaceship.png" id="2_m5fot"] + +[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_8kah6"] +radius = 2.8242884 +height = 9.961488 + +[node name="Asteroid" type="Area2D"] +script = ExtResource("1_ub6x2") + +[node name="Sprite2D" type="Sprite2D" parent="."] +scale = Vector2(2, 2) +texture = ExtResource("2_m5fot") +region_enabled = true +region_rect = Rect2(42, 26, 4, 4) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +rotation = 0.73129296 +shape = SubResource("CapsuleShape2D_8kah6") diff --git a/Enemies/Scripts/asteroid.gd b/Enemies/Scripts/asteroid.gd new file mode 100644 index 0000000..ab22ec4 --- /dev/null +++ b/Enemies/Scripts/asteroid.gd @@ -0,0 +1,28 @@ +extends Area2D + +var velocity = Vector2(0, 0) +var rot_velocity = 0 +var explosion = preload('res://Scenes/explosion.tscn') +var pop = preload("res://Sounds/Explosion5.wav") + +func _ready() -> void: + connect("body_entered", _on_body_entered) + +func _physics_process(delta): + position += velocity * delta + rotation += rot_velocity * delta + + Utils.wrap_position(self) + +func _on_body_entered(body): + if body.name == "Ship": + Game.set_lives(Game.lives - 1) + + Utils.play_sound(pop, get_parent()) + + var boom = explosion.instantiate() + boom.position = body.global_position + boom.scale = Vector2(6, 6) + get_parent().add_child(boom) + body.reset() + queue_free() diff --git a/Enemies/Scripts/asteroid.gd.uid b/Enemies/Scripts/asteroid.gd.uid new file mode 100644 index 0000000..9225140 --- /dev/null +++ b/Enemies/Scripts/asteroid.gd.uid @@ -0,0 +1 @@ +uid://cg4pd7sdvx3qc diff --git a/Scenes/explosion.tscn b/Scenes/explosion.tscn new file mode 100644 index 0000000..0ee2efc --- /dev/null +++ b/Scenes/explosion.tscn @@ -0,0 +1,55 @@ +[gd_scene load_steps=8 format=3 uid="uid://g6cu38jl3h32"] + +[ext_resource type="Script" uid="uid://lawrmxvtimw1" path="res://Scripts/explosion.gd" id="1_a801j"] +[ext_resource type="Texture2D" uid="uid://cv84w0y2jg3i3" path="res://Sprites/i_are_spaceship.png" id="2_4okmj"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_vxas0"] +atlas = ExtResource("2_4okmj") +region = Rect2(48, 31, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_j4sxf"] +atlas = ExtResource("2_4okmj") +region = Rect2(32, 31, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_m5xho"] +atlas = ExtResource("2_4okmj") +region = Rect2(16, 31, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_kmxf7"] +atlas = ExtResource("2_4okmj") +region = Rect2(0, 31, 16, 16) + +[sub_resource type="SpriteFrames" id="SpriteFrames_l04k4"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_vxas0") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_j4sxf") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_m5xho") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_kmxf7") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_j4sxf") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_vxas0") +}], +"loop": true, +"name": &"default", +"speed": 12.0 +}] + +[node name="Node2D" type="Node2D"] + +[node name="Area2D" type="Area2D" parent="."] +script = ExtResource("1_a801j") + +[node name="Explosion" type="AnimatedSprite2D" parent="Area2D"] +sprite_frames = SubResource("SpriteFrames_l04k4") +autoplay = "default" diff --git a/Scenes/game_over.tscn b/Scenes/game_over.tscn new file mode 100644 index 0000000..1a2407a --- /dev/null +++ b/Scenes/game_over.tscn @@ -0,0 +1,67 @@ +[gd_scene load_steps=4 format=3 uid="uid://dliccivjx8fcm"] + +[ext_resource type="Script" uid="uid://cf1vwutwpi4rf" path="res://Scripts/game_over.gd" id="1_ojehl"] + +[sub_resource type="LabelSettings" id="LabelSettings_i2yjh"] +font_size = 72 + +[sub_resource type="LabelSettings" id="LabelSettings_ojehl"] +font_size = 32 + +[node name="Control" type="Control"] +layout_mode = 3 +anchors_preset = 14 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_ojehl") + +[node name="Container" type="Control" parent="."] +layout_mode = 1 +anchors_preset = 13 +anchor_left = 0.5 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_top = -100.0 +offset_bottom = -100.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Title" type="Label" parent="Container"] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -195.0 +offset_right = 195.0 +offset_bottom = 99.0 +grow_horizontal = 2 +text = "Game Over" +label_settings = SubResource("LabelSettings_i2yjh") + +[node name="Score" type="Label" parent="Container"] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -60.5 +offset_top = 85.0 +offset_right = 60.5 +offset_bottom = 130.0 +grow_horizontal = 2 +text = "Score: 0" +label_settings = SubResource("LabelSettings_ojehl") + +[node name="New Game" type="Button" parent="Container"] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -46.5 +offset_top = 150.0 +offset_right = 46.5 +offset_bottom = 181.0 +grow_horizontal = 2 +text = "New Game" diff --git a/Scenes/laser.tscn b/Scenes/laser.tscn new file mode 100644 index 0000000..910b672 --- /dev/null +++ b/Scenes/laser.tscn @@ -0,0 +1,21 @@ +[gd_scene load_steps=4 format=3 uid="uid://nf2xr7ufei5a"] + +[ext_resource type="Script" uid="uid://csldj2x1axso1" path="res://Scripts/laser.gd" id="1_6vqwg"] +[ext_resource type="Texture2D" uid="uid://cv84w0y2jg3i3" path="res://Sprites/i_are_spaceship.png" id="1_fn5yt"] + +[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_6vqwg"] +radius = 3.0 +height = 10.0 + +[node name="Laser" type="Area2D"] +script = ExtResource("1_6vqwg") + +[node name="Sprite2D" type="Sprite2D" parent="."] +position = Vector2(-1, 1) +scale = Vector2(2, 2) +texture = ExtResource("1_fn5yt") +region_enabled = true +region_rect = Rect2(34, 17, 3, 7) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CapsuleShape2D_6vqwg") diff --git a/Scenes/life.tscn b/Scenes/life.tscn new file mode 100644 index 0000000..10176c8 --- /dev/null +++ b/Scenes/life.tscn @@ -0,0 +1,9 @@ +[gd_scene load_steps=2 format=3 uid="uid://j2mr8pluyo37"] + +[ext_resource type="Texture2D" uid="uid://cvfsmhdbgh8vh" path="res://Sprites/idle_spaceship.png" id="1_bkce2"] + +[node name="Life" type="TextureRect"] +offset_right = 15.0 +offset_bottom = 24.0 +texture = ExtResource("1_bkce2") +stretch_mode = 4 diff --git a/Scenes/main_menu.tscn b/Scenes/main_menu.tscn new file mode 100644 index 0000000..0ccec31 --- /dev/null +++ b/Scenes/main_menu.tscn @@ -0,0 +1,64 @@ +[gd_scene load_steps=3 format=3 uid="uid://c4ld5hjy5d8g3"] + +[ext_resource type="Script" uid="uid://dxbdiq4y3mqtd" path="res://Scripts/main_menu.gd" id="1_28flt"] + +[sub_resource type="LabelSettings" id="LabelSettings_i2yjh"] +font_size = 72 + +[node name="Control" type="Control"] +layout_mode = 3 +anchors_preset = 14 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_28flt") + +[node name="Container" type="Control" parent="."] +layout_mode = 1 +anchors_preset = 13 +anchor_left = 0.5 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_top = -100.0 +offset_bottom = -100.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Title" type="Label" parent="Container"] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -195.0 +offset_right = 195.0 +offset_bottom = 99.0 +grow_horizontal = 2 +text = "Asteroids" +label_settings = SubResource("LabelSettings_i2yjh") +horizontal_alignment = 1 + +[node name="New Game" type="Button" parent="Container"] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -46.5 +offset_top = 111.0 +offset_right = 46.5 +offset_bottom = 142.0 +grow_horizontal = 2 +text = "New Game" + +[node name="Quit" type="Button" parent="Container"] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -46.5 +offset_top = 150.0 +offset_right = 46.5 +offset_bottom = 181.0 +grow_horizontal = 2 +text = "Quit" diff --git a/Scenes/ship.tscn b/Scenes/ship.tscn new file mode 100644 index 0000000..164ecc9 --- /dev/null +++ b/Scenes/ship.tscn @@ -0,0 +1,97 @@ +[gd_scene load_steps=16 format=3 uid="uid://dwvw8qerrwuu0"] + +[ext_resource type="Script" uid="uid://p443pc5fxxg0" path="res://Scripts/ship.gd" id="1_6ejuo"] +[ext_resource type="PackedScene" uid="uid://nf2xr7ufei5a" path="res://Scenes/laser.tscn" id="2_8aq7e"] +[ext_resource type="Texture2D" uid="uid://bdwr76wwjquob" path="res://Sprites/fly_spaceship.png" id="3_cmder"] +[ext_resource type="AudioStream" uid="uid://docuh1bqh2uba" path="res://Sounds/laser4.wav" id="3_fwcnm"] +[ext_resource type="Texture2D" uid="uid://cvfsmhdbgh8vh" path="res://Sprites/idle_spaceship.png" id="4_fwcnm"] +[ext_resource type="Texture2D" uid="uid://dtcdw0p6jcw00" path="res://Sprites/left_spaceship.png" id="5_cmder"] +[ext_resource type="Texture2D" uid="uid://c0quqc1en7jo" path="res://Sprites/right_spaceship.png" id="6_fwcnm"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_272bh"] +atlas = ExtResource("3_cmder") +region = Rect2(15, 0, 15, 24) + +[sub_resource type="AtlasTexture" id="AtlasTexture_5vw27"] +atlas = ExtResource("3_cmder") +region = Rect2(0, 0, 15, 24) + +[sub_resource type="AtlasTexture" id="AtlasTexture_kxdp2"] +atlas = ExtResource("5_cmder") +region = Rect2(15, 0, 15, 24) + +[sub_resource type="AtlasTexture" id="AtlasTexture_v2j2m"] +atlas = ExtResource("5_cmder") +region = Rect2(0, 0, 15, 24) + +[sub_resource type="AtlasTexture" id="AtlasTexture_1m05r"] +atlas = ExtResource("6_fwcnm") +region = Rect2(15, 0, 15, 24) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ssryt"] +atlas = ExtResource("6_fwcnm") +region = Rect2(0, 0, 15, 24) + +[sub_resource type="SpriteFrames" id="SpriteFrames_1bvp3"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_272bh") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_5vw27") +}], +"loop": true, +"name": &"fly", +"speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": ExtResource("4_fwcnm") +}], +"loop": true, +"name": &"idle", +"speed": 0.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_kxdp2") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_v2j2m") +}], +"loop": true, +"name": &"left", +"speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_1m05r") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ssryt") +}], +"loop": true, +"name": &"right", +"speed": 5.0 +}] + +[sub_resource type="ConvexPolygonShape2D" id="ConvexPolygonShape2D_kek77"] +points = PackedVector2Array(-6, 0, -7, 7, 8, 7, 7, 0, 0, -8) + +[node name="Ship" type="CharacterBody2D"] +script = ExtResource("1_6ejuo") +Laser = ExtResource("2_8aq7e") +pew = ExtResource("3_fwcnm") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +sprite_frames = SubResource("SpriteFrames_1bvp3") +animation = &"right" +autoplay = "idle" + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(0, -4) +shape = SubResource("ConvexPolygonShape2D_kek77") + +[node name="Muzzle" type="Marker2D" parent="."] +position = Vector2(0, -15) diff --git a/Scripts/explosion.gd b/Scripts/explosion.gd new file mode 100644 index 0000000..1235b86 --- /dev/null +++ b/Scripts/explosion.gd @@ -0,0 +1,7 @@ +extends Area2D + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + # Free self after 1.5 seconds + await get_tree().create_timer(0.5).timeout + queue_free() diff --git a/Scripts/explosion.gd.uid b/Scripts/explosion.gd.uid new file mode 100644 index 0000000..ac9ed2f --- /dev/null +++ b/Scripts/explosion.gd.uid @@ -0,0 +1 @@ +uid://lawrmxvtimw1 diff --git a/Scripts/game.gd b/Scripts/game.gd new file mode 100644 index 0000000..140b5ba --- /dev/null +++ b/Scripts/game.gd @@ -0,0 +1,88 @@ +extends Node2D + +var score: int = 0 +var lives: int = 0 +var added_lives: int = 0 +var score_label: Label +var lives_box: HBoxContainer +var spawner: Node2D +var player: CharacterBody2D +var ui: CanvasLayer +var game_over_ui: Control +var menu_ui: Control +var life_icon = preload("res://Scenes/life.tscn") +var menu_scn = preload("res://Scenes/main_menu.tscn") +var game_over_scn = preload("res://Scenes/game_over.tscn") +var ship = preload("res://Scenes/ship.tscn") +var life = preload("res://Sounds/extra_life.wav") + +func _ready() -> void: + menu_ui = menu_scn.instantiate() + menu_ui.new_game.connect(_new_game) + menu_ui.quit_game.connect(_quit_game) + + await get_tree().process_frame + ui.add_child(menu_ui) + +func set_score(amount: int): + score = amount + score_label.text = "Score: " + str(score) + + if floor(score / 10000.0) > added_lives: + added_lives += 1 + set_lives(lives + 1) + + var snd = AudioStreamPlayer.new() + add_child(snd) + snd.stream = life + snd.play() + snd.finished.connect(func(): snd.queue_free()) + +func set_lives(amount: int): + lives = amount + + var icons = lives_box.get_children() + + var diff = lives - len(icons); + if diff > 0: + for i in range(diff): + lives_box.add_child(life_icon.instantiate()) + else: + if lives >= 0: + for i in range(abs(diff)): + lives_box.remove_child(icons[len(icons) - 1]) + icons.remove_at(len(icons) - 1) + + if lives == 0: + spawner.stop() + for node in get_tree().get_nodes_in_group("enemies"): + node.queue_free() + + player.queue_free() + + score_label.visible = false + game_over_ui = game_over_scn.instantiate() + game_over_ui.new_game.connect(_new_game) + game_over_ui.set_score(score) + ui.add_child(game_over_ui) + +func _new_game(): + if score_label: + score_label.visible = true + set_lives(3) + spawner.start() + set_score(0) + + if game_over_ui: + game_over_ui.queue_free() + + if menu_ui: + menu_ui.queue_free() + + player = ship.instantiate() + player.position = get_viewport_rect().size / 2 + + get_tree().current_scene.add_child(player) + +func _quit_game(): + get_tree().quit() diff --git a/Scripts/game.gd.uid b/Scripts/game.gd.uid new file mode 100644 index 0000000..568c71c --- /dev/null +++ b/Scripts/game.gd.uid @@ -0,0 +1 @@ +uid://bs4d2x1ylus1m diff --git a/Scripts/game_over.gd b/Scripts/game_over.gd new file mode 100644 index 0000000..af2fbd8 --- /dev/null +++ b/Scripts/game_over.gd @@ -0,0 +1,12 @@ +extends Control + +signal new_game + +func set_score(amount: int): + $Container/Score.text = "Score: " + str(amount) + +func _ready(): + $"Container/New Game".pressed.connect(_emit_new) + +func _emit_new(): + emit_signal("new_game") diff --git a/Scripts/game_over.gd.uid b/Scripts/game_over.gd.uid new file mode 100644 index 0000000..a6813da --- /dev/null +++ b/Scripts/game_over.gd.uid @@ -0,0 +1 @@ +uid://cf1vwutwpi4rf diff --git a/Scripts/laser.gd b/Scripts/laser.gd new file mode 100644 index 0000000..dd9abed --- /dev/null +++ b/Scripts/laser.gd @@ -0,0 +1,37 @@ +extends Area2D + +var explosion = preload('res://Scenes/explosion.tscn') +var pop = preload("res://Sounds/Explosion.wav") +var speed = 750 + +var half_size: Vector2 # half of sprite dimensions (used for wrapping) + +func _ready() -> void: + connect("area_entered", _on_body_entered) + + half_size = Utils.get_half_size(self) + +func _physics_process(delta): + position += -transform.y * speed * delta + + var rect = get_viewport_rect() + + if position.x < -half_size.x or position.x > rect.size.x + half_size.x or position.y < -half_size.y or position.y > rect.size.y + half_size.y: + #print_debug("FREED") + queue_free() + +func _on_body_entered(body): + if body.is_in_group("enemies"): + body.queue_free() + + Utils.play_sound(pop, get_parent()) + + var boom = explosion.instantiate() + boom.position = body.global_position + boom.scale = body.scale + get_parent().add_child(boom) + + Game.set_score(Game.score + 100) + + queue_free() + #print_debug("KILLED") diff --git a/Scripts/laser.gd.uid b/Scripts/laser.gd.uid new file mode 100644 index 0000000..26761ac --- /dev/null +++ b/Scripts/laser.gd.uid @@ -0,0 +1 @@ +uid://csldj2x1axso1 diff --git a/Scripts/lives.gd b/Scripts/lives.gd new file mode 100644 index 0000000..4dadd5d --- /dev/null +++ b/Scripts/lives.gd @@ -0,0 +1,6 @@ +extends HBoxContainer + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + Game.lives_box = self diff --git a/Scripts/lives.gd.uid b/Scripts/lives.gd.uid new file mode 100644 index 0000000..095af43 --- /dev/null +++ b/Scripts/lives.gd.uid @@ -0,0 +1 @@ +uid://miwfeu4n6uh7 diff --git a/Scripts/main_menu.gd b/Scripts/main_menu.gd new file mode 100644 index 0000000..c2d8321 --- /dev/null +++ b/Scripts/main_menu.gd @@ -0,0 +1,14 @@ +extends Control + +signal new_game +signal quit_game + +func _ready(): + $"Container/New Game".pressed.connect(_emit_new) + $Container/Quit.pressed.connect(_emit_quit) + +func _emit_new(): + emit_signal("new_game") + +func _emit_quit(): + emit_signal("quit_game") diff --git a/Scripts/main_menu.gd.uid b/Scripts/main_menu.gd.uid new file mode 100644 index 0000000..0a66a82 --- /dev/null +++ b/Scripts/main_menu.gd.uid @@ -0,0 +1 @@ +uid://dxbdiq4y3mqtd diff --git a/Scripts/score.gd b/Scripts/score.gd new file mode 100644 index 0000000..44792ff --- /dev/null +++ b/Scripts/score.gd @@ -0,0 +1,6 @@ +extends Label + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + Game.score_label = self diff --git a/Scripts/score.gd.uid b/Scripts/score.gd.uid new file mode 100644 index 0000000..e95ebf3 --- /dev/null +++ b/Scripts/score.gd.uid @@ -0,0 +1 @@ +uid://efye4dftj3u6 diff --git a/Scripts/ship.gd b/Scripts/ship.gd new file mode 100644 index 0000000..e2b8ee6 --- /dev/null +++ b/Scripts/ship.gd @@ -0,0 +1,63 @@ +extends CharacterBody2D + +const ROT_SPEED = 3.0 +const MOVE_ACC = 100 +const FRICTION = 0.995 +const FIRE_RATE = 0.2 + +@export var Laser: PackedScene +@export var pew: Resource + +var speed = Vector2(0, 0) +var last_shot = 0.0 + +func _ready() -> void: + Game.player = self + +func _physics_process(delta: float) -> void: + var forward = Input.is_action_pressed("ui_up") + var left = Input.is_action_pressed("ui_left") + var right = Input.is_action_pressed("ui_right") + + if left: + rotation -= ROT_SPEED * delta + + if $AnimatedSprite2D.animation != "left": + $AnimatedSprite2D.play("left") + if right: + rotation += ROT_SPEED * delta + + if $AnimatedSprite2D.animation != "right": + $AnimatedSprite2D.play("right") + if forward: + speed += Vector2.UP.rotated(rotation) * MOVE_ACC * delta + + if $AnimatedSprite2D.animation != "fly": + $AnimatedSprite2D.play("fly") + if Input.is_action_pressed("ui_down"): + speed -= Vector2.UP.rotated(rotation) * MOVE_ACC * delta + + if !(forward || left || right) and $AnimatedSprite2D.animation != "idle": + $AnimatedSprite2D.play("idle") + + speed *= FRICTION + velocity = speed + + move_and_slide() + + Utils.wrap_position(self) + + # --- Fire projectile on space --- + last_shot += delta + if Input.is_action_pressed("ui_accept") and last_shot >= FIRE_RATE: # default = Space/Enter + var bullet = Laser.instantiate() + + Utils.play_sound(pew, self) + + get_parent().add_child(bullet) + bullet.transform = $Muzzle.global_transform + last_shot = 0.0 + +func reset(): + position = get_viewport_rect().size / 2 + speed = Vector2(0, 0) diff --git a/Scripts/ship.gd.uid b/Scripts/ship.gd.uid new file mode 100644 index 0000000..2dc93d6 --- /dev/null +++ b/Scripts/ship.gd.uid @@ -0,0 +1 @@ +uid://p443pc5fxxg0 diff --git a/Scripts/spawner.gd b/Scripts/spawner.gd new file mode 100644 index 0000000..81a4e9b --- /dev/null +++ b/Scripts/spawner.gd @@ -0,0 +1,84 @@ +extends Node2D + +var timer: Timer +var asteroids := [ + preload('res://Enemies/Scenes/asteroidTiny.tscn'), + preload('res://Enemies/Scenes/asteroidSm.tscn'), + preload('res://Enemies/Scenes/asteroid.tscn'), + preload('res://Enemies/Scenes/asteroidBig.tscn') +] +var screen_size: Vector2 + +func _ready(): + Game.spawner = self + + screen_size = get_viewport_rect().size + # Call spawn_enemy() every spawn_interval seconds + timer = Timer.new() + timer.wait_time = spawn_time_from_score(Game.score) + timer.timeout.connect(spawn_enemy) + add_child(timer) + +func spawn_time_from_score(score: int) -> float: + var min_time = 0.3 + var max_time = 2.0 + var max_score = 50000.0 + + # Clamp score so it doesn’t overshoot + var clamped_score = clamp(score, 0, max_score) + + # Normalized value [0..1] + var t = float(clamped_score) / max_score + + # Logarithmic easing (slows down progression) + # Use log10 but you can tweak the base for different curves + var curved_t = log(1.0 + 9.0 * t) / log(10.0) # maps 0..1 to 0..1, but with log shape + + # Interpolate between max_time and min_time + return lerp(max_time, min_time, curved_t) + +func spawn_enemy(): + var enemy = asteroids[randi_range(0, 3)].instantiate() + var pos = get_random_edge_position() + enemy.position = pos + + # Direction vector toward center + var center = screen_size * 0.5 + var dir = (center - pos).normalized() + + # Add some randomness so it's not always perfect + var angle_variation = randf_range(-0.5, 0.5) # radians (~±14 degrees) + dir = dir.rotated(angle_variation) + + # Apply starting velocity + enemy.rot_velocity = randf_range(0, PI) + enemy.velocity = dir * randf_range(50, 200) + enemy.rotation = randf_range(0, PI) + + var scl = randi_range(1, 5) + enemy.scale = Vector2(scl, scl) + + enemy.add_to_group("enemies") + add_child(enemy) + + timer.wait_time = spawn_time_from_score(Game.score) + +func get_random_edge_position() -> Vector2: + # Pick which edge (0=top,1=bottom,2=left,3=right) + var edge = randi() % 4 + match edge: + 0: # top + return Vector2(randf() * screen_size.x, 0) + 1: # bottom + return Vector2(randf() * screen_size.x, screen_size.y) + 2: # left + return Vector2(0, randf() * screen_size.y) + 3: # right + return Vector2(screen_size.x, randf() * screen_size.y) + return Vector2.ZERO + +func stop(): + timer.stop() + +func start(): + timer.start() diff --git a/Scripts/spawner.gd.uid b/Scripts/spawner.gd.uid new file mode 100644 index 0000000..797bec3 --- /dev/null +++ b/Scripts/spawner.gd.uid @@ -0,0 +1 @@ +uid://mfgrqlsgsyrx diff --git a/Scripts/ui.gd b/Scripts/ui.gd new file mode 100644 index 0000000..19acad4 --- /dev/null +++ b/Scripts/ui.gd @@ -0,0 +1,6 @@ +extends CanvasLayer + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + Game.ui = self diff --git a/Scripts/ui.gd.uid b/Scripts/ui.gd.uid new file mode 100644 index 0000000..b9560e0 --- /dev/null +++ b/Scripts/ui.gd.uid @@ -0,0 +1 @@ +uid://dpa4j6me328ak diff --git a/Scripts/utils.gd b/Scripts/utils.gd new file mode 100644 index 0000000..dea0919 --- /dev/null +++ b/Scripts/utils.gd @@ -0,0 +1,43 @@ +extends Node2D + +func get_half_size(sprt: Node2D): + var half_size: Vector2 + + if sprt is Sprite2D: + half_size = (sprt.texture.get_size() * sprt.scale) / 2.0 + elif sprt is AnimatedSprite2D: + var tex: Texture2D = sprt.sprite_frames.get_frame_texture(sprt.animation, 0) + if tex: + half_size = (tex.get_size() * sprt.scale) / 2.0 + else: + half_size = Vector2.ZERO + else: + half_size = Vector2.ZERO + + return half_size + +func wrap_position(node: Node2D) -> void: + var rect = node.get_viewport_rect() + var pos = node.position + var half_size = get_half_size(node) + + # Horizontal wrap + if pos.x < -half_size.x: + pos.x = rect.size.x + half_size.x + elif pos.x > rect.size.x + half_size.x: + pos.x = -half_size.x + + # Vertical wrap + if pos.y < -half_size.y: + pos.y = rect.size.y + half_size.y + elif pos.y > rect.size.y + half_size.y: + pos.y = -half_size.y + + node.position = pos + +func play_sound(sound: Resource, parent: Node2D): + var player = AudioStreamPlayer.new() + parent.add_child(player) + player.stream = sound + player.play() + player.finished.connect(func(): player.queue_free()) diff --git a/Scripts/utils.gd.uid b/Scripts/utils.gd.uid new file mode 100644 index 0000000..52af9ea --- /dev/null +++ b/Scripts/utils.gd.uid @@ -0,0 +1 @@ +uid://buu1netks6ojb diff --git a/Sounds/Explosion.wav b/Sounds/Explosion.wav new file mode 100644 index 0000000..3de845f Binary files /dev/null and b/Sounds/Explosion.wav differ diff --git a/Sounds/Explosion.wav.import b/Sounds/Explosion.wav.import new file mode 100644 index 0000000..26c8d96 --- /dev/null +++ b/Sounds/Explosion.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://damfiglhgbndg" +path="res://.godot/imported/Explosion.wav-df129fcef001a99a7ebca62c066fad7f.sample" + +[deps] + +source_file="res://Sounds/Explosion.wav" +dest_files=["res://.godot/imported/Explosion.wav-df129fcef001a99a7ebca62c066fad7f.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/Sounds/Explosion5.wav b/Sounds/Explosion5.wav new file mode 100644 index 0000000..6219643 Binary files /dev/null and b/Sounds/Explosion5.wav differ diff --git a/Sounds/Explosion5.wav.import b/Sounds/Explosion5.wav.import new file mode 100644 index 0000000..47780b7 --- /dev/null +++ b/Sounds/Explosion5.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://bbcbp35voy82q" +path="res://.godot/imported/Explosion5.wav-e35eb32510b5624844f55312473cea80.sample" + +[deps] + +source_file="res://Sounds/Explosion5.wav" +dest_files=["res://.godot/imported/Explosion5.wav-e35eb32510b5624844f55312473cea80.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/Sounds/extra_life.wav b/Sounds/extra_life.wav new file mode 100644 index 0000000..da2306e Binary files /dev/null and b/Sounds/extra_life.wav differ diff --git a/Sounds/extra_life.wav.import b/Sounds/extra_life.wav.import new file mode 100644 index 0000000..53ed7dc --- /dev/null +++ b/Sounds/extra_life.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://fyesvv48iu8r" +path="res://.godot/imported/extra_life.wav-b029094bd39138c35926eb8f28e384dd.sample" + +[deps] + +source_file="res://Sounds/extra_life.wav" +dest_files=["res://.godot/imported/extra_life.wav-b029094bd39138c35926eb8f28e384dd.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/Sounds/laser4.wav b/Sounds/laser4.wav new file mode 100644 index 0000000..846befd Binary files /dev/null and b/Sounds/laser4.wav differ diff --git a/Sounds/laser4.wav.import b/Sounds/laser4.wav.import new file mode 100644 index 0000000..d5fecb7 --- /dev/null +++ b/Sounds/laser4.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://docuh1bqh2uba" +path="res://.godot/imported/laser4.wav-026c5e7ca4997824f763173d5cb83d5d.sample" + +[deps] + +source_file="res://Sounds/laser4.wav" +dest_files=["res://.godot/imported/laser4.wav-026c5e7ca4997824f763173d5cb83d5d.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/Sprites/fly_spaceship.png b/Sprites/fly_spaceship.png new file mode 100644 index 0000000..2126c52 Binary files /dev/null and b/Sprites/fly_spaceship.png differ diff --git a/Sprites/fly_spaceship.png.import b/Sprites/fly_spaceship.png.import new file mode 100644 index 0000000..33d4f99 --- /dev/null +++ b/Sprites/fly_spaceship.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bdwr76wwjquob" +path="res://.godot/imported/fly_spaceship.png-09f18472abff441559058c1b32552609.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Sprites/fly_spaceship.png" +dest_files=["res://.godot/imported/fly_spaceship.png-09f18472abff441559058c1b32552609.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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/Sprites/i_are_spaceship.png b/Sprites/i_are_spaceship.png new file mode 100644 index 0000000..6c2608a Binary files /dev/null and b/Sprites/i_are_spaceship.png differ diff --git a/Sprites/i_are_spaceship.png.import b/Sprites/i_are_spaceship.png.import new file mode 100644 index 0000000..de1e2e9 --- /dev/null +++ b/Sprites/i_are_spaceship.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cv84w0y2jg3i3" +path="res://.godot/imported/i_are_spaceship.png-f1773335f0779d276b4232000f51f2ad.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Sprites/i_are_spaceship.png" +dest_files=["res://.godot/imported/i_are_spaceship.png-f1773335f0779d276b4232000f51f2ad.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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/Sprites/idle_spaceship.png b/Sprites/idle_spaceship.png new file mode 100644 index 0000000..987009e Binary files /dev/null and b/Sprites/idle_spaceship.png differ diff --git a/Sprites/idle_spaceship.png.import b/Sprites/idle_spaceship.png.import new file mode 100644 index 0000000..35b468e --- /dev/null +++ b/Sprites/idle_spaceship.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cvfsmhdbgh8vh" +path="res://.godot/imported/idle_spaceship.png-50f9870f8c75b88f0c2ffe9c1ebb048d.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Sprites/idle_spaceship.png" +dest_files=["res://.godot/imported/idle_spaceship.png-50f9870f8c75b88f0c2ffe9c1ebb048d.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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/Sprites/left_spaceship.png b/Sprites/left_spaceship.png new file mode 100644 index 0000000..c3ae450 Binary files /dev/null and b/Sprites/left_spaceship.png differ diff --git a/Sprites/left_spaceship.png.import b/Sprites/left_spaceship.png.import new file mode 100644 index 0000000..36091cb --- /dev/null +++ b/Sprites/left_spaceship.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dtcdw0p6jcw00" +path="res://.godot/imported/left_spaceship.png-203801d0667ec1f88f7d829433d9f923.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Sprites/left_spaceship.png" +dest_files=["res://.godot/imported/left_spaceship.png-203801d0667ec1f88f7d829433d9f923.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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/Sprites/right_spaceship.png b/Sprites/right_spaceship.png new file mode 100644 index 0000000..3dee561 Binary files /dev/null and b/Sprites/right_spaceship.png differ diff --git a/Sprites/right_spaceship.png.import b/Sprites/right_spaceship.png.import new file mode 100644 index 0000000..85e1037 --- /dev/null +++ b/Sprites/right_spaceship.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c0quqc1en7jo" +path="res://.godot/imported/right_spaceship.png-3cbfec901222e0eb10821f64c8fb11ef.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Sprites/right_spaceship.png" +dest_files=["res://.godot/imported/right_spaceship.png-3cbfec901222e0eb10821f64c8fb11ef.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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/Sprites/space.png b/Sprites/space.png new file mode 100644 index 0000000..d3c67e4 Binary files /dev/null and b/Sprites/space.png differ diff --git a/Sprites/space.png.import b/Sprites/space.png.import new file mode 100644 index 0000000..077044f --- /dev/null +++ b/Sprites/space.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cuqofgxmpn2fu" +path="res://.godot/imported/space.png-700a9bfbdde92801716d216837fb3742.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Sprites/space.png" +dest_files=["res://.godot/imported/space.png-700a9bfbdde92801716d216837fb3742.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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/main.tscn b/main.tscn new file mode 100644 index 0000000..6668d60 --- /dev/null +++ b/main.tscn @@ -0,0 +1,45 @@ +[gd_scene load_steps=7 format=3 uid="uid://cmlg48m6buclv"] + +[ext_resource type="Texture2D" uid="uid://cuqofgxmpn2fu" path="res://Sprites/space.png" id="1_7mycd"] +[ext_resource type="Script" uid="uid://dpa4j6me328ak" path="res://Scripts/ui.gd" id="2_272bh"] +[ext_resource type="Script" uid="uid://efye4dftj3u6" path="res://Scripts/score.gd" id="3_5vw27"] +[ext_resource type="Script" uid="uid://mfgrqlsgsyrx" path="res://Scripts/spawner.gd" id="4_1bvp3"] +[ext_resource type="Script" uid="uid://miwfeu4n6uh7" path="res://Scripts/lives.gd" id="4_kek77"] + +[sub_resource type="LabelSettings" id="LabelSettings_7mycd"] + +[node name="Node2D" type="Node2D"] + +[node name="Background" type="TextureRect" parent="."] +offset_right = 1153.0 +offset_bottom = 648.0 +texture = ExtResource("1_7mycd") +stretch_mode = 1 + +[node name="UI" type="CanvasLayer" parent="."] +script = ExtResource("2_272bh") + +[node name="Score" type="Label" parent="UI"] +visible = false +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -66.0 +offset_top = 2.0 +offset_right = -5.0 +offset_bottom = 25.0 +grow_horizontal = 0 +text = "Score: 0" +label_settings = SubResource("LabelSettings_7mycd") +horizontal_alignment = 2 +script = ExtResource("3_5vw27") + +[node name="Lives" type="HBoxContainer" parent="UI"] +offset_left = 6.0 +offset_top = 6.0 +offset_right = 46.0 +offset_bottom = 46.0 +script = ExtResource("4_kek77") + +[node name="Spawner" type="Node2D" parent="."] +script = ExtResource("4_1bvp3") diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..df64daa --- /dev/null +++ b/project.godot @@ -0,0 +1,70 @@ +; 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="Asteroids" +run/main_scene="res://main.tscn" +config/features=PackedStringArray("4.5", "GL Compatibility") + +[autoload] + +Game="*res://Scripts/game.gd" +Utils="*res://Scripts/utils.gd" + +[display] + +window/stretch/mode="viewport" +window/stretch/scale=1.5 + +[input] + +ui_left={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194319,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"script":null) +, 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,"location":0,"echo":false,"script":null) +] +} +ui_right={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194321,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":1.0,"script":null) +, 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,"location":0,"echo":false,"script":null) +] +} +ui_up={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194320,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":11,"pressure":0.0,"pressed":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null) +, 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,"location":0,"echo":false,"script":null) +] +} +ui_down={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194322,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"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":0,"location":0,"echo":false,"script":null) +] +} + +[rendering] + +textures/canvas_textures/default_texture_filter=0 +renderer/rendering_method="gl_compatibility" +renderer/rendering_method.mobile="gl_compatibility" +2d/snap/snap_2d_transforms_to_pixel=true +2d/snap/snap_2d_vertices_to_pixel=true +2d/canvas_textures/default_texture_filter=0 +2d/stretch/scale=1.5