From 119f7f9625b3cac8a1eae35fdeda42196eac9587 Mon Sep 17 00:00:00 2001 From: Tabby <41929769+tabby-cat-nya@users.noreply.github.com> Date: Mon, 12 May 2025 17:10:37 +1000 Subject: [PATCH] unlimited games --- games/bomb defusal/bomb_defusal.gd | 5 +- games/crafting/crafting.gd | 76 +++++++++++++++++++++++ games/crafting/crafting.gd.uid | 1 + games/crafting/crafting.tscn | 49 +++++++++++++++ games/crafting/pixel.gd | 28 +++++++++ games/crafting/pixel.gd.uid | 1 + games/crafting/pixel.tscn | 24 ++++++++ games/reaction/reaction.gd | 31 ++++++++++ games/reaction/reaction.gd.uid | 1 + games/reaction/reaction.tscn | 99 ++++++++++++++++++++++++++++++ project.godot | 45 ++++++++++++++ 11 files changed, 359 insertions(+), 1 deletion(-) create mode 100644 games/crafting/crafting.gd create mode 100644 games/crafting/crafting.gd.uid create mode 100644 games/crafting/crafting.tscn create mode 100644 games/crafting/pixel.gd create mode 100644 games/crafting/pixel.gd.uid create mode 100644 games/crafting/pixel.tscn create mode 100644 games/reaction/reaction.gd create mode 100644 games/reaction/reaction.gd.uid create mode 100644 games/reaction/reaction.tscn diff --git a/games/bomb defusal/bomb_defusal.gd b/games/bomb defusal/bomb_defusal.gd index 228980a..e26e5ac 100644 --- a/games/bomb defusal/bomb_defusal.gd +++ b/games/bomb defusal/bomb_defusal.gd @@ -52,4 +52,7 @@ func enter_number(number : int): pass func pick_new_number(): - current_number = randi_range(0,9) + var new_number = current_number + while(new_number == current_number): + new_number = randi_range(0,9) + current_number = new_number diff --git a/games/crafting/crafting.gd b/games/crafting/crafting.gd new file mode 100644 index 0000000..d9ff2c9 --- /dev/null +++ b/games/crafting/crafting.gd @@ -0,0 +1,76 @@ +extends Node +@export var keys : Array[String] +@export var time_limit : float = 25 + +@export_group("Node References") +@export var pixel_grid : GridContainer +@export var timer_progress : ProgressBar +var pixels : Array[Control] +var current_time : float = 25 + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + create_pixels() + current_time = time_limit + pass # Replace with function body. + +func create_pixels(): + for i in range(25): + var newPixel = load("res://games/crafting/pixel.tscn").instantiate() + var randomKey = randi_range(0,keys.size()-1) + newPixel.key = keys[randomKey] + pixels.append(newPixel) + pixel_grid.add_child(newPixel) + +func enter_letter(letter : String): + var found : bool = false + var options : Array[Control] + for pixel in pixels: + if (pixel.key == letter and !pixel.activated): + found = true + options.append(pixel) + if(found): + var randomPixel : int = randi_range(0, options.size()-1) + options[randomPixel].activate() + else: + for i in range(3): + var randomPixel : int = randi_range(0,pixels.size()-1) + pixels[randomPixel].deactivate() + if count_activated(): + pass + #winner + +func count_activated() -> bool: + var count : int = 0 + for pixel in pixels: + if pixel.activated: + count += 1 + if count == 25: + return true + else: + return false + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + current_time -= delta + timer_progress.value = current_time/time_limit + if current_time <= 0: + pass + #loser + + if Input.is_action_just_pressed("crafting_e"): + enter_letter("E") + elif Input.is_action_just_pressed("crafting_q"): + enter_letter("Q") + elif Input.is_action_just_pressed("crafting_r"): + enter_letter("R") + elif Input.is_action_just_pressed("crafting_t"): + enter_letter("T") + elif Input.is_action_just_pressed("crafting_y"): + enter_letter("Y") + elif Input.is_action_just_pressed("crafting_u"): + enter_letter("U") + elif Input.is_action_just_pressed("crafting_f"): + enter_letter("F") + elif Input.is_action_just_pressed("crafting_m"): + enter_letter("M") diff --git a/games/crafting/crafting.gd.uid b/games/crafting/crafting.gd.uid new file mode 100644 index 0000000..bdeb616 --- /dev/null +++ b/games/crafting/crafting.gd.uid @@ -0,0 +1 @@ +uid://b4ps00o1tpuft diff --git a/games/crafting/crafting.tscn b/games/crafting/crafting.tscn new file mode 100644 index 0000000..91ddf18 --- /dev/null +++ b/games/crafting/crafting.tscn @@ -0,0 +1,49 @@ +[gd_scene load_steps=5 format=3 uid="uid://drk2fwkv816qv"] + +[ext_resource type="Script" uid="uid://b4ps00o1tpuft" path="res://games/crafting/crafting.gd" id="1_51qhm"] + +[sub_resource type="Gradient" id="Gradient_51qhm"] +colors = PackedColorArray(0.774014, 0.581042, 1, 1, 1, 0.595754, 0.986362, 1) + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_8e2i7"] +noise_type = 0 +fractal_type = 3 + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_26tlc"] +width = 360 +height = 180 +color_ramp = SubResource("Gradient_51qhm") +noise = SubResource("FastNoiseLite_8e2i7") + +[node name="Crafting" type="Node" node_paths=PackedStringArray("pixel_grid", "timer_progress")] +script = ExtResource("1_51qhm") +keys = Array[String](["Q", "E", "R", "T", "Y", "U", "F", "M"]) +pixel_grid = NodePath("CenterContainer/VBoxContainer/GridContainer") +timer_progress = NodePath("CenterContainer/VBoxContainer/Timer") + +[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("NoiseTexture2D_26tlc") + +[node name="CenterContainer" type="CenterContainer" parent="."] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"] +layout_mode = 2 + +[node name="GridContainer" type="GridContainer" parent="CenterContainer/VBoxContainer"] +layout_mode = 2 +columns = 5 + +[node name="Timer" type="ProgressBar" parent="CenterContainer/VBoxContainer"] +layout_mode = 2 +max_value = 1.0 +step = 0.0 diff --git a/games/crafting/pixel.gd b/games/crafting/pixel.gd new file mode 100644 index 0000000..742c4fd --- /dev/null +++ b/games/crafting/pixel.gd @@ -0,0 +1,28 @@ +extends ColorRect + + +@export var end_color : Color = Color.PURPLE +@export_group("Node References") +@export var key_label : Label +var key : String = "Q" +var activated : bool = false + +# 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: + key_label.visible = !activated + key_label.text = key + if(activated): + color = end_color + else: + color = Color.WHITE + +func activate(): + activated = true + +func deactivate(): + activated = false diff --git a/games/crafting/pixel.gd.uid b/games/crafting/pixel.gd.uid new file mode 100644 index 0000000..51b9a59 --- /dev/null +++ b/games/crafting/pixel.gd.uid @@ -0,0 +1 @@ +uid://bs11jp8pmu8uv diff --git a/games/crafting/pixel.tscn b/games/crafting/pixel.tscn new file mode 100644 index 0000000..429af1a --- /dev/null +++ b/games/crafting/pixel.tscn @@ -0,0 +1,24 @@ +[gd_scene load_steps=3 format=3 uid="uid://b7fjw13eg65gh"] + +[ext_resource type="Script" uid="uid://bs11jp8pmu8uv" path="res://games/crafting/pixel.gd" id="1_gwgos"] + +[sub_resource type="LabelSettings" id="LabelSettings_8qltj"] +font_size = 56 +font_color = Color(0, 0, 0, 1) + +[node name="ColorRect" type="ColorRect" node_paths=PackedStringArray("key_label")] +custom_minimum_size = Vector2(60, 60) +script = ExtResource("1_gwgos") +key_label = NodePath("Label") + +[node name="Label" type="Label" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +text = "A" +label_settings = SubResource("LabelSettings_8qltj") +horizontal_alignment = 1 +vertical_alignment = 1 diff --git a/games/reaction/reaction.gd b/games/reaction/reaction.gd new file mode 100644 index 0000000..78aa65c --- /dev/null +++ b/games/reaction/reaction.gd @@ -0,0 +1,31 @@ +extends Node + +@export var reaction_window : float = 1 +@export_group("Node References") +@export var prepare_node : Control +@export var press_node : Control +var time_remaining : float + + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + time_remaining = randf_range(5,15) + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + time_remaining -= delta + prepare_node.visible = time_remaining > 0 + press_node.visible = time_remaining <= 0 + if(time_remaining <= 0): + reaction_window -= delta + if(Input.is_action_just_pressed("reaction_press")): + if(time_remaining<=0 and reaction_window > 0): + pass + #winner + else: + pass + #loser + pass diff --git a/games/reaction/reaction.gd.uid b/games/reaction/reaction.gd.uid new file mode 100644 index 0000000..28333f7 --- /dev/null +++ b/games/reaction/reaction.gd.uid @@ -0,0 +1 @@ +uid://cs3ipvky7dk6c diff --git a/games/reaction/reaction.tscn b/games/reaction/reaction.tscn new file mode 100644 index 0000000..95523da --- /dev/null +++ b/games/reaction/reaction.tscn @@ -0,0 +1,99 @@ +[gd_scene load_steps=7 format=3 uid="uid://bcu5svl5gjd4r"] + +[ext_resource type="Script" uid="uid://cs3ipvky7dk6c" path="res://games/reaction/reaction.gd" id="1_fqqjl"] + +[sub_resource type="Gradient" id="Gradient_nlvo0"] +colors = PackedColorArray(0, 0.730016, 0, 1, 0.0627451, 1, 1, 1) + +[sub_resource type="GradientTexture2D" id="GradientTexture2D_fqqjl"] +gradient = SubResource("Gradient_nlvo0") +fill_from = Vector2(0, 1) + +[sub_resource type="LabelSettings" id="LabelSettings_npxhc"] +font_size = 80 + +[sub_resource type="Gradient" id="Gradient_6p5vi"] +colors = PackedColorArray(1, 0, 0.141176, 1, 1, 1, 0, 1) + +[sub_resource type="GradientTexture2D" id="GradientTexture2D_wmmsg"] +gradient = SubResource("Gradient_6p5vi") +fill_to = Vector2(1, 1) + +[node name="Reaction" type="Node"] +script = ExtResource("1_fqqjl") + +[node name="Prepare" type="Control" parent="."] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="TextureRect" type="TextureRect" parent="Prepare"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = SubResource("GradientTexture2D_fqqjl") + +[node name="MarginContainer" type="MarginContainer" parent="Prepare"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 30 +theme_override_constants/margin_right = 30 + +[node name="PanelContainer" type="PanelContainer" parent="Prepare/MarginContainer"] +layout_mode = 2 +size_flags_vertical = 4 + +[node name="Label" type="Label" parent="Prepare/MarginContainer/PanelContainer"] +layout_mode = 2 +text = "Get Ready to press Space" +label_settings = SubResource("LabelSettings_npxhc") +horizontal_alignment = 1 +autowrap_mode = 2 + +[node name="Press" type="Control" parent="."] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="TextureRect" type="TextureRect" parent="Press"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = SubResource("GradientTexture2D_wmmsg") + +[node name="MarginContainer" type="MarginContainer" parent="Press"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 30 +theme_override_constants/margin_right = 30 + +[node name="PanelContainer" type="PanelContainer" parent="Press/MarginContainer"] +layout_mode = 2 +size_flags_vertical = 4 + +[node name="Label" type="Label" parent="Press/MarginContainer/PanelContainer"] +layout_mode = 2 +text = "Press Space Now!!!" +label_settings = SubResource("LabelSettings_npxhc") +horizontal_alignment = 1 +autowrap_mode = 2 diff --git a/project.godot b/project.godot index af12105..790c88e 100644 --- a/project.godot +++ b/project.godot @@ -133,6 +133,51 @@ bomb_9={ , 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":4194447,"key_label":0,"unicode":57,"location":0,"echo":false,"script":null) ] } +reaction_press={ +"deadzone": 0.2, +"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":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null) +] +} +crafting_q={ +"deadzone": 0.2, +"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":81,"key_label":0,"unicode":113,"location":0,"echo":false,"script":null) +] +} +crafting_e={ +"deadzone": 0.2, +"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":69,"key_label":0,"unicode":101,"location":0,"echo":false,"script":null) +] +} +crafting_r={ +"deadzone": 0.2, +"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":82,"key_label":0,"unicode":114,"location":0,"echo":false,"script":null) +] +} +crafting_t={ +"deadzone": 0.2, +"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":84,"key_label":0,"unicode":116,"location":0,"echo":false,"script":null) +] +} +crafting_y={ +"deadzone": 0.2, +"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":89,"key_label":0,"unicode":121,"location":0,"echo":false,"script":null) +] +} +crafting_u={ +"deadzone": 0.2, +"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":85,"key_label":0,"unicode":117,"location":0,"echo":false,"script":null) +] +} +crafting_f={ +"deadzone": 0.2, +"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":70,"key_label":0,"unicode":102,"location":0,"echo":false,"script":null) +] +} +crafting_m={ +"deadzone": 0.2, +"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":77,"key_label":0,"unicode":109,"location":0,"echo":false,"script":null) +] +} [rendering]