unlimited games
This commit is contained in:
parent
29e48dd5af
commit
119f7f9625
11 changed files with 359 additions and 1 deletions
76
games/crafting/crafting.gd
Normal file
76
games/crafting/crafting.gd
Normal file
|
|
@ -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")
|
||||
1
games/crafting/crafting.gd.uid
Normal file
1
games/crafting/crafting.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b4ps00o1tpuft
|
||||
49
games/crafting/crafting.tscn
Normal file
49
games/crafting/crafting.tscn
Normal file
|
|
@ -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
|
||||
28
games/crafting/pixel.gd
Normal file
28
games/crafting/pixel.gd
Normal file
|
|
@ -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
|
||||
1
games/crafting/pixel.gd.uid
Normal file
1
games/crafting/pixel.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bs11jp8pmu8uv
|
||||
24
games/crafting/pixel.tscn
Normal file
24
games/crafting/pixel.tscn
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue