From f35256866d5eb8904fa0d0a74721fa8713d2a414 Mon Sep 17 00:00:00 2001 From: AllfatherHatt Date: Tue, 12 Nov 2024 15:05:38 +0100 Subject: [PATCH] I should commit more often --- README.md | 2 +- images/32blacksquare.png | Bin 0 -> 133 bytes images/32blacksquare.png.import | 34 ++++++ images/dot.png | Bin 0 -> 4808 bytes images/dot.png.import | 35 ++++++ images/sparkle.png | Bin 0 -> 3699 bytes images/sparkle.png.import | 34 ++++++ images/white_glowing_circle.png | Bin 0 -> 2052 bytes images/white_glowing_circle.png.import | 34 ++++++ laser.gd | 74 ------------- main.gd | 2 +- main.tscn | 63 +---------- project.godot | 5 + spaceship.gd | 22 ++-- spaceship.tscn | 30 +++++ .../components/hardpoints/hardpoint.gd | 2 +- .../components/hardpoints/hardpoint.tscn | 10 ++ src/vessels/hulls/base_hull.gd | 64 +++++++++++ src/vessels/hulls/base_hull.tscn | 20 ++++ src/vessels/systems/weapons_system.gd | 8 ++ src/vessels/weapons/beams/base_beam.gd | 87 +++++++++++++++ src/vessels/weapons/beams/base_beam.tscn | 104 ++++++++++++++++++ .../weapons/beams/mining/mining_beam.gd | 21 ++++ .../beams/mining/mining_beam_turret.tscn | 20 ++++ .../weapons/beams/mining/mining_turret.gd | 14 +++ test_object.gd | 13 +++ weapons_system.gd | 16 --- 27 files changed, 551 insertions(+), 163 deletions(-) create mode 100644 images/32blacksquare.png create mode 100644 images/32blacksquare.png.import create mode 100644 images/dot.png create mode 100644 images/dot.png.import create mode 100644 images/sparkle.png create mode 100644 images/sparkle.png.import create mode 100644 images/white_glowing_circle.png create mode 100644 images/white_glowing_circle.png.import delete mode 100644 laser.gd create mode 100644 spaceship.tscn rename hardpoint.gd => src/vessels/components/hardpoints/hardpoint.gd (88%) create mode 100644 src/vessels/components/hardpoints/hardpoint.tscn create mode 100644 src/vessels/hulls/base_hull.gd create mode 100644 src/vessels/hulls/base_hull.tscn create mode 100644 src/vessels/systems/weapons_system.gd create mode 100644 src/vessels/weapons/beams/base_beam.gd create mode 100644 src/vessels/weapons/beams/base_beam.tscn create mode 100644 src/vessels/weapons/beams/mining/mining_beam.gd create mode 100644 src/vessels/weapons/beams/mining/mining_beam_turret.tscn create mode 100644 src/vessels/weapons/beams/mining/mining_turret.gd create mode 100644 test_object.gd delete mode 100644 weapons_system.gd diff --git a/README.md b/README.md index 76257b4..2cf02c0 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # StarCheese - The Final Fromage -StarCheese is a small game project made in the Godot engine, specifically Godot 4.2.2 Stable (which might change) \ No newline at end of file +StarCheese is a small game project made in the Godot engine, specifically Godot 4.2.2 Stable (which might change) diff --git a/images/32blacksquare.png b/images/32blacksquare.png new file mode 100644 index 0000000000000000000000000000000000000000..21b7d763b03983a8ee441df6eb2344a29f4a3c74 GIT binary patch literal 133 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1SJ1Ryj={W7>k44ofy`glX(f`u%tWsIx;Y9 z?C1WI$O`0h7I;J!GcfQS24TkI`72U@f>NF?jv*f2Zx1r^0(plPeD{Bw#;3r*(6E}3 XM}dLSOo?kPP@KWj)z4*}Q$iB}sS+Rq literal 0 HcmV?d00001 diff --git a/images/32blacksquare.png.import b/images/32blacksquare.png.import new file mode 100644 index 0000000..7b96e03 --- /dev/null +++ b/images/32blacksquare.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ciy0e5x055p51" +path="res://.godot/imported/32blacksquare.png-4ebf2398d9deb7b95f7724d503d45993.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://images/32blacksquare.png" +dest_files=["res://.godot/imported/32blacksquare.png-4ebf2398d9deb7b95f7724d503d45993.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/dot.png b/images/dot.png new file mode 100644 index 0000000000000000000000000000000000000000..2e16b84623823d4417aacf6cdbcba57ea85736bb GIT binary patch literal 4808 zcmW+)c~p`M^L}|jS#G&tWR~UvnrXKvuU?HrGzzzr+$|Tp>a}dS=7zgK*4JujnR-jm zEcbvkx3t7^DJ$^H)Z9r+O;Ip2cliAM{+O9_=FEBinP+CsGgqlDl+CE^C;$L9JJ^%m zHX`Hy457T?UlW7gZ3IY^8^sRb3bnrj0Gj1Mw)Kd6FykMTZD6HhhF?{r%Few`uAAqo zXG+o@7KHUmyPe!Tai#Y6@>p!Eq4Tv%z4H3lltq}lda<8JcNJfXJy_Q?;%1Vn30m?w zhIXK6WqIz=(pwmbw2friLZz`=s(1XH!@iYuAtKNVS!eFN?CM-C)>CXdum%H-X}-yk z(rZKcDXbOPM687pC$H(>#M_AQ!GEggYP8la z(P-oI*_GD0tb#Sy#+R&=YZMu;nQ3F2I>J>RabO6ib@(?BI#vM=z#(C?wT&omGy~y+ zjM%xaY6JO)P{qfKbGz_2CCh!93Id2L2|E=yroQBU>S5!N%`YzkraMI>uih=k*~gil z(xx`7Y?pBcA`8~5SmY#&{Q_KA-Wr0|C6&)7%2r$~5pK8QU^Y&4KZo`0sTzlww?Yk} zRoNNhEEr8pXWxwJZ4+4VUXL3T}NlI&e!n{#7qB=Ubd)mZV=P#ZfY1cA}+|yQw zh3+U8J{IzN@)pB%f)}&y+Fy1|JH(~7??2-cbak|VZ22#sA;WYo3_h+W8ZzB3G7@07 z6nQ_*WEdn@eGYRAM$+;(;907$Pg$iBPHXbSdSLSl8`ZPkhF9vm)y+l4Gsd8Vm8!om>sPGo zZ(I_^wLn5PMgL4V$}(B^&T4UzVAWA}6 zw+y+#=0{ntW8oq+U>%Mkn(kWgNAszIvy}_M;=)gyf(mkpxVOH-*!CEV>rYQgPfm;x2%U~t;A~n*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index 0000000..4c779cd --- /dev/null +++ b/images/dot.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c3o1ttqdwn30x" +path.s3tc="res://.godot/imported/dot.png-33c725e4dcea1d588eb81ca554765516.s3tc.ctex" +metadata={ +"imported_formats": ["s3tc_bptc"], +"vram_texture": true +} + +[deps] + +source_file="res://images/dot.png" +dest_files=["res://.godot/imported/dot.png-33c725e4dcea1d588eb81ca554765516.s3tc.ctex"] + +[params] + +compress/mode=2 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=true +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=0 diff --git a/images/sparkle.png b/images/sparkle.png new file mode 100644 index 0000000000000000000000000000000000000000..af2b74e3a58880a82fbebcc16f5482966d6bbe88 GIT binary patch literal 3699 zcmV-(4vg`MP)aSAPI?KXFGu)Bs(OwukU5iw`OY2J?GTv z?&_KD>;9xxRaeh+pXu+bQ;+UB1v6&Mm@#9(wS8-|zNcLeYyntg zTbuPg>l!PAwjhL!3!p%Lw8k%h9i=QP3VGcU`H^j3DMQI?>B^uDi(sPyXhFVL({~E_ zk}&dX9WgOWBSh~jWnIOvx*;1B!NvrjkZ-wsYm)@$sdub~03^|Q>K%(T74q7Rfg2LR zMg-uH@3r+-?anu?OcR9V367Y`iU_Nw%dJ#yc?F!bxfvS}!QcW2l3%LvrR{`sOcO$W z{iUf{8Xn(ll6RMNo4T;MIO>*k`r-lJH&N3~(0s8t{>dcGtiu8gKL<@FdMJGBVj@ zJ%c!4{l3X_R2voa5k(%jVVFmCb_9ss^gW3z0+^3jVni)qbTg6$D{p|b#t zwm;wZrhH4aKi#l1G&TR5z`b2<-2(0fz6HFCl?Ri<*L?26BHx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x3XL=c^C%jx{ego>asrSdRU*kBB;Hn--+l? z&2?V|m5PrVjPCWG2KyO6R{^j$Wvf((h*%T5_^Yo$Nz*j6*=!gJ(AHB)fwFB-{Pv(& zNc&rro2x;YJKO`XK@Sz!jn<$h5wW(WhzK=JBjY&MI|8oF@6{bE$vFq02+dju4#6)T1p;34PX^viYu6>#V-R%o`#ap?VRuA+xi9V~gY%KXu^@Q(liZC(}Wv0N{tqZa2z$4U4aZ+8H)qjAHE|nIDcI+^B^J*M6?!>(MMwu zDXMxCo^5|Hvvs#kSpytx`3EhDs2jIFqu2A`rk(*owP!nms*^@wE0piwW)L;Ee3xC@ zl^t~PY8^b^wybsWCg-(5O;W zGphAxYbmH7qk?YqIjj}3Wxi3natGD|l|BT!`L;BFtv?Dmv_S8rHa#^^VW40?MXmF0 zDvlVGnAyxX2c0`PYMa3@3}RgZEpz0YGj_Tqm}(IAVtXp=T79&vc=qk7_^<4i+1V+h zrkgLiTjm+|L6w)YXCG9pDDb@dp#FC|+%CL#(Hc%vQ#RP3`DOPm)_|>t^40B1jezH% zvGsY%eq#jGD&d#iZ#)D2b?zjeQ<=Wj{}I>&y#?;}HS9h9mH+*51o#g8OvV<%oeTIZ ium^%4d_2d0Z2be!RoM;c{vO@{0000 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: - var damage_event = DamageEvent.new(laser_damage, collider) - event_bus.publish(get_node("/root/Main/DamageEventScope"), damage_event) - else: - $LaserLine2D.set_point_position(1, Vector2(0, -laser_range)) - else: - $LaserLine2D.clear_points() - $LaserLine2D.add_point(Vector2.ZERO) - $LaserLine2D.add_point(Vector2.ZERO) diff --git a/main.gd b/main.gd index ebb22cf..11a3036 100644 --- a/main.gd +++ b/main.gd @@ -31,7 +31,7 @@ func _ready() -> void: pass # Replace with function body. # Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta: float) -> void: +func _process(_delta: float) -> void: var actions = [ "ui_fire", "ui_up", diff --git a/main.tscn b/main.tscn index 122934a..1bb12c9 100644 --- a/main.tscn +++ b/main.tscn @@ -1,22 +1,10 @@ -[gd_scene load_steps=11 format=3 uid="uid://8ocp10j32f62"] +[gd_scene load_steps=5 format=3 uid="uid://8ocp10j32f62"] [ext_resource type="Script" path="res://main.gd" id="1_eedai"] [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="Texture2D" uid="uid://bxgw2u7j4b634" path="res://images/laser_turret.png" id="6_qxhyw"] -[ext_resource type="Script" path="res://hardpoint.gd" id="7_6cr6a"] +[ext_resource type="PackedScene" uid="uid://dej58eek7fudd" path="res://spaceship.tscn" id="3_h8rrl"] [ext_resource type="Script" path="res://spawn_asteroid_button.gd" id="9_21dg0"] -[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) - [node name="Main" type="Node2D"] script = ExtResource("1_eedai") @@ -24,52 +12,9 @@ script = ExtResource("1_eedai") position = Vector2(955, 537) scale = Vector2(2, 2) texture = ExtResource("1_rpyi5") +metadata/_edit_lock_ = true -[node name="spaceship" type="CharacterBody2D" parent="."] -position = Vector2(956, 623) -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="HardPoint1" type="Node2D" parent="spaceship"] -position = Vector2(0, -46) -script = ExtResource("7_6cr6a") +[node name="spaceship" parent="." instance=ExtResource("3_h8rrl")] [node name="SpawnAsteroidButton" type="Button" parent="."] offset_left = 72.0 diff --git a/project.godot b/project.godot index bbc0fb8..06caccc 100644 --- a/project.godot +++ b/project.godot @@ -27,6 +27,11 @@ ui_fire={ "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":4194326,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) ] } +fire_weapon={ +"deadzone": 0.5, +"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(133, 15),"global_position":Vector2(142, 61),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null) +] +} [layer_names] diff --git a/spaceship.gd b/spaceship.gd index c822f60..208c6d7 100644 --- a/spaceship.gd +++ b/spaceship.gd @@ -4,9 +4,7 @@ extends CharacterBody2D @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 +@onready var laser := $WeaponsSystem/mining_beam_turret/mining_beam var weapons_system: WeaponsSystem var event_bus: EventBus @@ -14,7 +12,7 @@ func _ready(): weapons_system = get_node("/root/Main/WeaponsSystem") event_bus = get_node("/root/Main/MainEventBus") event_bus.subscribe_to(get_node("/root/Main/InputEventScope"), "KeyboardInputEvent", Callable(self, "handle_keyboard_input")) - + func get_spaceship_orientation_vector() -> Vector2: return -global_transform.y @@ -22,11 +20,11 @@ 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 + thrust = Vector2(1, 0).rotated(rotation) * acceleration * delta velocity += thrust if Input.is_action_pressed("ui_down"): - thrust = Vector2(0, 1).rotated(rotation) * acceleration * delta + thrust = Vector2(-1, 0).rotated(rotation) * acceleration * delta velocity += thrust if Input.is_action_pressed("ui_left"): @@ -35,7 +33,6 @@ func handle_movement(delta: float) -> void: 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 @@ -47,14 +44,17 @@ func handle_movement(delta: float) -> void: var collision_normal = collision.get_normal() velocity = velocity.slide(collision_normal) +func _unhandled_input(event: InputEvent) -> void: + if not event.is_action("fire_weapon"): + return + laser.is_casting = event.is_action_pressed("fire_weapon") + func handle_keyboard_input(event: KeyboardInputEvent): - if( event.action == "ui_fire" ): - if( event.pressed ): + if event.action == "ui_fire": + if event.pressed: weapons_system.fire_all() else: weapons_system.cease_fire_all() - - pass func _process(delta: float) -> void: handle_movement(delta) diff --git a/spaceship.tscn b/spaceship.tscn new file mode 100644 index 0000000..8e81aaf --- /dev/null +++ b/spaceship.tscn @@ -0,0 +1,30 @@ +[gd_scene load_steps=6 format=3 uid="uid://dej58eek7fudd"] + +[ext_resource type="Script" path="res://spaceship.gd" id="1_bwnho"] +[ext_resource type="PackedScene" uid="uid://kke1bgv1bvht" path="res://src/vessels/weapons/beams/mining/mining_beam_turret.tscn" id="2_4ub4i"] +[ext_resource type="Texture2D" uid="uid://cran7fr1i2qou" path="res://images/spaceship-placeholder.png" id="3_xxo2y"] +[ext_resource type="Script" path="res://src/vessels/systems/weapons_system.gd" id="4_w4ss2"] + +[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_3vtwu"] +radius = 48.0 +height = 102.0 + +[node name="spaceship" type="CharacterBody2D"] +position = Vector2(956, 623) +collision_layer = 2 +motion_mode = 1 +script = ExtResource("1_bwnho") + +[node name="WeaponsSystem" type="Node" parent="."] +script = ExtResource("4_w4ss2") + +[node name="mining_beam_turret" parent="WeaponsSystem" instance=ExtResource("2_4ub4i")] +position = Vector2(1009, 623) + +[node name="Sprite2D" type="Sprite2D" parent="."] +z_index = 1 +rotation = 1.5708 +texture = ExtResource("3_xxo2y") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CapsuleShape2D_3vtwu") diff --git a/hardpoint.gd b/src/vessels/components/hardpoints/hardpoint.gd similarity index 88% rename from hardpoint.gd rename to src/vessels/components/hardpoints/hardpoint.gd index 228b5b7..20b3fec 100644 --- a/hardpoint.gd +++ b/src/vessels/components/hardpoints/hardpoint.gd @@ -9,7 +9,7 @@ var mounted_weapon: Node2D = null 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 + #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 diff --git a/src/vessels/components/hardpoints/hardpoint.tscn b/src/vessels/components/hardpoints/hardpoint.tscn new file mode 100644 index 0000000..678d144 --- /dev/null +++ b/src/vessels/components/hardpoints/hardpoint.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=3 format=3 uid="uid://detjgwvlxhxhk"] + +[ext_resource type="Script" path="res://src/vessels/components/hardpoints/hardpoint.gd" id="1_sd20m"] +[ext_resource type="Texture2D" uid="uid://ciy0e5x055p51" path="res://images/32blacksquare.png" id="2_d8vdx"] + +[node name="Hardpoint" type="Node2D"] +script = ExtResource("1_sd20m") + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("2_d8vdx") diff --git a/src/vessels/hulls/base_hull.gd b/src/vessels/hulls/base_hull.gd new file mode 100644 index 0000000..076fa5f --- /dev/null +++ b/src/vessels/hulls/base_hull.gd @@ -0,0 +1,64 @@ +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 + +var weapons_system: WeaponsSystem +var event_bus: EventBus +func _ready(): + weapons_system = get_node("/root/Main/WeaponsSystem") + event_bus = get_node("/root/Main/MainEventBus") + event_bus.subscribe_to(get_node("/root/Main/InputEventScope"), "KeyboardInputEvent", Callable(self, "handle_keyboard_input")) + + +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(1, 0).rotated(rotation) * acceleration * delta + velocity += thrust + + if Input.is_action_pressed("ui_down"): + thrust = Vector2(-1, 0).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 _unhandled_input(event: InputEvent) -> void: +# if not event.is_action("fire_weapon"): +# return + #laser.is_casting = event.is_action_pressed("fire_weapon") +# pass + +func handle_keyboard_input(event: KeyboardInputEvent): + if( event.action == "ui_fire" ): + if( event.pressed ): + weapons_system.fire_all() + else: + weapons_system.cease_fire_all() + + pass + +func _process(delta: float) -> void: + handle_movement(delta) diff --git a/src/vessels/hulls/base_hull.tscn b/src/vessels/hulls/base_hull.tscn new file mode 100644 index 0000000..5a5de78 --- /dev/null +++ b/src/vessels/hulls/base_hull.tscn @@ -0,0 +1,20 @@ +[gd_scene load_steps=3 format=3 uid="uid://b1goask3ynem3"] + +[ext_resource type="Texture2D" uid="uid://cran7fr1i2qou" path="res://images/spaceship-placeholder.png" id="1_2uldm"] + +[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_3vtwu"] +radius = 48.0 +height = 102.0 + +[node name="spaceship" type="CharacterBody2D"] +position = Vector2(956, 623) +collision_layer = 2 +motion_mode = 1 + +[node name="Sprite2D" type="Sprite2D" parent="."] +z_index = 1 +rotation = 1.5708 +texture = ExtResource("1_2uldm") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CapsuleShape2D_3vtwu") diff --git a/src/vessels/systems/weapons_system.gd b/src/vessels/systems/weapons_system.gd new file mode 100644 index 0000000..128519f --- /dev/null +++ b/src/vessels/systems/weapons_system.gd @@ -0,0 +1,8 @@ +class_name WeaponsSystem +extends Node + +func fire_all(): + get_tree().call_group("turrets", "fire") + +func cease_fire_all(): + get_tree().call_group("turrets", "cease_fire") diff --git a/src/vessels/weapons/beams/base_beam.gd b/src/vessels/weapons/beams/base_beam.gd new file mode 100644 index 0000000..a14ff49 --- /dev/null +++ b/src/vessels/weapons/beams/base_beam.gd @@ -0,0 +1,87 @@ +# Casts a laser along a raycast, emitting particles on the impact point. +# Use `is_casting` to make the laser fire and stop. +# You can attach it to a weapon or a ship; the laser will rotate with its parent. +extends RayCast2D + +# Speed at which the laser extends when first fired, in pixels per seconds. +@export var cast_speed := 70000.0 +# Maximum length of the laser in pixels. +@export var max_length := 1400.0 +# Base duration of the tween animation in seconds. +@export var growth_time := 0.1 + + + +# If `true`, the laser is firing. +# It plays appearing and disappearing animations when it's not animating. +# See `appear()` and `disappear()` for more information. +var is_casting := false: set = set_is_casting + +@onready var fill : Line2D = $FillLine2D +var tween : Tween +@onready var casting_particles := $CastingParticles2D +@onready var collision_particles := $CollisionParticles2D +@onready var beam_particles := $BeamParticles2D + +@onready var line_width: float = fill.width + + +func _ready() -> void: + set_physics_process(false) + fill.points[1] = Vector2.ZERO + + + +func _physics_process(delta: float) -> void: + target_position = (target_position + Vector2.RIGHT * cast_speed * delta).limit_length(max_length) + cast_beam() + + +func set_is_casting(cast: bool) -> void: + is_casting = cast + + if is_casting: + target_position = Vector2.ZERO + fill.points[1] = target_position + appear() + else: + # Reset the laser endpoint + fill.points[1] = Vector2.ZERO + + collision_particles.emitting = false + disappear() + + set_physics_process(is_casting) + beam_particles.emitting = is_casting + casting_particles.emitting = is_casting + + +# Controls the emission of particles and extends the Line2D to `cast_to` or the ray's +# collision point, whichever is closest. +func cast_beam() -> void: + var cast_point := target_position + + force_raycast_update() + collision_particles.emitting = is_colliding() + + if is_colliding(): + cast_point = to_local(get_collision_point()) + collision_particles.global_rotation = get_collision_normal().angle() + collision_particles.position = cast_point + + fill.points[1] = cast_point + beam_particles.position = cast_point * 0.5 + beam_particles.process_material.emission_box_extents.x = cast_point.length() * 0.5 + + +func appear() -> void: + if tween and tween.is_running(): + tween.kill() + tween = create_tween() + tween.tween_property(fill, "width", line_width, growth_time * 2).from(0) + +func disappear() -> void: + if tween and tween.is_running(): + tween.kill() + tween = create_tween() + tween.tween_property(fill, "width", 0, growth_time).from_current() diff --git a/src/vessels/weapons/beams/base_beam.tscn b/src/vessels/weapons/beams/base_beam.tscn new file mode 100644 index 0000000..49b7d29 --- /dev/null +++ b/src/vessels/weapons/beams/base_beam.tscn @@ -0,0 +1,104 @@ +[gd_scene load_steps=12 format=3 uid="uid://tldpf6ukiu3f"] + +[ext_resource type="Script" path="res://src/vessels/weapons/beams/base_beam.gd" id="1_fdyd4"] +[ext_resource type="Texture2D" uid="uid://di7nndrreqmtf" path="res://images/glowing_circle.png" id="2_h1jdn"] + +[sub_resource type="Gradient" id="1"] +offsets = PackedFloat32Array(0.582915, 1) +colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0) + +[sub_resource type="GradientTexture2D" id="2"] +gradient = SubResource("1") + +[sub_resource type="Curve" id="3"] +_data = [Vector2(0.518072, 1), 0.0, -3.53434, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="CurveTexture" id="4"] +width = 2048 +curve = SubResource("3") + +[sub_resource type="ParticleProcessMaterial" id="5"] +initial_velocity_min = 100.0 +initial_velocity_max = 100.0 +gravity = Vector3(0, 0, 0) +scale_min = 0.5 +scale_max = 0.5 +scale_curve = SubResource("4") +color_ramp = SubResource("2") + +[sub_resource type="Curve" id="6"] +_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(0.503614, 0.957505), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0] +point_count = 3 + +[sub_resource type="CurveTexture" id="7"] +curve = SubResource("6") + +[sub_resource type="ParticleProcessMaterial" id="8"] +particle_flag_align_y = true +particle_flag_disable_z = true +emission_shape = 3 +emission_box_extents = Vector3(60, 20, 1) +direction = Vector3(-1, 0, 0) +spread = 0.0 +gravity = Vector3(0, 0, 0) +tangential_accel_min = 100.0 +tangential_accel_max = 100.0 +scale_min = 0.3 +scale_max = 0.3 +scale_curve = SubResource("7") + +[sub_resource type="ParticleProcessMaterial" id="9"] +particle_flag_disable_z = true +spread = 50.0 +initial_velocity_min = 300.0 +initial_velocity_max = 300.0 +gravity = Vector3(0, 0, 0) +scale_min = 0.5 +scale_max = 0.5 +scale_curve = SubResource("4") +color_ramp = SubResource("2") + +[node name="BaseBeam2D" type="RayCast2D"] +target_position = Vector2(0, 0) +script = ExtResource("1_fdyd4") + +[node name="FillLine2D" type="Line2D" parent="."] +modulate = Color(1.5, 1.5, 1.5, 1) +points = PackedVector2Array(0, 0, 100, 0) +default_color = Color(0.301961, 0.65098, 1, 1) +texture_mode = 2 +joint_mode = 2 +begin_cap_mode = 2 +end_cap_mode = 2 +sharp_limit = 8.0 +antialiased = true + +[node name="CastingParticles2D" type="GPUParticles2D" parent="."] +modulate = Color(1.5, 1.5, 1.5, 1) +show_behind_parent = true +emitting = false +process_material = SubResource("5") +texture = ExtResource("2_h1jdn") +lifetime = 0.3 +visibility_rect = Rect2(0, -18.722, 29.6756, 38.4841) + +[node name="BeamParticles2D" type="GPUParticles2D" parent="."] +modulate = Color(1.5, 1.5, 1.5, 1) +emitting = false +amount = 50 +process_material = SubResource("8") +texture = ExtResource("2_h1jdn") +preprocess = 1.0 +randomness = 1.0 +visibility_rect = Rect2(-2500, -2500, 5000, 5000) + +[node name="CollisionParticles2D" type="GPUParticles2D" parent="."] +modulate = Color(1.5, 1.5, 1.5, 1) +show_behind_parent = true +emitting = false +amount = 16 +process_material = SubResource("9") +texture = ExtResource("2_h1jdn") +lifetime = 0.3 +visibility_rect = Rect2(-2500, -2500, 5000, 5000) diff --git a/src/vessels/weapons/beams/mining/mining_beam.gd b/src/vessels/weapons/beams/mining/mining_beam.gd new file mode 100644 index 0000000..f8c3df2 --- /dev/null +++ b/src/vessels/weapons/beams/mining/mining_beam.gd @@ -0,0 +1,21 @@ +extends "res://src/vessels/weapons/beams/base_beam.gd" +var event_bus: EventBus +@export var laser_damage: float = 0.8 + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + super._ready() + add_to_group("weapons") + event_bus = get_node("/root/Main/MainEventBus") + +func cast_beam() -> void: + super.cast_beam() + if is_colliding(): + var collider = get_collider() + if collider: + var damage_event = DamageEvent.new(laser_damage, collider) + event_bus.publish(get_node("/root/Main/DamageEventScope"), damage_event) + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass diff --git a/src/vessels/weapons/beams/mining/mining_beam_turret.tscn b/src/vessels/weapons/beams/mining/mining_beam_turret.tscn new file mode 100644 index 0000000..cece554 --- /dev/null +++ b/src/vessels/weapons/beams/mining/mining_beam_turret.tscn @@ -0,0 +1,20 @@ +[gd_scene load_steps=5 format=3 uid="uid://kke1bgv1bvht"] + +[ext_resource type="Script" path="res://src/vessels/weapons/beams/mining/mining_turret.gd" id="1_l6ng7"] +[ext_resource type="PackedScene" uid="uid://tldpf6ukiu3f" path="res://src/vessels/weapons/beams/base_beam.tscn" id="2_litw1"] +[ext_resource type="Script" path="res://src/vessels/weapons/beams/mining/mining_beam.gd" id="3_orfy2"] +[ext_resource type="Texture2D" uid="uid://bxgw2u7j4b634" path="res://images/laser_turret.png" id="4_ut0ve"] + +[node name="mining_beam_turret" type="Node2D"] +script = ExtResource("1_l6ng7") + +[node name="mining_beam" parent="." instance=ExtResource("2_litw1")] +position = Vector2(14, 0) +script = ExtResource("3_orfy2") +laser_damage = 0.8 + +[node name="turret" type="Sprite2D" parent="."] +position = Vector2(-3, -0.0834265) +rotation = 1.5708 +scale = Vector2(1.50815, 1.37222) +texture = ExtResource("4_ut0ve") diff --git a/src/vessels/weapons/beams/mining/mining_turret.gd b/src/vessels/weapons/beams/mining/mining_turret.gd new file mode 100644 index 0000000..646d732 --- /dev/null +++ b/src/vessels/weapons/beams/mining/mining_turret.gd @@ -0,0 +1,14 @@ +extends Node2D +@onready var mining_beam := $mining_beam +var event_bus: EventBus + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + event_bus = get_node("/root/Main/MainEventBus") + add_to_group("turrets") # Add this turret to the "turrets" group + +func fire(): + mining_beam.is_casting = true + +func cease_fire(): + mining_beam.is_casting = false diff --git a/test_object.gd b/test_object.gd new file mode 100644 index 0000000..8ff8c3e --- /dev/null +++ b/test_object.gd @@ -0,0 +1,13 @@ +extends Node2D + +@onready var laser := $LaserBeam2D + + +func _process(_delta: float) -> void: + look_at(get_global_mouse_position()) + + +func _unhandled_input(event: InputEvent) -> void: + if not event.is_action("fire_weapon"): + return + laser.is_casting = event.is_action_pressed("fire_weapon") diff --git a/weapons_system.gd b/weapons_system.gd deleted file mode 100644 index 23e70e2..0000000 --- a/weapons_system.gd +++ /dev/null @@ -1,16 +0,0 @@ -class_name WeaponsSystem -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")