Initial Commit

This commit is contained in:
Rain Clark 2024-05-09 22:42:55 -04:00
parent 1bb096ba0d
commit a5e7731b47
14 changed files with 256 additions and 0 deletions

BIN
assets/_RAW_/bullet.pxo Normal file

Binary file not shown.

BIN
assets/_RAW_/ship.pxo Normal file

Binary file not shown.

BIN
assets/img/bullet.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 B

View File

@ -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

BIN
assets/img/ship.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@ -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

1
icon.svg Normal file
View File

@ -0,0 +1 @@
<svg height="128" width="128" xmlns="http://www.w3.org/2000/svg"><rect x="2" y="2" width="124" height="124" rx="14" fill="#363d52" stroke="#212532" stroke-width="4"/><g transform="scale(.101) translate(122 122)"><g fill="#fff"><path d="M105 673v33q407 354 814 0v-33z"/><path d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 814 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H446l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z" fill="#478cbf"/><path d="M483 600c0 34 58 34 58 0v-86c0-34-58-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></g></svg>

After

Width:  |  Height:  |  Size: 949 B

37
icon.svg.import Normal file
View File

@ -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

55
project.godot Normal file
View File

@ -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

25
scenes/bullet.tscn Normal file
View File

@ -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"]

7
scenes/game.tscn Normal file
View File

@ -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")]

29
scenes/ship.tscn Normal file
View File

@ -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")

8
scripts/bullet.gd Normal file
View File

@ -0,0 +1,8 @@
extends Area2D
func _process(delta: float) -> void:
pass
func _on_life_timer_timeout() -> void:
queue_free()

26
scripts/ship.gd Normal file
View File

@ -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: