From a5e7731b477e8c38864512a97f513358992d2c79 Mon Sep 17 00:00:00 2001 From: Rain Date: Thu, 9 May 2024 22:42:55 -0400 Subject: [PATCH] Initial Commit --- assets/_RAW_/bullet.pxo | Bin 0 -> 483 bytes assets/_RAW_/ship.pxo | Bin 0 -> 999 bytes assets/img/bullet.png | Bin 0 -> 113 bytes assets/img/bullet.png.import | 34 ++++++++++++++++++++++ assets/img/ship.png | Bin 0 -> 4619 bytes assets/img/ship.png.import | 34 ++++++++++++++++++++++ icon.svg | 1 + icon.svg.import | 37 +++++++++++++++++++++++ project.godot | 55 +++++++++++++++++++++++++++++++++++ scenes/bullet.tscn | 25 ++++++++++++++++ scenes/game.tscn | 7 +++++ scenes/ship.tscn | 29 ++++++++++++++++++ scripts/bullet.gd | 8 +++++ scripts/ship.gd | 26 +++++++++++++++++ 14 files changed, 256 insertions(+) create mode 100644 assets/_RAW_/bullet.pxo create mode 100644 assets/_RAW_/ship.pxo create mode 100644 assets/img/bullet.png create mode 100644 assets/img/bullet.png.import create mode 100644 assets/img/ship.png create mode 100644 assets/img/ship.png.import create mode 100644 icon.svg create mode 100644 icon.svg.import create mode 100644 project.godot create mode 100644 scenes/bullet.tscn create mode 100644 scenes/game.tscn create mode 100644 scenes/ship.tscn create mode 100644 scripts/bullet.gd create mode 100644 scripts/ship.gd diff --git a/assets/_RAW_/bullet.pxo b/assets/_RAW_/bullet.pxo new file mode 100644 index 0000000000000000000000000000000000000000..211b43b415bf61743e01c74bdaaae47259dcd85f GIT binary patch literal 483 zcmV<90UZ8ELr_Kn000005C8y<1^@ud0RR9fwJ-f(js*=402bIvEubgq|NsC0|ARK< z@BVuyNoA5E|0l9{k~>L6fd3RHtpkW{`R}%gfus^)yaPS}J^(!c$`WO!RJ=a5jk@zF zqBQGj+{qFk2H_XGh41UV=)nbI{o+(v0r*lZnsxd;fc z=qExnG%Ql;>(bxmm?>wQC#H|BN_+{Dg7z04YsnDJ-=g=R0;+pP>27z z>#>%D|F$M@_$SMtAp-Ti+Q8xOwlPT;I2>zGsDaH1WG0wNqlKxN15kr#+XfP#kr0V7 z5ET*h1qLDE#IKGAr7by$ROgd5SK)QRRd`)+6HTnFS0 zGxjHdFV^f*^1Gt%9VAUg_uDeSr+5@~G-KKga(2WvmoNw8_K)xJ#tGtaOXy!nVpQ>$ ZHp{V*jU!fYqUQO^2azU9NDW6rP)4k(+C=~W literal 0 HcmV?d00001 diff --git a/assets/_RAW_/ship.pxo b/assets/_RAW_/ship.pxo new file mode 100644 index 0000000000000000000000000000000000000000..4289658b185d03d30b1ef690917c602b3027ee39 GIT binary patch literal 999 zcmZ>F4sc^)00IF9hBPMzh8v6w3<*GPDiAXQ*@{3~W2^q(1P1<6J_fVtZkiiZU-BF_ z;Au8@UvsDIy~^GxL1yzgZf3q$5f<x!yHla-2{VUuUUp`~Uy{f5O1b`9EjQ|Nnpfd-q6n0+Zxr24M~^FHb0Z>BXaI8&YIP^E3yI-!8iU+&Yf zE0b#i?sM8s@SkF1<{qT?MOIgk?^&L%!qyKZuKb;s7^jBMdzE1JC(F|yUUx>{SGB2M zZ>uz1l?#5F+8Xc(->qLeRpaJA;Lkhxj{AD_(qd05wl?d4IDx>*3cE%V!T+Jq zc-_jxAjHDL_JE%u!G~)V6fir?5ct5(AXLHLXv>;+(B63g$CODyzrtSh=-!?9SYb;| zo5GU`LIyfV*xNTcIob(`D66RP9Z7ubpe@(wyWo?=H9ZDRsQGu97$&*E%nyYDCJ%@O zKjbe7Okw3aXwAaw)+|uRSNG@P<%TmK_^nDa_&Qt~I@NOKFdWcf4zsdR>&$F1NaW;< zIO3tqX!(eTvDs2*HWSp6z3dDjO#lBgpg0T`Dc0xAKd8m6z9V9Qo;c!_7S&;fx0 z4hN>b29*ZMHil;oOrDaA$}R~Vf)Z*Pikh>^x=*y_|)x> ztE6M{W22Vu&`xUn)~zZt>22ZB1L69b(|+rolAdnx`v3Xt<56{%$F48<@SWY^YkQ#T z8|E~L*CiAASd$m1+Mg;&KEhu+t0h)WuxOKUlG@?70T1{WJW_wdZjmeYZ4x8^(irzL eFjxRR3W96`408=uK0aA7MWBlLD3d!divs}Vd8!=% literal 0 HcmV?d00001 diff --git a/assets/img/bullet.png b/assets/img/bullet.png new file mode 100644 index 0000000000000000000000000000000000000000..831ed575c05376d18dc555f23458782318f5db5f GIT binary patch literal 113 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|v^`xMLo9le zQw}iw`~UyH{LJ$wPMqlQm1PD3VLi^IgDV&pv-L zfHu^kG3scK_RL}XJ!r=dW2Dd~BvNEL>}z3D zLpuugO|Y@=46XG?XbYcU@tXlHfqA4)w^*}LwUWS<8Xfe<)g*;$Dcpdn35w8Dgbt!5 z^AW7>E2k2sy&176Z2gNJRaakQGI#Fm&3p6v&n?B# z_gB6Dc(7%m)=6~CkG%LB`tG@z=QK4RpD8?<=uT`k9nSNF&KgDf)N;;%%jXE)cLFcjQRDEMO6Y5cvLEBCZz76gX8W($cl z$2WdZr7kqHw=KV~{@|fM=-IJv_FnpJb#q|auVp#)$t6#_-yW#=IQJKCbuN*g|7FLv zuhwsuo>^P}Ghgik<|12*3_81C=l=O>@w!L5zFoa!Tdd^iy^iz6OO`*X{B+j3-pke2 zuH8?LSFNAzPddn5k^bt$q6ho+C%!gj##NG^C6ook#!4C4l{X#?^!Gn%dwTC??U!M| z*<0?=x1~C_&n=Uis4*J+RoX4((m#J5knG_{2rPq06b~~PS$NwJUDe)fwFd! zVx`uKTRkZtpUo)ug5~9zIZSy0W3(%h7RnR-6eMr~o<{wyLbs3dn-n511#Mwir9edp zUtm(?!9+^oyZ|MYq!Pzc{cMR^u~3dCdhHHsnK^Bk0zR1(`8@BTRI1X_Qe~+|$$6bB z!e}(AaJ5RU#vlUomAQG^kGXww1d1UJGw?B9*2A-$8x=Td8&}Mm6bd+xj_l9nv06vz z-M(QJpdKne?NJd*T;+19#(Vhq)DlQCyrCcT@a2?wfNB}=am8K+q?Q0TKW99Jof-A_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.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: