Make the keyboard THICC
g: - Thiccen keyboard - Clean up keeb function - Add option to not center the game ui: - Stop screaming
This commit is contained in:
parent
a22248a2a5
commit
dff087128c
27
src/g.py
27
src/g.py
@ -42,7 +42,7 @@ parser.add_argument('--word', metavar="solution", help="force a parti
|
|||||||
parser.add_argument('--classic', action='store_true', help="use the classic Wordle word list")
|
parser.add_argument('--classic', action='store_true', help="use the classic Wordle word list")
|
||||||
parser.add_argument('--nonsense', action='store_true', help="allow nonsensical guesses")
|
parser.add_argument('--nonsense', action='store_true', help="allow nonsensical guesses")
|
||||||
parser.add_argument('--hard', action='store_true', help="enable hard mode (wip)")
|
parser.add_argument('--hard', action='store_true', help="enable hard mode (wip)")
|
||||||
parser.add_argument('--clear', action='store_true', help="clear screen and reset cursor position on start")
|
parser.add_argument('--nocenter', action='store_true', help="disable centering the screen")
|
||||||
# TODO: Implement hard mode properly (more than just a *)
|
# TODO: Implement hard mode properly (more than just a *)
|
||||||
|
|
||||||
# Parse the args
|
# Parse the args
|
||||||
@ -159,35 +159,32 @@ def keeb(x, y):
|
|||||||
def colorify(string):
|
def colorify(string):
|
||||||
s = ""
|
s = ""
|
||||||
for char in string:
|
for char in string:
|
||||||
s += c.c24(colors[letters[letter_num(char)]]) + char + c.RESET
|
s += c.c24(colors[letters[letter_num(char)]]) + " " + char + " " + c.RESET
|
||||||
return s
|
return s
|
||||||
S = ["qwertyuiop","asdfghjkl","zxcvbnm"]
|
S = ["qwertyuiop", "asdfghjkl", "zxcvbnm"+u"\u23CE"]
|
||||||
ui.uprint(x, y, colorify(" " + S[0] + " "))
|
for i in range(len(S)):
|
||||||
ui.uprint(x, y+1, colorify(" " + S[1] + " "))
|
ui.uprint(x-(3*len(S[i])//2)+7, y+i, colorify(S[i]))
|
||||||
ui.uprint(x, y+2, colorify(" " + S[2] + " "))
|
|
||||||
|
|
||||||
|
|
||||||
# intro: Print the intro text
|
# intro: Print the intro text
|
||||||
def intro():
|
def intro():
|
||||||
title = "Wordle {}{}".format(d, "*" if args.hard else "")
|
title = "Wordle {}{}".format(d, "*" if args.hard else "")
|
||||||
spaces = ' '
|
spaces = ' ' * ((14 - len(title)) // 2)
|
||||||
# spaces = ' ' * ((13 - len(title)) // 2)
|
|
||||||
intro = c.RESET # Reset the text printing colors
|
|
||||||
if args.clear:
|
|
||||||
intro += c.clear(False) # Clear the screen
|
|
||||||
intro += ui.m_abs(0,0) # Move the cursor to 0,0 (top left)
|
|
||||||
# [ Wordle 100* ]
|
# [ Wordle 100* ]
|
||||||
intro += spaces + title + "\n"
|
intro = c.RESET + spaces + title
|
||||||
return intro
|
return intro
|
||||||
|
|
||||||
def game():
|
def game():
|
||||||
|
if args.nocenter:
|
||||||
|
x = ui.size[0]//2 - 8
|
||||||
|
else:
|
||||||
x = get_terminal_size().columns//2 - 8
|
x = get_terminal_size().columns//2 - 8
|
||||||
ui.uprint(x, 0, intro())
|
ui.uprint(x, 0, intro())
|
||||||
words = w.Words + w.Answers
|
words = w.Words + w.Answers
|
||||||
guess = 0
|
guess = 0
|
||||||
while guess < max_guesses:
|
while guess < max_guesses:
|
||||||
# lol i should probably use curses
|
# lol i should probably use curses
|
||||||
keeb(x, 10)
|
keeb(x+1, 9)
|
||||||
user_input = ui.uinput(x, len(guesses) + 2, c.clear() + " ").lower()
|
user_input = ui.uinput(x, len(guesses) + 2, c.clear() + " ").lower()
|
||||||
if len(user_input) == 5 and (user_input in words or args.nonsense):
|
if len(user_input) == 5 and (user_input in words or args.nonsense):
|
||||||
# Add guesses to the guessed list, and put the word in boxes
|
# Add guesses to the guessed list, and put the word in boxes
|
||||||
@ -217,5 +214,5 @@ def win(won):
|
|||||||
print(ui.m(0,ui.size[1]+1) + board)
|
print(ui.m(0,ui.size[1]+1) + board)
|
||||||
|
|
||||||
|
|
||||||
ui.init(15,12)
|
ui.init(30,12)
|
||||||
game()
|
game()
|
@ -34,7 +34,7 @@ size = [0,0]
|
|||||||
def init(width, height):
|
def init(width, height):
|
||||||
size[0], size[1] = width, height
|
size[0], size[1] = width, height
|
||||||
print(c.c24(0x00f0d0) + '0123456789ABCDE' + c.RESET)
|
print(c.c24(0x00f0d0) + '0123456789ABCDE' + c.RESET)
|
||||||
print(("A"*width + "\n")*(height-1))
|
print((" "*width + "\n")*(height-1))
|
||||||
print(m(0,-height-1) + ANSI_S, end='')
|
print(m(0,-height-1) + ANSI_S, end='')
|
||||||
clear()
|
clear()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user