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/asteroid.gd b/asteroid.gd new file mode 100644 index 0000000..3d373af --- /dev/null +++ b/asteroid.gd @@ -0,0 +1,43 @@ +extends StaticBody2D + +@export var max_health: float = 100.0 # Maximum health for the asteroid +var current_health: float +var is_destroyed: bool = false # Track if the asteroid has already been destroyed + +func _ready(): + current_health = max_health + update_health_label() # Update the health display when the game starts + +# Function to handle taking damage +func take_damage(damage: float): + if is_destroyed: # Prevent taking damage if already destroyed + return + + current_health -= damage # Subtract the damage from current health + current_health = max(current_health, 0) # Ensure health doesn't drop below 0 + update_health_label() # Update the label to reflect new health value + + if current_health <= 0.0: + break_apart() + +# Function to handle when the asteroid is destroyed +func break_apart(): + is_destroyed = true # Mark the asteroid as destroyed + queue_free() # Remove the asteroid from the scene + print("Asteroid mined!") + + # Load the Cheese scene + var cheese_scene = load("res://Cheese.tscn") + + # Instance the cheese + var cheese_instance = cheese_scene.instantiate() + + # Set the position where the cheese should spawn (at the asteroid's position) + cheese_instance.global_position = global_position + Vector2(randf() * 50 - 25, randf() * 50 - 25) + + # Add the cheese instance to the scene + get_parent().add_child(cheese_instance) + +# Function to update the health label display +func update_health_label(): + $AsteroidHealthLabel.text = str(round(current_health)) + " / " + str(max_health) diff --git a/cheese.tscn b/cheese.tscn new file mode 100644 index 0000000..ceed080 --- /dev/null +++ b/cheese.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=3 format=3 uid="uid://ukjuwuhb6mq6"] + +[ext_resource type="Script" path="res://cheeseCollision.gd" id="1_k5eo2"] +[ext_resource type="Texture2D" uid="uid://djwn5ruf1wln0" path="res://images/protocheese.png" id="2_xljbq"] + +[node name="cheese" type="Area2D"] +position = Vector2(300, 337) +scale = Vector2(2, 2) +collision_mask = 3 +script = ExtResource("1_k5eo2") + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."] +polygon = PackedVector2Array(3, 17.5, 18.5, 0, 13.5, -20.5, -16.5, -7, -16, 13) + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("2_xljbq") + +[connection signal="body_entered" from="." to="." method="_on_body_entered"] diff --git a/cheeseCollision.gd b/cheeseCollision.gd new file mode 100644 index 0000000..ebaadf4 --- /dev/null +++ b/cheeseCollision.gd @@ -0,0 +1,18 @@ +extends Area2D + + + +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + + +func _on_body_entered(body): + if body.name == "spaceship": + queue_free() # This removes the cheese from the scene + print("Cheese collected!") # Replace this with actual game logic + diff --git a/hardpoint.gd b/hardpoint.gd new file mode 100644 index 0000000..228b5b7 --- /dev/null +++ b/hardpoint.gd @@ -0,0 +1,19 @@ +extends Node2D + +@export var hardpoint_id: String = "HardPoint1" # Unique identifier for this hardpoint + +# Optional - can store a reference to the mounted weapon +var mounted_weapon: Node2D = null + +# Method to attach a weapon to the hardpoint +func attach_weapon(weapon: Node2D) -> void: + mounted_weapon = weapon + weapon.global_position = global_position # Set weapon position to the hardpoint position + weapon.rotation = rotation # Align the weapon's rotation to the hardpoint's rotation + +func _draw(): + draw_circle(Vector2.ZERO, 10, Color(1, 0, 0)) # Draw a red circle at the hardpoint + +func _ready(): + add_to_group("hardpoints") # Add the hardpoint to the "hardpoints" group + queue_redraw() # Redraw the visual to ensure it's updated 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..fc09f0e --- /dev/null +++ b/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b738dyw75cuny" +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/images/AsteroidBrown.png b/images/AsteroidBrown.png new file mode 100644 index 0000000..650bada Binary files /dev/null and b/images/AsteroidBrown.png differ diff --git a/images/AsteroidBrown.png.import b/images/AsteroidBrown.png.import new file mode 100644 index 0000000..23158b8 --- /dev/null +++ b/images/AsteroidBrown.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://buirp1h6onqai" +path="res://.godot/imported/AsteroidBrown.png-5960fa3ab2dd38f3a19e0b952d620e7c.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://images/AsteroidBrown.png" +dest_files=["res://.godot/imported/AsteroidBrown.png-5960fa3ab2dd38f3a19e0b952d620e7c.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/images/bg_space_seamless.png b/images/bg_space_seamless.png new file mode 100644 index 0000000..505e352 Binary files /dev/null and b/images/bg_space_seamless.png differ diff --git a/images/bg_space_seamless.png.import b/images/bg_space_seamless.png.import new file mode 100644 index 0000000..9a61785 --- /dev/null +++ b/images/bg_space_seamless.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://y6phkg4twpdm" +path="res://.godot/imported/bg_space_seamless.png-aa28148dfa1d993d28c2e72eefdcdab6.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://images/bg_space_seamless.png" +dest_files=["res://.godot/imported/bg_space_seamless.png-aa28148dfa1d993d28c2e72eefdcdab6.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/images/glowcircle.png b/images/glowcircle.png new file mode 100644 index 0000000..911e04f Binary files /dev/null and b/images/glowcircle.png differ diff --git a/images/glowcircle.png.import b/images/glowcircle.png.import new file mode 100644 index 0000000..f67ecf5 --- /dev/null +++ b/images/glowcircle.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://d0o4hqaai2tpu" +path="res://.godot/imported/glowcircle.png-4797643c88aab209a866b25184909738.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://images/glowcircle.png" +dest_files=["res://.godot/imported/glowcircle.png-4797643c88aab209a866b25184909738.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/images/glowing_circle.png b/images/glowing_circle.png new file mode 100644 index 0000000..6e51f4f Binary files /dev/null and b/images/glowing_circle.png differ diff --git a/images/glowing_circle.png.import b/images/glowing_circle.png.import new file mode 100644 index 0000000..0a148fa --- /dev/null +++ b/images/glowing_circle.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://di7nndrreqmtf" +path="res://.godot/imported/glowing_circle.png-4ed2edd49097f5b99b37d1372b8b318b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://images/glowing_circle.png" +dest_files=["res://.godot/imported/glowing_circle.png-4ed2edd49097f5b99b37d1372b8b318b.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/images/laser_turret.png b/images/laser_turret.png new file mode 100644 index 0000000..f014e2f Binary files /dev/null and b/images/laser_turret.png differ diff --git a/images/laser_turret.png.import b/images/laser_turret.png.import new file mode 100644 index 0000000..d37d50a --- /dev/null +++ b/images/laser_turret.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bxgw2u7j4b634" +path="res://.godot/imported/laser_turret.png-1df2831a344ffa5282291095b5880ec8.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://images/laser_turret.png" +dest_files=["res://.godot/imported/laser_turret.png-1df2831a344ffa5282291095b5880ec8.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/images/protocheese.png b/images/protocheese.png new file mode 100644 index 0000000..e2683ce Binary files /dev/null and b/images/protocheese.png differ diff --git a/images/protocheese.png.import b/images/protocheese.png.import new file mode 100644 index 0000000..4a78eef --- /dev/null +++ b/images/protocheese.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://djwn5ruf1wln0" +path="res://.godot/imported/protocheese.png-9fecc312dcb5c24e7f3a9d4a6b6c2d88.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://images/protocheese.png" +dest_files=["res://.godot/imported/protocheese.png-9fecc312dcb5c24e7f3a9d4a6b6c2d88.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/images/spaceship-placeholder.png b/images/spaceship-placeholder.png new file mode 100644 index 0000000..ff5d9a6 Binary files /dev/null and b/images/spaceship-placeholder.png differ diff --git a/images/spaceship-placeholder.png.import b/images/spaceship-placeholder.png.import new file mode 100644 index 0000000..02fc54f --- /dev/null +++ b/images/spaceship-placeholder.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cran7fr1i2qou" +path="res://.godot/imported/spaceship-placeholder.png-33b1b8ec5ecce91858cf1b9fc0c0a4e9.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://images/spaceship-placeholder.png" +dest_files=["res://.godot/imported/spaceship-placeholder.png-33b1b8ec5ecce91858cf1b9fc0c0a4e9.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/laser.gd b/laser.gd new file mode 100644 index 0000000..27068be --- /dev/null +++ b/laser.gd @@ -0,0 +1,78 @@ +extends Node2D + +@export var laser_range: float = 800.0 +@export var laser_damage: float = 0.2 +@export var hardpoint_id: String = "HardPoint1" # Identifier for the hardpoint to attach this laser + +var hardpoint = null # Reference to the attached hardpoint +var is_firing = false # Track the laser's firing state +var current_damage_output: float = 0.0 # Track the current damage output + +func _ready(): + # Register the laser to the "weapons" group + add_to_group("weapons") + # Connect to the correct hardpoint when ready + call_deferred("_connect_to_hardpoint") + + # Initialize LaserLine2D with two points (origin and target) + $LaserLine2D.clear_points() + $LaserLine2D.add_point(Vector2.ZERO) # Origin point + $LaserLine2D.add_point(Vector2.ZERO) # Target point (initially the same as origin) + $DamageOutputLabel.text = str(current_damage_output) + +# Connect the laser to the appropriate hardpoint +func _connect_to_hardpoint(): + var hardpoints = get_tree().get_nodes_in_group("hardpoints") + for h in hardpoints: + if h.hardpoint_id == hardpoint_id: + hardpoint = h + h.attach_weapon(self) + break + + +func fire(): + is_firing = true + _process_laser(true) + current_damage_output = laser_damage + $DamageOutputLabel.text = str(current_damage_output) + + +func cease_fire(): + is_firing = false + _process_laser(false) + current_damage_output = 0.0 + $DamageOutputLabel.text = str(current_damage_output) + +func _process(delta: float) -> void: + if is_firing: + _process_laser(true) + + +func _process_laser(active: bool): + var raycast = $LaserBeam2D + raycast.enabled = active + + + if active: + + raycast.force_raycast_update() + + if raycast.is_colliding(): + + var collision_point = raycast.get_collision_point() + $LaserLine2D.set_point_position(0, Vector2.ZERO) + $LaserLine2D.set_point_position(1, to_local(collision_point)) + + + var collider = raycast.get_collider() + if collider.has_method("take_damage"): + collider.take_damage(laser_damage) + else: + + $LaserLine2D.set_point_position(0, Vector2.ZERO) + $LaserLine2D.set_point_position(1, Vector2(0, -laser_range)) + else: + + $LaserLine2D.clear_points() + $LaserLine2D.add_point(Vector2.ZERO) # Re-add the origin point + $LaserLine2D.add_point(Vector2.ZERO) # Reset target point to origin diff --git a/maiE190.tmp b/maiE190.tmp new file mode 100644 index 0000000..5455179 --- /dev/null +++ b/maiE190.tmp @@ -0,0 +1,63 @@ +[gd_scene load_steps=9 format=3 uid="uid://8ocp10j32f62"] + +[ext_resource type="Texture2D" uid="uid://y6phkg4twpdm" path="res://images/bg_space_seamless.png" id="1_rpyi5"] +[ext_resource type="Texture2D" uid="uid://cran7fr1i2qou" path="res://images/spaceship-placeholder.png" id="2_f2x66"] +[ext_resource type="Script" path="res://spaceship.gd" id="3_ttkgl"] +[ext_resource type="Texture2D" uid="uid://djwn5ruf1wln0" path="res://images/protocheese.png" id="4_i7fg5"] +[ext_resource type="Script" path="res://cheeseCollision.gd" id="5_r3xo8"] +[ext_resource type="Script" path="res://asteroid.gd" id="6_n4dsl"] +[ext_resource type="Texture2D" uid="uid://buirp1h6onqai" path="res://images/AsteroidBrown.png" id="7_0tjls"] + +[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_u4a3y"] +radius = 44.0 +height = 100.0 + +[node name="Main" type="Node2D"] + +[node name="background" type="Sprite2D" parent="."] +position = Vector2(955, 535) +scale = Vector2(2, 2) +texture = ExtResource("1_rpyi5") + +[node name="spaceship" type="CharacterBody2D" parent="."] +position = Vector2(960, 540) +motion_mode = 1 +script = ExtResource("3_ttkgl") + +[node name="Sprite2D" type="Sprite2D" parent="spaceship"] +z_index = 1 +texture = ExtResource("2_f2x66") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="spaceship"] +position = Vector2(0, -1) +shape = SubResource("CapsuleShape2D_u4a3y") + +[node name="RayCast2D" type="RayCast2D" parent="spaceship"] +position = Vector2(0, 3) +target_position = Vector2(0, -177) + +[node name="cheese" type="Area2D" parent="."] +position = Vector2(300, 337) +scale = Vector2(2, 2) +script = ExtResource("5_r3xo8") + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="cheese"] +polygon = PackedVector2Array(3, 17.5, 18.5, 0, 13.5, -20.5, -16.5, -7, -16, 13) + +[node name="Sprite2D" type="Sprite2D" parent="cheese"] +texture = ExtResource("4_i7fg5") + +[node name="asteroid" type="Area2D" parent="."] +position = Vector2(564, 144) +script = ExtResource("6_n4dsl") + +[node name="Sprite2D" type="Sprite2D" parent="asteroid"] +position = Vector2(1.00006, -3.99998) +scale = Vector2(1.2, 1.181) +texture = ExtResource("7_0tjls") + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="asteroid"] +position = Vector2(-519, -164) +polygon = PackedVector2Array(548, 101, 613, 169, 597, 210, 548, 240, 462, 221, 431, 184, 434, 133, 497, 90) + +[connection signal="body_entered" from="cheese" to="cheese" method="_on_body_entered"] diff --git a/main.tscn b/main.tscn new file mode 100644 index 0000000..e2b84ac --- /dev/null +++ b/main.tscn @@ -0,0 +1,121 @@ +[gd_scene load_steps=13 format=3 uid="uid://8ocp10j32f62"] + +[ext_resource type="Texture2D" uid="uid://y6phkg4twpdm" path="res://images/bg_space_seamless.png" id="1_rpyi5"] +[ext_resource type="Texture2D" uid="uid://cran7fr1i2qou" path="res://images/spaceship-placeholder.png" id="2_f2x66"] +[ext_resource type="Script" path="res://spaceship.gd" id="3_ttkgl"] +[ext_resource type="Script" path="res://laser.gd" id="4_uhf7q"] +[ext_resource type="Script" path="res://weapons_system.gd" id="5_gf6oh"] +[ext_resource type="Script" path="res://asteroid.gd" id="6_n4dsl"] +[ext_resource type="Texture2D" uid="uid://bxgw2u7j4b634" path="res://images/laser_turret.png" id="6_qxhyw"] +[ext_resource type="Texture2D" uid="uid://buirp1h6onqai" path="res://images/AsteroidBrown.png" id="7_0tjls"] +[ext_resource type="Script" path="res://hardpoint.gd" id="7_6cr6a"] + +[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_3vtwu"] +radius = 48.0 +height = 102.0 + +[sub_resource type="Gradient" id="Gradient_sx4rn"] +offsets = PackedFloat32Array(0.961735, 1) +colors = PackedColorArray(1, 1, 0, 1, 1, 1, 1, 0.137255) + +[sub_resource type="CircleShape2D" id="CircleShape2D_w58nc"] +radius = 88.0057 + +[node name="Main" type="Node2D"] + +[node name="background" type="Sprite2D" parent="."] +position = Vector2(955, 537) +scale = Vector2(2, 2) +texture = ExtResource("1_rpyi5") + +[node name="spaceship" type="CharacterBody2D" parent="."] +position = Vector2(908, 835) +collision_layer = 2 +motion_mode = 1 +script = ExtResource("3_ttkgl") + +[node name="Sprite2D" type="Sprite2D" parent="spaceship"] +z_index = 1 +texture = ExtResource("2_f2x66") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="spaceship"] +position = Vector2(0, 6) +rotation = -3.14159 +shape = SubResource("CapsuleShape2D_3vtwu") + +[node name="Laser1" type="Node2D" parent="spaceship"] +light_mask = 2 +position = Vector2(95, -159) +script = ExtResource("4_uhf7q") + +[node name="LaserSprite2D" type="Sprite2D" parent="spaceship/Laser1"] +position = Vector2(0, -5) +texture = ExtResource("6_qxhyw") + +[node name="LaserBeam2D" type="RayCast2D" parent="spaceship/Laser1"] +position = Vector2(0, -17) +target_position = Vector2(0, -800) +collide_with_areas = true + +[node name="LaserLine2D" type="Line2D" parent="spaceship/Laser1"] +points = PackedVector2Array(0, 0, 0, 0) +default_color = Color(1, 1, 0, 0.54902) +gradient = SubResource("Gradient_sx4rn") +texture_mode = 2 +joint_mode = 2 + +[node name="DamageOutputLabel" type="Label" parent="spaceship/Laser1"] +offset_left = 18.0 +offset_top = -71.0 +offset_right = 104.0 +offset_bottom = -20.0 + +[node name="WeaponsSystem" type="Node" parent="spaceship"] +script = ExtResource("5_gf6oh") + +[node name="HardPoint1" type="Node2D" parent="spaceship"] +position = Vector2(0, -46) +script = ExtResource("7_6cr6a") + +[node name="asteroid" type="StaticBody2D" parent="."] +position = Vector2(564, 144) +collision_mask = 2 +script = ExtResource("6_n4dsl") + +[node name="Sprite2D" type="Sprite2D" parent="asteroid"] +position = Vector2(1.00006, -3.99998) +scale = Vector2(1.2, 1.181) +texture = ExtResource("7_0tjls") + +[node name="AsteroidCollisionPolygon2D" type="CollisionPolygon2D" parent="asteroid"] +position = Vector2(-519, -164) +polygon = PackedVector2Array(548, 101, 613, 169, 597, 210, 548, 240, 462, 221, 431, 184, 434, 133, 497, 90) + +[node name="AsteroidHealthLabel" type="Label" parent="asteroid"] +offset_left = 105.0 +offset_top = 38.0 +offset_right = 181.0 +offset_bottom = 80.0 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="asteroid"] +position = Vector2(-2, 1) +shape = SubResource("CircleShape2D_w58nc") + +[node name="asteroid2" type="StaticBody2D" parent="."] +position = Vector2(1405, 413) +script = ExtResource("6_n4dsl") + +[node name="Sprite2D" type="Sprite2D" parent="asteroid2"] +position = Vector2(1.00006, -3.99998) +scale = Vector2(1.2, 1.181) +texture = ExtResource("7_0tjls") + +[node name="AsteroidCollisionPolygon2D" type="CollisionPolygon2D" parent="asteroid2"] +position = Vector2(-519, -164) +polygon = PackedVector2Array(548, 101, 613, 169, 597, 210, 548, 240, 462, 221, 431, 184, 434, 133, 497, 90) + +[node name="AsteroidHealthLabel" type="Label" parent="asteroid2"] +offset_left = 105.0 +offset_top = 38.0 +offset_right = 181.0 +offset_bottom = 80.0 diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..a8a4f4b --- /dev/null +++ b/project.godot @@ -0,0 +1,34 @@ +; 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="Star Cheese - The Final Fromage" +run/main_scene="res://main.tscn" +config/features=PackedStringArray("4.2", "Forward Plus") +config/icon="res://icon.svg" + +[display] + +window/size/viewport_width=1920 +window/size/viewport_height=1080 + +[input] + +ui_fire={ +"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) +] +} + +[layer_names] + +2d_physics/layer_1="Environment" +2d_physics/layer_2="Player" diff --git a/spaceship.gd b/spaceship.gd new file mode 100644 index 0000000..0a67e16 --- /dev/null +++ b/spaceship.gd @@ -0,0 +1,57 @@ +extends CharacterBody2D + +@export var acceleration: float = 400.0 +@export var max_speed: float = 1500.0 +@export var rotation_speed: float = 3.0 +@export var friction: float = 0.99 + +signal fire # Signal to start firing +signal stop_fire # Signal to stop firing + +var weapons_system + +func _ready(): + weapons_system = $WeaponsSystem + +func get_spaceship_orientation_vector() -> Vector2: + return -global_transform.y + +func handle_movement(delta: float) -> void: + var thrust = Vector2.ZERO + + if Input.is_action_pressed("ui_up"): + thrust = Vector2(0, -1).rotated(rotation) * acceleration * delta + velocity += thrust + + if Input.is_action_pressed("ui_down"): + thrust = Vector2(0, 1).rotated(rotation) * acceleration * delta + velocity += thrust + + if Input.is_action_pressed("ui_left"): + rotation -= rotation_speed * delta + + if Input.is_action_pressed("ui_right"): + rotation += rotation_speed * delta + + # Clamp velocity and apply friction + velocity = velocity.clamp(Vector2(-max_speed, -max_speed), Vector2(max_speed, max_speed)) + velocity *= friction + + var collision = move_and_collide(velocity * delta) + + if collision: + print("Collided with: ", collision.get_collider().name) + + var collision_normal = collision.get_normal() + velocity = velocity.slide(collision_normal) + +func handle_weapons_input() -> void: + if Input.is_action_pressed("ui_fire"): + weapons_system.fire_all() + + if Input.is_action_just_released("ui_fire"): + weapons_system.cease_fire_all() + +func _process(delta: float) -> void: + handle_movement(delta) + handle_weapons_input() diff --git a/weapons_system.gd b/weapons_system.gd new file mode 100644 index 0000000..4050259 --- /dev/null +++ b/weapons_system.gd @@ -0,0 +1,15 @@ +extends Node + +var weapons = [] + + +func _ready(): + pass + + +func fire_all(): + get_tree().call_group("weapons", "fire") + + +func cease_fire_all(): + get_tree().call_group("weapons", "cease_fire")