hud
This commit is contained in:
@@ -11,7 +11,7 @@ var word_set_array
|
||||
var alphabet = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N",
|
||||
"O","P","Q","R","S","T","U","V","W","X","Y","Z"]
|
||||
var comets = []
|
||||
var comet_speed = 250
|
||||
var comet_speed = 150
|
||||
var active
|
||||
|
||||
# display
|
||||
@@ -20,10 +20,21 @@ var scale_factor_x
|
||||
var scale_factor_y
|
||||
|
||||
# numbers
|
||||
var delay = 1.5
|
||||
var max_delay = 2
|
||||
var delay = max_delay
|
||||
var spawn_timer = 0
|
||||
var max_character_count = 0
|
||||
|
||||
# stats
|
||||
var health = 100
|
||||
var miss_count = 0.0
|
||||
var total_comets = 0.0
|
||||
|
||||
# ui init
|
||||
var hp_label
|
||||
var acc_label
|
||||
var miss_label
|
||||
|
||||
# objects
|
||||
var comet_source = preload("res://scenes/objects/game/comet.tscn")
|
||||
var fade
|
||||
@@ -31,13 +42,11 @@ var pause_menu
|
||||
|
||||
# Runs on start
|
||||
func _ready() -> void:
|
||||
# ready ui
|
||||
viewport_size = get_viewport_rect().size
|
||||
#scale_factor_x = viewport_size.x/1280
|
||||
#scale_factor_y = viewport_size.y/720
|
||||
|
||||
#print($Tux.position)
|
||||
#$Tux.position = Vector2($Tux.position.x * scale_factor_x, $Tux.position.y * scale_factor_y)
|
||||
#print($Tux.position)
|
||||
hp_label = self.get_node("OnTop").get_node("HUD").get_node("Stack").get_node("Health")
|
||||
acc_label = self.get_node("OnTop").get_node("HUD").get_node("Stack").get_node("Accuracy")
|
||||
miss_label = self.get_node("OnTop").get_node("HUD").get_node("Stack").get_node("MissCount")
|
||||
|
||||
active = true
|
||||
|
||||
@@ -73,6 +82,12 @@ func _process(delta: float) -> void:
|
||||
if active:
|
||||
spawn_timer += delta
|
||||
|
||||
hp_label.text = "HP: " + str(health)
|
||||
miss_label.text = "X: " + str(miss_count)
|
||||
if total_comets > 0:
|
||||
var accper = (total_comets - miss_count)/(total_comets)*100
|
||||
acc_label.text = "ACC: " + str(snapped(accper, .02)) + "%"
|
||||
|
||||
if spawn_timer >= delay:
|
||||
spawn_timer = 0
|
||||
spawn_word()
|
||||
@@ -88,6 +103,7 @@ func spawn_word():
|
||||
for char in new_word:
|
||||
if char != " ":
|
||||
var new_commet = comet_source.instantiate()
|
||||
total_comets += 1
|
||||
new_commet.position = Vector2(offset,-128)
|
||||
new_commet.get_node("Sprite").get_node("Label").text = char
|
||||
new_commet.speed = comet_speed
|
||||
@@ -95,7 +111,13 @@ func spawn_word():
|
||||
comets.append(new_commet)
|
||||
offset += dist
|
||||
|
||||
delay = randf_range(0.75,2)
|
||||
delay = randf_range(0.75,max_delay)
|
||||
|
||||
func take_damage():
|
||||
pass
|
||||
|
||||
func game_over():
|
||||
pass
|
||||
|
||||
func _input(event):
|
||||
if event is InputEventKey and event.pressed:
|
||||
@@ -104,7 +126,7 @@ func _input(event):
|
||||
if len(comets) > 0:
|
||||
var comet = comets[0]
|
||||
if event.as_text() == comet.get_node("Sprite").get_node("Label").text:
|
||||
comet.active = false
|
||||
comet.self_active = false
|
||||
var laser = Line2D.new()
|
||||
laser.default_color = Color.RED
|
||||
laser.points = PackedVector2Array([$Tux.position,comet.position])
|
||||
|
||||
@@ -1,20 +1,23 @@
|
||||
[gd_scene format=3 uid="uid://bef8re5x0kmmd"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c7vntfq6dyb2k" path="res://scenes/game/comet_zap.gd" id="1_eyb20"]
|
||||
[ext_resource type="Texture2D" uid="uid://dshpn3ffg3bch" path="res://original data/images/backgrounds/0.jpg" id="2_2j0xl"]
|
||||
[ext_resource type="Texture2D" uid="uid://b0jndopqfkddu" path="res://assets/visual/backgrounds/omori/Battle Backgrounds/battleback_ow_outskirts.png" id="2_2j0xl"]
|
||||
[ext_resource type="AudioStream" uid="uid://b2l55uknctgo6" path="res://assets/audio/music/game/comet_zap/Ranma Nibun-no-ichi Bakuretsu Rantouhen - King's Casino [Qk0v_NIqVPg].mp3" id="2_ije4o"]
|
||||
[ext_resource type="AudioStream" uid="uid://ckr4pf3etle0p" path="res://assets/audio/sfx/SYS_cancel.ogg" id="4_2j0xl"]
|
||||
[ext_resource type="Texture2D" uid="uid://jd2rnhvq6gl6" path="res://original data/images/tux/tux-yes2.png" id="4_yib6v"]
|
||||
[ext_resource type="AudioStream" uid="uid://t6tbvilcrwy8" path="res://assets/audio/sfx/SE_Push.ogg" id="5_62k7v"]
|
||||
[ext_resource type="PackedScene" uid="uid://dm6jp4gjboooc" path="res://scenes/menus/pause/pause.tscn" id="6_cjaft"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_2j0xl"]
|
||||
font_size = 50
|
||||
|
||||
[node name="CometZap" type="Node2D" unique_id=1227404695]
|
||||
script = ExtResource("1_eyb20")
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1005683026]
|
||||
[node name="Background" type="CanvasLayer" parent="." unique_id=1005683026]
|
||||
layer = -1
|
||||
|
||||
[node name="Control" type="Control" parent="CanvasLayer" unique_id=2022519285]
|
||||
[node name="Control" type="Control" parent="Background" unique_id=2022519285]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
@@ -23,7 +26,7 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="CanvasLayer/Control" unique_id=308962101]
|
||||
[node name="TextureRect" type="TextureRect" parent="Background/Control" unique_id=308962101]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
@@ -52,6 +55,45 @@ texture = ExtResource("4_yib6v")
|
||||
|
||||
[node name="OnTop" type="CanvasLayer" parent="." unique_id=828008006]
|
||||
|
||||
[node name="HUD" type="Control" parent="OnTop" unique_id=2042422382]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="Stack" type="BoxContainer" parent="OnTop/HUD" unique_id=1113890134]
|
||||
layout_mode = 1
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -366.0
|
||||
offset_bottom = 215.0
|
||||
grow_horizontal = 0
|
||||
vertical = true
|
||||
|
||||
[node name="Health" type="Label" parent="OnTop/HUD/Stack" unique_id=411589405]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 6
|
||||
text = "HP:"
|
||||
label_settings = SubResource("LabelSettings_2j0xl")
|
||||
|
||||
[node name="Accuracy" type="Label" parent="OnTop/HUD/Stack" unique_id=1592115024]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 6
|
||||
text = "ACC:"
|
||||
label_settings = SubResource("LabelSettings_2j0xl")
|
||||
|
||||
[node name="MissCount" type="Label" parent="OnTop/HUD/Stack" unique_id=1954191478]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 6
|
||||
text = "X:"
|
||||
label_settings = SubResource("LabelSettings_2j0xl")
|
||||
|
||||
[node name="Pause" parent="OnTop" unique_id=1227462733 instance=ExtResource("6_cjaft")]
|
||||
visible = false
|
||||
|
||||
|
||||
Reference in New Issue
Block a user