diff --git a/assets/_RAW_/bullet.pxo b/assets/_RAW_/bullet.pxo new file mode 100644 index 0000000..211b43b Binary files /dev/null and b/assets/_RAW_/bullet.pxo differ diff --git a/assets/_RAW_/ship.pxo b/assets/_RAW_/ship.pxo new file mode 100644 index 0000000..4289658 Binary files /dev/null and b/assets/_RAW_/ship.pxo differ diff --git a/assets/img/bullet.png b/assets/img/bullet.png new file mode 100644 index 0000000..831ed57 Binary files /dev/null and b/assets/img/bullet.png differ diff --git a/assets/img/bullet.png.import b/assets/img/bullet.png.import new file mode 100644 index 0000000..18179f8 --- /dev/null +++ b/assets/img/bullet.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dkig6mppjmlx0" +path="res://.godot/imported/bullet.png-3356f270ce3f04bca4c953a1f57e4fea.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/img/bullet.png" +dest_files=["res://.godot/imported/bullet.png-3356f270ce3f04bca4c953a1f57e4fea.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/img/ship.png b/assets/img/ship.png new file mode 100644 index 0000000..e7b767c Binary files /dev/null and b/assets/img/ship.png differ diff --git a/assets/img/ship.png.import b/assets/img/ship.png.import new file mode 100644 index 0000000..48869fb --- /dev/null +++ b/assets/img/ship.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://qcnuvee2jcp0" +path="res://.godot/imported/ship.png-840e32c7f9eb6a66a91f44b30feabbe5.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/img/ship.png" +dest_files=["res://.godot/imported/ship.png-840e32c7f9eb6a66a91f44b30feabbe5.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/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..c3882f5 --- /dev/null +++ b/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dtmoactlc677x" +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..75f8411 --- /dev/null +++ b/project.godot @@ -0,0 +1,55 @@ +; 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="Comets.gd" +run/main_scene="res://scenes/game.tscn" +config/features=PackedStringArray("4.2", "Forward Plus") +config/icon="res://icon.svg" + +[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,"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,"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,"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,"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,"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,"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,"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":-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) +] +} + +[rendering] + +textures/canvas_textures/default_texture_filter=0 diff --git a/scenes/bullet.tscn b/scenes/bullet.tscn new file mode 100644 index 0000000..8721165 --- /dev/null +++ b/scenes/bullet.tscn @@ -0,0 +1,25 @@ +[gd_scene load_steps=4 format=3 uid="uid://btqqwoybwtc0a"] + +[ext_resource type="Texture2D" uid="uid://dkig6mppjmlx0" path="res://assets/img/bullet.png" id="1_6rsjj"] +[ext_resource type="Script" path="res://scripts/bullet.gd" id="1_jyq7a"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_5nukh"] +size = Vector2(4, 16) + +[node name="Bullet" type="Area2D"] +script = ExtResource("1_jyq7a") + +[node name="Sprite2D" type="Sprite2D" parent="."] +position = Vector2(1, 0) +texture = ExtResource("1_6rsjj") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("RectangleShape2D_5nukh") + +[node name="LifeTimer" type="Timer" parent="."] +one_shot = true +autostart = true + +[node name="Camera2D" type="Camera2D" parent="."] + +[connection signal="timeout" from="LifeTimer" to="." method="_on_life_timer_timeout"] diff --git a/scenes/game.tscn b/scenes/game.tscn new file mode 100644 index 0000000..c063b0b --- /dev/null +++ b/scenes/game.tscn @@ -0,0 +1,7 @@ +[gd_scene load_steps=2 format=3 uid="uid://bdarunpk3c2eh"] + +[ext_resource type="PackedScene" uid="uid://cbo47ftx0vcro" path="res://scenes/ship.tscn" id="1_esyqo"] + +[node name="Game" type="Node2D"] + +[node name="Ship" parent="." instance=ExtResource("1_esyqo")] diff --git a/scenes/ship.tscn b/scenes/ship.tscn new file mode 100644 index 0000000..6a36c6a --- /dev/null +++ b/scenes/ship.tscn @@ -0,0 +1,29 @@ +[gd_scene load_steps=4 format=3 uid="uid://cbo47ftx0vcro"] + +[ext_resource type="Script" path="res://scripts/ship.gd" id="1_japvq"] +[ext_resource type="Texture2D" uid="uid://qcnuvee2jcp0" path="res://assets/img/ship.png" id="1_ymcdl"] + +[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_hwy8o"] + +[node name="Ship" type="Area2D"] +script = ExtResource("1_japvq") +max_speed = null +steering_factor = null + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("1_ymcdl") + +[node name="CPUParticles2D" type="CPUParticles2D" parent="Sprite2D"] +position = Vector2(-16, 0) +emission_shape = 1 +emission_sphere_radius = 3.0 +spread = 105.9 +gravity = Vector2(0, 0) + +[node name="Gun" type="Marker2D" parent="Sprite2D"] +position = Vector2(32, 0) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +rotation = 1.54049 +scale = Vector2(1.36118, -2.39866) +shape = SubResource("CapsuleShape2D_hwy8o") diff --git a/scripts/bullet.gd b/scripts/bullet.gd new file mode 100644 index 0000000..317ab57 --- /dev/null +++ b/scripts/bullet.gd @@ -0,0 +1,8 @@ +extends Area2D + + +func _process(delta: float) -> void: + pass + +func _on_life_timer_timeout() -> void: + queue_free() diff --git a/scripts/ship.gd b/scripts/ship.gd new file mode 100644 index 0000000..8d2de39 --- /dev/null +++ b/scripts/ship.gd @@ -0,0 +1,26 @@ +extends Area2D + +@export var max_speed := 1200.0 +@export var steering_factor := 3.0 + +var velocity := Vector2.ZERO + +func _process(delta: float) -> void: + # TODO: Maybe look into tank controls like classic Astroids + var direction := Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down") + if direction.length() > 1.0: + direction.normalized() + + var desired_velocity := max_speed * direction + var steering := desired_velocity - velocity + velocity += steering * steering_factor * delta + position += velocity * delta + + if velocity.length() > 0.0: + $Sprite2D.rotation = velocity.angle() + + var viewport_size := get_viewport_rect().size + position.x = wrap(position.x, 0, viewport_size.x) + position.y = wrap(position.y, 0,viewport_size.y) + +func fire_gun() -> void: