Author Topic: Wordle clone  (Read 1373 times)

0 Members and 1 Guest are viewing this topic.

Offline SquirrelMonkey

  • Newbie
  • Posts: 29
  • Youtuber and GIPHY artist
    • Joluijten.com
Wordle clone
« on: March 05, 2022, 12:49:24 pm »
I am working on Weirdle, a Weird Paul themed Wordle clone in QuickBASIC.
The part of the program where you have to enter words is very slow. I wish I could use LINE INPUT, but with a limited amount of characters. Is that possible?

weirdle_005.png
   

Embedded in the browser: https://archive.org/details/weirdle_20220305_0655

Files: https://github.com/joluijten/Weirdle

Marked as best answer by SquirrelMonkey on March 05, 2022, 02:02:32 pm

Offline Dav

  • Forum Resident
  • Posts: 792
Re: Wordle clone
« Reply #1 on: March 05, 2022, 01:21:13 pm »
Sounds interesting.

I don't think LINE INPUT accepts a given input limit, but I made a restricted input routine function that you can freely have/use/abuse.

- Dav

Code: QB64: [Select]
  1. '==========
  2. 'KINPUT.BAS
  3. '==========
  4. 'Restricted keyboard INPUT$ routine.
  5. 'Limit how many characters you can enter.
  6. 'Coded by Dav, JAN/2021
  7.  
  8. a$ = KINPUT$(3, 3, "Enter up to 12 letters: ", 12)
  9.  
  10. PRINT "You entered: "; a$
  11.  
  12.  
  13. FUNCTION KINPUT$ (y, x, text$, limitnum)
  14.  
  15.     LOCATE y, x: PRINT text$;
  16.  
  17.     entry$ = ""
  18.     y = CSRLIN: x = POS(1)
  19.  
  20.     DO
  21.         a$ = INPUT$(1)
  22.  
  23.         IF a$ = CHR$(13) THEN 'enter returns entry
  24.             KINPUT$ = entry$: EXIT FUNCTION
  25.         END IF
  26.  
  27.         IF a$ = CHR$(27) THEN 'ESC bails out
  28.             KINPUT$ = "": EXIT FUNCTION
  29.         END IF
  30.  
  31.         IF a$ = CHR$(8) THEN 'Backspace goes back a space
  32.             IF LEN(entry$) > 0 THEN
  33.                 entry$ = MID$(entry$, 1, LEN(entry$) - 1)
  34.             END IF
  35.         ELSE
  36.             'add letter entered, if not over limitnum
  37.             IF LEN(entry$) < limitnum THEN
  38.                 entry$ = entry$ + a$
  39.             END IF
  40.         END IF
  41.  
  42.         LOCATE y, x: PRINT SPACE$(limitnum);
  43.         LOCATE y, x: PRINT entry$;
  44.  
  45.     LOOP
  46.  
  47.  


Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
Re: Wordle clone
« Reply #2 on: March 05, 2022, 04:10:42 pm »
That IS Weird Paul! Love him so much. Nice work m8.
You're not done when it works, you're done when it's right.

Offline SquirrelMonkey

  • Newbie
  • Posts: 29
  • Youtuber and GIPHY artist
    • Joluijten.com
Re: Wordle clone
« Reply #3 on: March 05, 2022, 05:13:22 pm »
Sounds interesting.

I don't think LINE INPUT accepts a given input limit, but I made a restricted input routine function that you can freely have/use/abuse.

- Dav

Code: QB64: [Select]
  1. '==========
  2. 'KINPUT.BAS
  3. '==========
  4. 'Restricted keyboard INPUT$ routine.
  5. 'Limit how many characters you can enter.
  6. 'Coded by Dav, JAN/2021
  7.  
  8. a$ = KINPUT$(3, 3, "Enter up to 12 letters: ", 12)
  9.  
  10. PRINT "You entered: "; a$
  11.  
  12.  
  13. FUNCTION KINPUT$ (y, x, text$, limitnum)
  14.  
  15.     LOCATE y, x: PRINT text$;
  16.  
  17.     entry$ = ""
  18.     y = CSRLIN: x = POS(1)
  19.  
  20.     DO
  21.         a$ = INPUT$(1)
  22.  
  23.         IF a$ = CHR$(13) THEN 'enter returns entry
  24.             KINPUT$ = entry$: EXIT FUNCTION
  25.         END IF
  26.  
  27.         IF a$ = CHR$(27) THEN 'ESC bails out
  28.             KINPUT$ = "": EXIT FUNCTION
  29.         END IF
  30.  
  31.         IF a$ = CHR$(8) THEN 'Backspace goes back a space
  32.             IF LEN(entry$) > 0 THEN
  33.                 entry$ = MID$(entry$, 1, LEN(entry$) - 1)
  34.             END IF
  35.         ELSE
  36.             'add letter entered, if not over limitnum
  37.             IF LEN(entry$) < limitnum THEN
  38.                 entry$ = entry$ + a$
  39.             END IF
  40.         END IF
  41.  
  42.         LOCATE y, x: PRINT SPACE$(limitnum);
  43.         LOCATE y, x: PRINT entry$;
  44.  
  45.     LOOP
  46.  
  47.  

Thank you! Going to try this code.

Offline SquirrelMonkey

  • Newbie
  • Posts: 29
  • Youtuber and GIPHY artist
    • Joluijten.com
Re: Wordle clone
« Reply #4 on: March 05, 2022, 05:13:48 pm »
That IS Weird Paul! Love him so much. Nice work m8.

Yes, the one and only. :D

Offline SierraKen

  • Forum Resident
  • Posts: 1454
Re: Wordle clone
« Reply #5 on: March 05, 2022, 09:21:40 pm »
That's pretty cool Dav!
Here is my version of doing pretty much the same thing except using INKEY$. It gives a 15 character limit and then ends. You can add more code if you want to put all the letters into one string.

Code: QB64: [Select]
  1. Dim letter$(15)
  2. Locate 10, 2: Print "->"
  3.     _Limit 20
  4.     a$ = InKey$
  5.     If a$ <> "" Then
  6.         t = t + 1
  7.         letter$(t) = a$
  8.         Locate 10, t + 3: Print letter$(t)
  9.         If t > 14 Then GoTo done:
  10.     End If
  11. done:
  12. Print "Finished."
  13. Input "Press Enter to end."; b$
  14.  


Offline SierraKen

  • Forum Resident
  • Posts: 1454
Re: Wordle clone
« Reply #6 on: March 05, 2022, 09:32:45 pm »
Here is one that puts all the 15 characters together into one string and then displays it again.

Code: QB64: [Select]
  1. Dim letter$(15)
  2. Locate 10, 2: Print "->"
  3.     _Limit 20
  4.     a$ = InKey$
  5.     If a$ <> "" Then
  6.         t = t + 1
  7.         letter$(t) = a$
  8.         Locate 10, t + 3: Print letter$(t)
  9.         If t > 14 Then GoTo done:
  10.     End If
  11. done:
  12. word$ = letter$(1) + letter$(2) + letter$(3) + letter$(4) + letter$(5) + letter$(6) + letter$(7) + letter$(8) + letter$(9) + letter$(10) + letter$(11) + letter$(12) + letter$(13) + letter$(14) + letter$(15)
  13. Locate 12, 1
  14. Print word$
  15. Locate 14, 1
  16. Print "Finished."
  17. Locate 16, 1
  18. Input "Press Enter to end."; b$
  19.  

Offline SquirrelMonkey

  • Newbie
  • Posts: 29
  • Youtuber and GIPHY artist
    • Joluijten.com
Re: Wordle clone
« Reply #7 on: March 07, 2022, 05:36:11 pm »
Your code made my game way faster. Thanks, Dav!
https://archive.org/details/weirdle_20220306