initial commit

This commit is contained in:
Dan
2022-08-13 21:03:56 -04:00
commit 7cc95eac12
21 changed files with 853 additions and 0 deletions

1
.import/.gdignore Normal file
View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,3 @@
source_md5="47313fa4c47a9963fddd764e1ec6e4a8"
dest_md5="26ea799ea0a3da9e753b3ebe822e0570"

Binary file not shown.

BIN
Fonts/Xolonium-Regular.ttf Normal file

Binary file not shown.

78
Input.gd Normal file
View File

@@ -0,0 +1,78 @@
extends Control
# Called when the node enters the scene tree for the first time.
func _ready():
$char1.editable = true
$char2.editable = false
$char3.editable = false
$char4.editable = false
$char5.editable = false
$char1.grab_focus()
# These make sure the text entered is a letter, and locks the field if it is.
func _on_char1_text_changed(new_text):
var regex = RegEx.new()
regex.compile("[a-zA-Z]")
if regex.search(new_text):
$char1.editable = false
$char2.grab_focus()
$char2.editable = true
elif new_text == "":
pass
else:
print("bad")
func _on_char2_text_changed(new_text):
var regex = RegEx.new()
regex.compile("[a-zA-Z]")
if regex.search(new_text):
$char2.editable = false
$char3.grab_focus()
$char3.editable = true
elif new_text == "":
pass
else:
print("bad")
func _on_char3_text_changed(new_text):
var regex = RegEx.new()
regex.compile("[a-zA-Z]")
if regex.search(new_text):
$char3.editable = false
$char4.grab_focus()
$char4.editable = true
elif new_text == "":
pass
else:
print("bad")
func _on_char4_text_changed(new_text):
var regex = RegEx.new()
regex.compile("[a-zA-Z]")
if regex.search(new_text):
$char4.editable = false
$char5.grab_focus()
$char5.editable = true
elif new_text == "":
pass
else:
print("bad")
func _on_char5_text_changed(new_text):
var regex = RegEx.new()
regex.compile("[a-zA-Z]")
if regex.search(new_text):
$char5.editable = false
elif new_text == "":
pass
else:
print("bad")

60
Input.tscn Normal file
View File

@@ -0,0 +1,60 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://Input.gd" type="Script" id=1]
[ext_resource path="res://Theme.tres" type="Theme" id=2]
[node name="Control" type="Control"]
margin_right = 40.0
margin_bottom = 40.0
script = ExtResource( 1 )
[node name="char1" type="LineEdit" parent="."]
margin_right = 72.0
margin_bottom = 25.0
theme = ExtResource( 2 )
align = 1
max_length = 1
editable = false
[node name="char2" type="LineEdit" parent="."]
margin_left = 79.0
margin_right = 155.0
margin_bottom = 29.0
theme = ExtResource( 2 )
align = 1
max_length = 1
editable = false
[node name="char3" type="LineEdit" parent="."]
margin_left = 159.0
margin_right = 235.0
margin_bottom = 29.0
theme = ExtResource( 2 )
align = 1
max_length = 1
editable = false
[node name="char4" type="LineEdit" parent="."]
margin_left = 241.0
margin_right = 317.0
margin_bottom = 29.0
theme = ExtResource( 2 )
align = 1
max_length = 1
editable = false
[node name="char5" type="LineEdit" parent="."]
margin_left = 322.0
margin_top = -1.0
margin_right = 398.0
margin_bottom = 28.0
theme = ExtResource( 2 )
align = 1
max_length = 1
editable = false
[connection signal="text_changed" from="char1" to="." method="_on_char1_text_changed"]
[connection signal="text_changed" from="char2" to="." method="_on_char2_text_changed"]
[connection signal="text_changed" from="char3" to="." method="_on_char3_text_changed"]
[connection signal="text_changed" from="char4" to="." method="_on_char4_text_changed"]
[connection signal="text_changed" from="char5" to="." method="_on_char5_text_changed"]

36
Keyboard.gd Normal file
View File

@@ -0,0 +1,36 @@
extends Control
#onready var tryNum = get_node("../Main.tryNum")
var tryNum = 1
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func tryCheck():
var try
if tryNum == 1:
try = get_node("Try1")
elif tryNum == 2:
try = get_node("Try2")
elif tryNum == 3:
try = get_node("Try3")
elif tryNum == 4:
try = get_node("Try4")
elif tryNum == 5:
try = get_node("Try5")
else:
pass
return try
func _on_A_pressed():
pass # Replace with function body.

200
Keyboard.tscn Normal file
View File

@@ -0,0 +1,200 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://Keyboard.gd" type="Script" id=1]
[sub_resource type="InputEventKey" id=1]
physical_scancode = 65
[sub_resource type="ShortCut" id=2]
shortcut = SubResource( 1 )
[node name="Keyboard" type="Control"]
margin_right = 40.0
margin_bottom = 40.0
script = ExtResource( 1 )
[node name="A" type="Button" parent="."]
margin_left = 28.0
margin_top = 59.0
margin_right = 49.0
margin_bottom = 79.0
shortcut = SubResource( 2 )
text = "A"
[node name="B" type="Button" parent="."]
margin_left = 206.0
margin_top = 91.0
margin_right = 227.0
margin_bottom = 111.0
text = "B"
[node name="C" type="Button" parent="."]
margin_left = 123.0
margin_top = 93.0
margin_right = 144.0
margin_bottom = 113.0
shortcut = SubResource( 2 )
text = "C"
[node name="D" type="Button" parent="."]
margin_left = 95.0
margin_top = 55.0
margin_right = 117.0
margin_bottom = 75.0
text = "D"
[node name="E" type="Button" parent="."]
margin_left = 99.0
margin_top = 9.0
margin_right = 118.0
margin_bottom = 29.0
text = "E"
[node name="F" type="Button" parent="."]
margin_left = 128.0
margin_top = 53.0
margin_right = 149.0
margin_bottom = 73.0
text = "F"
[node name="G" type="Button" parent="."]
margin_left = 158.0
margin_top = 54.0
margin_right = 180.0
margin_bottom = 74.0
text = "G"
[node name="I" type="Button" parent="."]
margin_left = 273.0
margin_top = 18.0
margin_right = 290.0
margin_bottom = 38.0
text = "I"
[node name="J" type="Button" parent="."]
margin_left = 229.0
margin_top = 54.0
margin_right = 249.0
margin_bottom = 74.0
text = "J"
[node name="K" type="Button" parent="."]
margin_left = 260.0
margin_top = 52.0
margin_right = 280.0
margin_bottom = 72.0
text = "K"
[node name="H" type="Button" parent="."]
margin_left = 191.0
margin_top = 55.0
margin_right = 213.0
margin_bottom = 75.0
text = "H"
[node name="L" type="Button" parent="."]
margin_left = 297.0
margin_top = 59.0
margin_right = 318.0
margin_bottom = 79.0
shortcut = SubResource( 2 )
text = "L"
[node name="M" type="Button" parent="."]
margin_left = 272.0
margin_top = 93.0
margin_right = 296.0
margin_bottom = 113.0
text = "M"
[node name="N" type="Button" parent="."]
margin_left = 238.0
margin_top = 90.0
margin_right = 260.0
margin_bottom = 110.0
shortcut = SubResource( 2 )
text = "N"
[node name="O" type="Button" parent="."]
margin_left = 301.0
margin_top = 17.0
margin_right = 324.0
margin_bottom = 37.0
text = "O"
[node name="P" type="Button" parent="."]
margin_left = 340.0
margin_top = 14.0
margin_right = 360.0
margin_bottom = 34.0
text = "P"
[node name="Q" type="Button" parent="."]
margin_left = 21.0
margin_top = 10.0
margin_right = 44.0
margin_bottom = 30.0
text = "Q"
[node name="R" type="Button" parent="."]
margin_left = 132.0
margin_top = 12.0
margin_right = 152.0
margin_bottom = 32.0
text = "R"
[node name="S" type="Button" parent="."]
margin_left = 59.0
margin_top = 55.0
margin_right = 81.0
margin_bottom = 75.0
text = "S"
[node name="T" type="Button" parent="."]
margin_left = 168.0
margin_top = 14.0
margin_right = 187.0
margin_bottom = 34.0
text = "T"
[node name="U" type="Button" parent="."]
margin_left = 238.0
margin_top = 16.0
margin_right = 260.0
margin_bottom = 36.0
text = "U"
[node name="V" type="Button" parent="."]
margin_left = 164.0
margin_top = 90.0
margin_right = 184.0
margin_bottom = 110.0
text = "V"
[node name="W" type="Button" parent="."]
margin_left = 63.0
margin_top = 9.0
margin_right = 88.0
margin_bottom = 29.0
text = "W"
[node name="X" type="Button" parent="."]
margin_left = 88.0
margin_top = 91.0
margin_right = 110.0
margin_bottom = 111.0
text = "X"
[node name="Y" type="Button" parent="."]
margin_left = 204.0
margin_top = 14.0
margin_right = 223.0
margin_bottom = 34.0
text = "Y"
[node name="Z" type="Button" parent="."]
margin_left = 51.0
margin_top = 91.0
margin_right = 71.0
margin_bottom = 111.0
text = "Z"

160
Main.gd Normal file
View File

@@ -0,0 +1,160 @@
extends Control
var tryNum = 1
var playing = true
var todaysWord = ""
var validWords = [""]
func _ready():
$Try1._ready()
$Message.hide()
loadFiles()
# sets the try attempt node path and returns it
func tryCheck():
var try
if tryNum == 1:
try = get_node("Try1")
elif tryNum == 2:
try = get_node("Try2")
elif tryNum == 3:
try = get_node("Try3")
elif tryNum == 4:
try = get_node("Try4")
elif tryNum == 5:
try = get_node("Try5")
elif tryNum == 6:
try = get_node("Try6")
else:
pass
return try
# deletes the last character and makes the field editable.
func _on_Delete_pressed():
var try = tryCheck()
var check = try.get_node("char1").get_text() + try.get_node("char2").get_text() + try.get_node("char3").get_text() + try.get_node("char4").get_text() + try.get_node("char5").get_text()
var letterNumber = check.length()
if playing == true:
if letterNumber == 1:
try.get_node("char1").clear()
try.get_node("char1").editable = true
try.get_node("char1").grab_focus()
elif letterNumber == 2:
try.get_node("char2").clear()
try.get_node("char2").editable = true
try.get_node("char2").grab_focus()
elif letterNumber == 3:
try.get_node("char3").clear()
try.get_node("char3").editable = true
try.get_node("char3").grab_focus()
elif letterNumber == 4:
try.get_node("char4").clear()
try.get_node("char4").editable = true
try.get_node("char4").grab_focus()
elif letterNumber == 5:
try.get_node("char5").clear()
try.get_node("char5").editable = true
try.get_node("char5").grab_focus()
elif letterNumber < 1:
try.get_node("char1").grab_focus()
# The submit button grabs all the fields. Makes sure it's 5 characters long. Increases the try number. Loops back to the
# input loop. If pressed on the 5th try the game is over and stops the using from deleteing anything.
func _on_Submit_pressed():
var try = tryCheck()
var setWord = todaysWord
var check = try.get_node("char1").get_text() + try.get_node("char2").get_text() + try.get_node("char3").get_text() + try.get_node("char4").get_text() + try.get_node("char5").get_text()
#print(setWord)
if check.length() == 5:
if check.to_lower() in validWords || check.to_upper() == "ASDFA":
if tryNum < 6:
if wordCheck(setWord.to_upper(), check.to_upper()) == true:
playing = false
show_message("You Win")
print("you win")
else:
$Message.hide()
tryNum += 1
try = tryCheck()
try._ready()
elif tryNum == 6:
if wordCheck(setWord.to_upper(), check.to_upper()) == true:
print("you win")
show_message("You win")
playing = false
else:
playing = false
show_message(todaysWord)
else:
show_message("not a valid word")
print("Not a valid word")
else:
print("Must be 5 words long")
show_message("Must be 5 letters long")
func wordCheck(setWord, userWord):
var outcome = false
var try = tryCheck()
#try.get_node("char1").get_text()
#print(validWords)
# This block sets the background color overrides
# Green Box
var green = $Try1/char1.get_stylebox("read_only").duplicate()
green.bg_color = Color8(0, 225, 0)
# Yellow Box
var yellow = $Try1/char1.get_stylebox("read_only").duplicate()
yellow.bg_color = Color8(255, 255, 0)
# Grey
var grey = $Try1/char1.get_stylebox("read_only").duplicate()
grey.bg_color = Color8(98, 98, 98,50)
var x = 0
# loop through each letter in the user submited word. If the placement matches the set word turn it green
# if it doesn't match but is in the word set it yellow. If it isn't in the word set it grey.
for each in userWord:
if each == setWord[x]:
#print(each)
var nodeSet = "char"+str(x+1)
try.get_node(nodeSet).add_stylebox_override("read_only", green)
$Keyboard.get_node(each).add_stylebox_override("normal", green)
elif each in setWord:
var nodeSet = "char"+str(x+1)
if try.get_node(nodeSet).has_stylebox_override("green") != true:
#print("already green")
try.get_node(nodeSet).add_stylebox_override("read_only", yellow)
$Keyboard.get_node(each).add_stylebox_override("normal", yellow)
else:
var nodeSet = "char"+str(x+1)
try.get_node(nodeSet).add_stylebox_override("read_only", grey)
$Keyboard.get_node(each).add_stylebox_override("normal", grey)
x+=1
if userWord == setWord:
outcome = true
return outcome
func show_message(text):
$Message.text = text
$Message.show()
$MessageTimer.start()
func loadFiles():
var file = File.new()
file.open("res://config.game", file.READ)
var data = file.get_var()
var today = data["today"]
var rng = RandomNumberGenerator.new()
rng.randomize()
today = rng.randi_range(0, 300)
todaysWord = data["wordList"][today]
validWords = data["validWords"]+data["wordList"]

117
Main.tscn Normal file
View File

@@ -0,0 +1,117 @@
[gd_scene load_steps=10 format=2]
[ext_resource path="res://Main.gd" type="Script" id=1]
[ext_resource path="res://Input.tscn" type="PackedScene" id=2]
[ext_resource path="res://Keyboard.tscn" type="PackedScene" id=3]
[sub_resource type="Theme" id=3]
LineEdit/colors/background_color = Color( 0.698039, 0.141176, 0.141176, 1 )
TextEdit/colors/background_color = Color( 0.498039, 0.72549, 0.0941176, 0.788235 )
[sub_resource type="InputEventKey" id=8]
pressed = true
scancode = 16777221
[sub_resource type="ShortCut" id=2]
shortcut = SubResource( 8 )
[sub_resource type="InputEventAction" id=6]
action = "delete"
[sub_resource type="ShortCut" id=7]
shortcut = SubResource( 6 )
[sub_resource type="Theme" id=4]
Label/colors/font_color = Color( 0, 0, 0, 1 )
[node name="Main" type="Control"]
anchor_right = 0.395
anchor_bottom = 0.43
margin_right = -0.480011
rect_pivot_offset = Vector2( 328, 264 )
script = ExtResource( 1 )
[node name="ColorRect" type="ColorRect" parent="."]
margin_left = -5.0
margin_top = -5.0
margin_right = 418.0
margin_bottom = 508.0
[node name="Submit" type="Button" parent="."]
margin_left = 135.0
margin_top = 460.0
margin_right = 192.0
margin_bottom = 480.0
focus_mode = 0
theme = SubResource( 3 )
enabled_focus_mode = 0
shortcut = SubResource( 2 )
text = "Submit"
[node name="Delete" type="Button" parent="."]
margin_left = 235.0
margin_top = 461.0
margin_right = 290.0
margin_bottom = 481.0
focus_mode = 0
enabled_focus_mode = 0
shortcut = SubResource( 7 )
text = "Delete"
[node name="Try1" parent="." instance=ExtResource( 2 )]
margin_left = 7.0
margin_top = 14.0
margin_right = 407.0
margin_bottom = 47.0
[node name="Try2" parent="." instance=ExtResource( 2 )]
margin_left = 7.0
margin_top = 54.0
margin_right = 407.0
margin_bottom = 85.0
[node name="Try3" parent="." instance=ExtResource( 2 )]
margin_left = 7.0
margin_top = 96.0
margin_right = 406.0
margin_bottom = 129.0
[node name="Try4" parent="." instance=ExtResource( 2 )]
anchor_bottom = 0.155
margin_left = 7.0
margin_top = 139.0
margin_right = 408.0
margin_bottom = 150.938
[node name="Try5" parent="." instance=ExtResource( 2 )]
margin_left = 7.0
margin_top = 180.0
margin_right = 408.0
margin_bottom = 212.0
[node name="Try6" parent="." instance=ExtResource( 2 )]
margin_left = 6.0
margin_top = 219.0
margin_right = 415.0
margin_bottom = 251.0
[node name="Keyboard" parent="." instance=ExtResource( 3 )]
margin_left = 34.0
margin_top = 327.0
margin_right = 403.0
margin_bottom = 454.0
[node name="Message" type="Label" parent="."]
margin_left = 9.0
margin_top = 260.0
margin_right = 402.0
margin_bottom = 321.0
theme = SubResource( 4 )
text = "You Win"
align = 1
[node name="MessageTimer" type="Timer" parent="."]
wait_time = 5.0
[connection signal="pressed" from="Submit" to="." method="_on_Submit_pressed"]
[connection signal="pressed" from="Delete" to="." method="_on_Delete_pressed"]

26
Theme.tres Normal file
View File

@@ -0,0 +1,26 @@
[gd_resource type="Theme" load_steps=4 format=2]
[ext_resource path="res://Fonts/Xolonium-Regular.ttf" type="DynamicFontData" id=1]
[sub_resource type="DynamicFont" id=4]
size = 20
font_data = ExtResource( 1 )
[sub_resource type="StyleBoxFlat" id=5]
bg_color = Color( 0.6, 0.6, 0.6, 0 )
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
corner_radius_top_left = 4
corner_radius_top_right = 4
corner_radius_bottom_right = 4
corner_radius_bottom_left = 4
[resource]
LineEdit/colors/font_color = Color( 0, 0, 0, 1 )
LineEdit/colors/font_color_uneditable = Color( 0, 0, 0, 1 )
LineEdit/fonts/font = SubResource( 4 )
LineEdit/styles/focus = SubResource( 5 )
LineEdit/styles/normal = SubResource( 5 )
LineEdit/styles/read_only = SubResource( 5 )

BIN
config.game Normal file

Binary file not shown.

5
config.json Normal file

File diff suppressed because one or more lines are too long

7
default_env.tres Normal file
View File

@@ -0,0 +1,7 @@
[gd_resource type="Environment" load_steps=2 format=2]
[sub_resource type="ProceduralSky" id=1]
[resource]
background_mode = 2
background_sky = SubResource( 1 )

41
export_presets.cfg Normal file
View File

@@ -0,0 +1,41 @@
[preset.0]
name="Windows Desktop"
platform="Windows Desktop"
runnable=true
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="../Exports/wordle.exe"
script_export_mode=1
script_encryption_key=""
[preset.0.options]
custom_template/debug=""
custom_template/release=""
binary_format/64_bits=true
binary_format/embed_pck=true
texture_format/bptc=false
texture_format/s3tc=true
texture_format/etc=false
texture_format/etc2=false
texture_format/no_bptc_fallbacks=true
codesign/enable=false
codesign/identity_type=0
codesign/identity=""
codesign/password=""
codesign/timestamp=true
codesign/timestamp_server_url=""
codesign/digest_algorithm=1
codesign/description=""
codesign/custom_options=PoolStringArray( )
application/icon=""
application/file_version=""
application/product_version=""
application/company_name=""
application/product_name=""
application/file_description=""
application/copyright=""
application/trademarks=""

3
globals.gd Normal file
View File

@@ -0,0 +1,3 @@
extends Node
var tryNumb = 1

BIN
icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

35
icon.png.import Normal file
View File

@@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

52
project.godot Normal file
View File

@@ -0,0 +1,52 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
[application]
config/name="Wordle"
run/main_scene="res://Main.tscn"
config/icon="res://icon.png"
[autoload]
Globals="*res://globals.gd"
[display]
window/size/width=423
window/size/height=513
[input]
ui_accept={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777222,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
]
}
delete={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777220,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
}
submit={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
}
[physics]
common/enable_pause_aware_picking=true
[rendering]
environment/default_environment="res://default_env.tres"

21
setup.gd Normal file

File diff suppressed because one or more lines are too long

8
setup.tscn Normal file
View File

@@ -0,0 +1,8 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://setup.gd" type="Script" id=1]
[node name="Control" type="Control"]
margin_right = 40.0
margin_bottom = 40.0
script = ExtResource( 1 )