From 39fdf118071287f1613ca4ee07bc95f445f47732 Mon Sep 17 00:00:00 2001 From: Haze Weathers Date: Tue, 27 Feb 2024 20:04:51 -0500 Subject: [PATCH] boss variant of hud --- maps/boss/boss1_arena.tscn | 4 +- maps/boss/boss2_arena.tscn | 4 +- objects/hud/hud_boss.gd | 83 ++++++++++++++++ objects/hud/hud_boss.tscn | 192 +++++++++++++++++++++++++++++++++++++ 4 files changed, 279 insertions(+), 4 deletions(-) create mode 100644 objects/hud/hud_boss.gd create mode 100644 objects/hud/hud_boss.tscn diff --git a/maps/boss/boss1_arena.tscn b/maps/boss/boss1_arena.tscn index e5fb68f..7b7b042 100644 --- a/maps/boss/boss1_arena.tscn +++ b/maps/boss/boss1_arena.tscn @@ -5,7 +5,7 @@ [ext_resource path="res://graphics/backgrounds/mountain_clouds.png" type="Texture" id=3] [ext_resource path="res://graphics/backgrounds/mountain_sunset.png" type="Texture" id=4] [ext_resource path="res://tilesets/t_mountain.tres" type="TileSet" id=5] -[ext_resource path="res://objects/hud/hud.tscn" type="PackedScene" id=6] +[ext_resource path="res://objects/hud/hud_boss.tscn" type="PackedScene" id=6] [ext_resource path="res://maps/boss/boss1_arena.gd" type="Script" id=7] [ext_resource path="res://objects/collectibles/arrow.tscn" type="PackedScene" id=8] [ext_resource path="res://objects/environment/turniwood/turning_platform.tscn" type="PackedScene" id=9] @@ -23,7 +23,7 @@ script = ExtResource( 7 ) music = ExtResource( 11 ) lore_entries = [ ExtResource( 16 ) ] -[node name="HUD" parent="." instance=ExtResource( 6 )] +[node name="BossHUD" parent="." instance=ExtResource( 6 )] song_name = "♫Klystron" [node name="Sprite" type="Sprite" parent="."] diff --git a/maps/boss/boss2_arena.tscn b/maps/boss/boss2_arena.tscn index bc5033b..294e5ae 100644 --- a/maps/boss/boss2_arena.tscn +++ b/maps/boss/boss2_arena.tscn @@ -5,7 +5,7 @@ [ext_resource path="res://objects/environment/falling_block/falling_block_lab.tscn" type="PackedScene" id=3] [ext_resource path="res://graphics/backgrounds/factory.png" type="Texture" id=4] [ext_resource path="res://maps/boss/boss2_arena.gd" type="Script" id=5] -[ext_resource path="res://objects/hud/hud.tscn" type="PackedScene" id=6] +[ext_resource path="res://objects/hud/hud_boss.tscn" type="PackedScene" id=6] [ext_resource path="res://audio/music/klystron_vip.ogg" type="AudioStream" id=7] [ext_resource path="res://objects/collectibles/arrow.tscn" type="PackedScene" id=8] [ext_resource path="res://shaders/can_stain.tres" type="Material" id=9] @@ -24,7 +24,7 @@ script = ExtResource( 5 ) music = ExtResource( 7 ) lore_entries = [ ExtResource( 17 ), ExtResource( 11 ) ] -[node name="HUD" parent="." instance=ExtResource( 6 )] +[node name="BossHUD" parent="." instance=ExtResource( 6 )] song_name = "♫Klystron VIP" [node name="Sprite" type="Sprite" parent="."] diff --git a/objects/hud/hud_boss.gd b/objects/hud/hud_boss.gd new file mode 100644 index 0000000..487aa8e --- /dev/null +++ b/objects/hud/hud_boss.gd @@ -0,0 +1,83 @@ +extends CanvasLayer + +onready var gold_counter = $GoldCounter +onready var shard_counter = $ShardCounter +onready var red_star = $RedStar +onready var yellow_star = $YellowStar +onready var green_star = $GreenStar +onready var blue_star = $BlueStar +onready var magenta_star = $MagentaStar +onready var score_counter = $ScoreCounter +onready var arrow_counter = $ArrowCounter +onready var lives_counter = $LivesCounter +onready var high_counter = $HighCounter +onready var time_counter = $TimeCounter +onready var oxygen = $Oxygen +onready var oxygen_meter = $Oxygen/OxygenMeter + +export var song_name = "♫Music" +export (Color) var bonus_color + +func _ready(): + #Change graphics depending on if lives are on + if Game.use_lives: + $LivesHead.visible = true + else: + $DeathsHead.visible = true + #Change text to song name + var music = $Music + music.text = song_name + yield(get_tree(), "idle_frame") + var tween = create_tween() + tween.tween_property(music, "rect_position:x", 254.0 - music.rect_size.x, 1.0) + tween.tween_interval(3.0) + tween.tween_property(music, "rect_position:x", 256.0, 1.0) + #Fixes frame 1 2 deaths counter + if Game.use_lives == false: + lives_counter.text = str(Game.deaths) + #Show oxygen meter when underwater +# var player = get_tree().get_nodes_in_group("player").pop_back() +# if player.underwater == true: oxygen.visible = true + +func shard_popup(shard_number): + #Change text to song name + var shard_title = $ShardTitle + var level = LevelData.levels[Game.current_level] + shard_title.text = "§" + str(level.shard_titles[shard_number]) + yield(get_tree(), "idle_frame") + var tween = create_tween() + tween.tween_property(shard_title, "rect_position:x", 254.0 - shard_title.rect_size.x, 1.0) + tween.tween_interval(3.0) + tween.tween_property(shard_title, "rect_position:x", 256.0, 1.0) + +func _physics_process(delta): + #Star Counter + red_star.visible = Game.stars_collected[0] + yellow_star.visible = Game.stars_collected[1] + green_star.visible = Game.stars_collected[2] + blue_star.visible = Game.stars_collected[3] + magenta_star.visible = Game.stars_collected[4] + #Arrow Counter + arrow_counter.text = str(Game.arrows) + ##TOUCH UP LATER + #Lives counter + if Game.use_lives: + lives_counter.text = str(Game.lives) + else: + lives_counter.text = str(Game.deaths) + #Life bonus color + if Game.lives == 2: + lives_counter.modulate = bonus_color + else: + lives_counter.modulate = Color.white + ##Timer + time_counter.text = Game.format_time(Game.time) + #Time bonus counter + if (Game.has_collection_bonus() && Game.time <= Game.get_map().target_time_100) or (!Game.has_collection_bonus() && Game.time <= Game.get_map().target_time_any): + time_counter.modulate = bonus_color + else: + time_counter.modulate = Color.white +# #Oxygen meter +# var player = get_tree().get_nodes_in_group("player").pop_back() +# oxygen_meter.scale.x = player.oxygen_timer.time_left + #if oxygen_meter.scale.x > 15: oxygen_meter.scale.x = 15 diff --git a/objects/hud/hud_boss.tscn b/objects/hud/hud_boss.tscn new file mode 100644 index 0000000..5007043 --- /dev/null +++ b/objects/hud/hud_boss.tscn @@ -0,0 +1,192 @@ +[gd_scene load_steps=16 format=2] + +[ext_resource path="res://graphics/hud/stars_hud.png" type="Texture" id=1] +[ext_resource path="res://graphics/hud/lives_head.png" type="Texture" id=2] +[ext_resource path="res://graphics/hud/hud.png" type="Texture" id=3] +[ext_resource path="res://graphics/hud/deaths_head.png" type="Texture" id=4] +[ext_resource path="res://graphics/hud/gold_counter.png" type="Texture" id=5] +[ext_resource path="res://objects/hud/hud_boss.gd" type="Script" id=6] +[ext_resource path="res://graphics/hud/key_counter.png" type="Texture" id=7] +[ext_resource path="res://ui/2ndpuberty_outline.tres" type="Material" id=8] +[ext_resource path="res://shaders/1px_border.gdshader" type="Shader" id=9] +[ext_resource path="res://ui/theme.tres" type="Theme" id=10] +[ext_resource path="res://graphics/hud/oxygen.png" type="Texture" id=11] +[ext_resource path="res://graphics/hud/oxygen_meter.png" type="Texture" id=12] + +[sub_resource type="ShaderMaterial" id=1] + +[sub_resource type="ShaderMaterial" id=2] + +[sub_resource type="ShaderMaterial" id=3] +shader = ExtResource( 9 ) +shader_param/border_color = Color( 0.219608, 0.219608, 0.219608, 1 ) +shader_param/border_corners = true + +[node name="BossHUD" type="CanvasLayer" groups=["hud"]] +layer = 100 +script = ExtResource( 6 ) +bonus_color = Color( 0.478431, 1, 0.47451, 1 ) + +[node name="Back" type="Sprite" parent="."] +position = Vector2( 128, 96 ) +texture = ExtResource( 3 ) + +[node name="GoldCounter" type="Label" parent="."] +modulate = Color( 0.690196, 0.690196, 0.690196, 1 ) +margin_left = 12.0 +margin_top = 1.0 +margin_right = 26.0 +margin_bottom = 11.0 +theme = ExtResource( 10 ) +text = "--" + +[node name="ShardCounter" type="Label" parent="."] +modulate = Color( 0.690196, 0.690196, 0.690196, 1 ) +margin_left = 41.0 +margin_top = 1.0 +margin_right = 48.0 +margin_bottom = 11.0 +theme = ExtResource( 10 ) +text = "-" + +[node name="Gold" type="Sprite" parent="."] +visible = false +position = Vector2( 8, 6 ) +texture = ExtResource( 5 ) + +[node name="Key" type="Sprite" parent="."] +position = Vector2( 9, 6 ) +texture = ExtResource( 7 ) + +[node name="RedStar" type="Sprite" parent="."] +visible = false +material = SubResource( 1 ) +position = Vector2( 83, 6 ) +texture = ExtResource( 1 ) +region_enabled = true +region_rect = Rect2( 0, 0, 8, 8 ) + +[node name="YellowStar" type="Sprite" parent="."] +visible = false +material = SubResource( 2 ) +position = Vector2( 93, 6 ) +texture = ExtResource( 1 ) +region_enabled = true +region_rect = Rect2( 8, 0, 8, 8 ) + +[node name="GreenStar" type="Sprite" parent="."] +visible = false +position = Vector2( 103, 6 ) +texture = ExtResource( 1 ) +region_enabled = true +region_rect = Rect2( 16, 0, 8, 8 ) + +[node name="BlueStar" type="Sprite" parent="."] +visible = false +position = Vector2( 113, 6 ) +texture = ExtResource( 1 ) +region_enabled = true +region_rect = Rect2( 24, 0, 8, 8 ) + +[node name="MagentaStar" type="Sprite" parent="."] +visible = false +position = Vector2( 123, 6 ) +texture = ExtResource( 1 ) +region_enabled = true +region_rect = Rect2( 32, 0, 8, 8 ) + +[node name="LivesHead" type="Sprite" parent="."] +visible = false +position = Vector2( 234, 6 ) +texture = ExtResource( 2 ) + +[node name="DeathsHead" type="Sprite" parent="."] +visible = false +position = Vector2( 236, 6 ) +texture = ExtResource( 4 ) + +[node name="ScoreText" type="Label" parent="."] +margin_left = 137.0 +margin_top = 1.0 +margin_right = 221.0 +margin_bottom = 11.0 +theme = ExtResource( 10 ) +text = "SCORE:" + +[node name="ScoreCounter" type="Label" parent="."] +modulate = Color( 0.690196, 0.690196, 0.690196, 1 ) +margin_left = 179.0 +margin_top = 1.0 +margin_right = 214.0 +margin_bottom = 11.0 +theme = ExtResource( 10 ) +text = "-----" + +[node name="HighCounter" type="Label" parent="."] +visible = false +margin_left = 178.0 +margin_top = 179.0 +margin_right = 262.0 +margin_bottom = 199.0 +theme = ExtResource( 10 ) +text = "High:000000" + +[node name="LivesCounter" type="Label" parent="."] +modulate = Color( 0.478431, 1, 0.47451, 1 ) +margin_left = 240.0 +margin_top = 1.0 +margin_right = 247.0 +margin_bottom = 11.0 +theme = ExtResource( 10 ) +text = "2" + +[node name="ArrowCounter" type="Label" parent="."] +margin_left = 61.0 +margin_top = 1.0 +margin_right = 68.0 +margin_bottom = 11.0 +theme = ExtResource( 10 ) +text = "0" + +[node name="TimeCounter" type="Label" parent="."] +modulate = Color( 0.478431, 1, 0.47451, 1 ) +margin_left = 1.0 +margin_top = 181.0 +margin_right = 50.0 +margin_bottom = 191.0 +theme = ExtResource( 10 ) +text = "00:00:00" + +[node name="Music" type="Label" parent="."] +material = ExtResource( 8 ) +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_top = -10.0 +margin_right = 42.0 +theme = ExtResource( 10 ) +text = "♫Music" +align = 2 + +[node name="ShardTitle" type="Label" parent="."] +material = SubResource( 3 ) +margin_left = 256.0 +margin_top = 182.0 +margin_right = 333.0 +margin_bottom = 192.0 +theme = ExtResource( 10 ) +text = "§time bonus" +align = 2 + +[node name="Oxygen" type="Sprite" parent="."] +visible = false +position = Vector2( 16, 18 ) +texture = ExtResource( 11 ) + +[node name="OxygenMeter" type="Sprite" parent="Oxygen"] +position = Vector2( -2, -1 ) +rotation = 3.14159 +scale = Vector2( 15, 1 ) +texture = ExtResource( 12 ) +flip_v = true