bomb defusal prototype
This commit is contained in:
parent
cef1d348d4
commit
29e48dd5af
5 changed files with 193 additions and 8 deletions
55
games/bomb defusal/bomb_defusal.gd
Normal file
55
games/bomb defusal/bomb_defusal.gd
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
extends Node
|
||||
|
||||
@export var code_length : int = 8
|
||||
|
||||
@export_group("Node References")
|
||||
@export var progress1 : ProgressBar
|
||||
@export var progress2 : ProgressBar
|
||||
@export var prompt : Label
|
||||
|
||||
var numbers_typed : int = 0
|
||||
var current_number : int
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
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:
|
||||
progress1.value = numbers_typed
|
||||
progress2.value = numbers_typed
|
||||
prompt.text = str(current_number)
|
||||
|
||||
#TODO Surely theres a better way
|
||||
if Input.is_action_just_pressed("bomb_0"):
|
||||
enter_number(0)
|
||||
elif Input.is_action_just_pressed("bomb_1"):
|
||||
enter_number(1)
|
||||
elif Input.is_action_just_pressed("bomb_2"):
|
||||
enter_number(2)
|
||||
elif Input.is_action_just_pressed("bomb_3"):
|
||||
enter_number(3)
|
||||
elif Input.is_action_just_pressed("bomb_4"):
|
||||
enter_number(4)
|
||||
elif Input.is_action_just_pressed("bomb_5"):
|
||||
enter_number(5)
|
||||
elif Input.is_action_just_pressed("bomb_6"):
|
||||
enter_number(6)
|
||||
elif Input.is_action_just_pressed("bomb_7"):
|
||||
enter_number(7)
|
||||
elif Input.is_action_just_pressed("bomb_8"):
|
||||
enter_number(8)
|
||||
elif Input.is_action_just_pressed("bomb_9"):
|
||||
enter_number(9)
|
||||
|
||||
func enter_number(number : int):
|
||||
if(number == current_number):
|
||||
numbers_typed += 1
|
||||
pick_new_number()
|
||||
else:
|
||||
#womp womp (lose channel)
|
||||
pass
|
||||
|
||||
func pick_new_number():
|
||||
current_number = randi_range(0,9)
|
||||
1
games/bomb defusal/bomb_defusal.gd.uid
Normal file
1
games/bomb defusal/bomb_defusal.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c7xvq23usjvax
|
||||
70
games/bomb defusal/bomb_defusal.tscn
Normal file
70
games/bomb defusal/bomb_defusal.tscn
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://d0qteaieltywg"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c7xvq23usjvax" path="res://games/bomb defusal/bomb_defusal.gd" id="1_kwp46"]
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_yym1j"]
|
||||
colors = PackedColorArray(0.947327, 0.000737363, 0.000402951, 1, 0, 0, 0, 1)
|
||||
|
||||
[sub_resource type="GradientTexture2D" id="GradientTexture2D_kwp46"]
|
||||
gradient = SubResource("Gradient_yym1j")
|
||||
fill = 1
|
||||
fill_from = Vector2(0.495726, 0.452991)
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_yym1j"]
|
||||
font_size = 226
|
||||
|
||||
[node name="BombDefusal" type="Node" node_paths=PackedStringArray("progress1", "progress2", "prompt")]
|
||||
script = ExtResource("1_kwp46")
|
||||
progress1 = NodePath("MarginContainer/PanelContainer/HBoxContainer/ProgressBar")
|
||||
progress2 = NodePath("MarginContainer/PanelContainer/HBoxContainer/ProgressBar2")
|
||||
prompt = NodePath("MarginContainer/PanelContainer/HBoxContainer/Label")
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="."]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = SubResource("GradientTexture2D_kwp46")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/margin_left = 100
|
||||
theme_override_constants/margin_top = 20
|
||||
theme_override_constants/margin_right = 100
|
||||
theme_override_constants/margin_bottom = 20
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/PanelContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ProgressBar" type="ProgressBar" parent="MarginContainer/PanelContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
max_value = 8.0
|
||||
step = 1.0
|
||||
fill_mode = 3
|
||||
show_percentage = false
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer/PanelContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "8"
|
||||
label_settings = SubResource("LabelSettings_yym1j")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="ProgressBar2" type="ProgressBar" parent="MarginContainer/PanelContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
max_value = 8.0
|
||||
step = 1.0
|
||||
fill_mode = 3
|
||||
show_percentage = false
|
||||
Loading…
Add table
Add a link
Reference in a new issue