From 488b3a9831c5d29bafc7a009ba1f1b657151c482 Mon Sep 17 00:00:00 2001 From: h0lybyte <5599058+h0lybyte@users.noreply.github.com> Date: Fri, 21 Feb 2025 06:15:33 -0500 Subject: [PATCH] feat(brackeys13): added shield support. --- apps/gamejam/brackeys/13/scenes/asteroid.tscn | 2 + .../gamejam/brackeys/13/scenes/spaceship.tscn | 133 +++++++++++++++++- apps/gamejam/brackeys/13/scripts/asteroid.gd | 5 + apps/gamejam/brackeys/13/scripts/spaceship.gd | 18 ++- 4 files changed, 152 insertions(+), 6 deletions(-) diff --git a/apps/gamejam/brackeys/13/scenes/asteroid.tscn b/apps/gamejam/brackeys/13/scenes/asteroid.tscn index d55366ffd..b8f4c1213 100644 --- a/apps/gamejam/brackeys/13/scenes/asteroid.tscn +++ b/apps/gamejam/brackeys/13/scenes/asteroid.tscn @@ -16,3 +16,5 @@ texture = ExtResource("1_bra2q") [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource("CircleShape2D_qw1xp") + +[connection signal="body_entered" from="." to="." method="_on_body_entered"] diff --git a/apps/gamejam/brackeys/13/scenes/spaceship.tscn b/apps/gamejam/brackeys/13/scenes/spaceship.tscn index ed569221c..6ca26baa9 100644 --- a/apps/gamejam/brackeys/13/scenes/spaceship.tscn +++ b/apps/gamejam/brackeys/13/scenes/spaceship.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=18 format=3 uid="uid://1s5v0llrjq3"] +[gd_scene load_steps=36 format=3 uid="uid://1s5v0llrjq3"] [ext_resource type="Script" path="res://scripts/spaceship.gd" id="1_uejed"] [ext_resource type="Texture2D" uid="uid://b5a5g0gqvormg" path="res://assets/frostwindz/battlecruiser.png" id="2_kvtre"] [ext_resource type="Texture2D" uid="uid://cj16mbdine6mk" path="res://assets/frostwindz/battlecruiser_engine.png" id="3_mwphh"] +[ext_resource type="Texture2D" uid="uid://84n6013yietv" path="res://assets/frostwindz/battlecruiser_shield.png" id="4_yxx3w"] [sub_resource type="CircleShape2D" id="CircleShape2D_s734v"] radius = 36.0139 @@ -99,6 +100,126 @@ animations = [{ "speed": 5.0 }] +[sub_resource type="AtlasTexture" id="AtlasTexture_srl8d"] +atlas = ExtResource("4_yxx3w") +region = Rect2(0, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_miugn"] +atlas = ExtResource("4_yxx3w") +region = Rect2(128, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_aacb1"] +atlas = ExtResource("4_yxx3w") +region = Rect2(256, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_jr7jx"] +atlas = ExtResource("4_yxx3w") +region = Rect2(384, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_4r5u6"] +atlas = ExtResource("4_yxx3w") +region = Rect2(512, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_2g3gh"] +atlas = ExtResource("4_yxx3w") +region = Rect2(640, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_dxcam"] +atlas = ExtResource("4_yxx3w") +region = Rect2(768, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_s3bim"] +atlas = ExtResource("4_yxx3w") +region = Rect2(896, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_frb3p"] +atlas = ExtResource("4_yxx3w") +region = Rect2(1024, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_0ccj1"] +atlas = ExtResource("4_yxx3w") +region = Rect2(1152, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_kl5ol"] +atlas = ExtResource("4_yxx3w") +region = Rect2(1280, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_gpumw"] +atlas = ExtResource("4_yxx3w") +region = Rect2(1408, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ogmnx"] +atlas = ExtResource("4_yxx3w") +region = Rect2(1536, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_5mjgc"] +atlas = ExtResource("4_yxx3w") +region = Rect2(1664, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_pcyl7"] +atlas = ExtResource("4_yxx3w") +region = Rect2(1792, 0, 128, 128) + +[sub_resource type="AtlasTexture" id="AtlasTexture_4l5jx"] +atlas = ExtResource("4_yxx3w") +region = Rect2(1920, 0, 128, 128) + +[sub_resource type="SpriteFrames" id="SpriteFrames_wdipm"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_srl8d") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_miugn") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_aacb1") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_jr7jx") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_4r5u6") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_2g3gh") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_dxcam") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_s3bim") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_frb3p") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_0ccj1") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_kl5ol") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_gpumw") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ogmnx") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_5mjgc") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_pcyl7") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_4l5jx") +}], +"loop": true, +"name": &"shield", +"speed": 5.0 +}] + [node name="Spaceship" type="CharacterBody2D"] collision_layer = 32 collision_mask = 472 @@ -117,7 +238,13 @@ shape = SubResource("CircleShape2D_s734v") position = Vector2(0, -46) [node name="Engine" type="AnimatedSprite2D" parent="."] -position = Vector2(0, -4) -scale = Vector2(0.804688, 0.9375) +position = Vector2(-0.125006, 1.5) +scale = Vector2(0.798828, 0.820312) sprite_frames = SubResource("SpriteFrames_0gnt7") animation = &"engine" + +[node name="Shield" type="AnimatedSprite2D" parent="."] +position = Vector2(-8.34465e-07, 1.75) +scale = Vector2(0.84375, 0.832031) +sprite_frames = SubResource("SpriteFrames_wdipm") +animation = &"shield" diff --git a/apps/gamejam/brackeys/13/scripts/asteroid.gd b/apps/gamejam/brackeys/13/scripts/asteroid.gd index 720bccb99..e95cc9d20 100644 --- a/apps/gamejam/brackeys/13/scripts/asteroid.gd +++ b/apps/gamejam/brackeys/13/scripts/asteroid.gd @@ -31,3 +31,8 @@ func destroy(): visible = false print("Asteroid Destroyed") Global.emit_signal("entity_destroyed", "asteroid", get_instance_id(), {"position": global_position}) + +func _on_body_entered(body): + if body is Spaceship: + var starship = body + starship.activate_shield() diff --git a/apps/gamejam/brackeys/13/scripts/spaceship.gd b/apps/gamejam/brackeys/13/scripts/spaceship.gd index 5805d2873..47ec41ec1 100644 --- a/apps/gamejam/brackeys/13/scripts/spaceship.gd +++ b/apps/gamejam/brackeys/13/scripts/spaceship.gd @@ -5,6 +5,7 @@ signal laser_shot(laser) @onready var scope = $OmniScope @onready var engine = $Engine +@onready var shield = $Shield var laser_scene = preload("res://scenes/laser.tscn") @@ -14,6 +15,7 @@ func _ready(): func _process(delta): if Input.is_action_pressed("shoot"): + shield.visible = false shoot_laser() func _physics_process(delta): @@ -23,7 +25,11 @@ func _physics_process(delta): var input_vector := Vector2(0, Input.get_axis("thrust", "reverse")) velocity += input_vector.rotated(rotation) * acceleration velocity = velocity.limit_length(max_speed) - engine.play("engine") + + if input_vector or velocity.length() > 0.1: + engine.play("engine") + else: + engine.stop() if Input.is_action_pressed("pan_right"): rotate(deg_to_rad(rotation_speed*delta)) @@ -34,12 +40,12 @@ func _physics_process(delta): var drift_direction = Vector2.RIGHT.rotated(rotation) if Input.is_action_pressed("drift_right"): - print("E Pressed - Thrust Right Detected") + #print("E Pressed - Thrust Right Detected") global_position = global_position.lerp(global_position + drift_direction * drift_force, delta * 5) if Input.is_action_pressed("drift_left"): - print("Q Pressed - Thrust Left Detected") + #print("Q Pressed - Thrust Left Detected") global_position = global_position.lerp(global_position - drift_direction * drift_force, delta * 5) if input_vector.y == 0: @@ -60,3 +66,9 @@ func _physics_process(delta): func shoot_laser(): emit_signal("laser_shot", scope.global_position, rotation) + + +func activate_shield(): + Global.emit_signal("notification_received", "shield_active", "Shield was deployed", "warning") + shield.visible = true + shield.play("shield")