Wordathon
A Wordle-style game built with React and Redux. You get six guesses per word, but the game doesn't end after one: keep guessing to build a streak, with three difficulty levels and sound effects.
- JavaScript
- React
- Redux
Overview
Wordathon is a word-guessing game in the style of Wordle, built with React and Redux. You have six guesses to find the hidden word. Green tiles are in the right spot, yellow tiles are in the word but somewhere else, and gray tiles aren’t in it. Solving a word doesn’t end the game: you move on to the next one and try to keep a streak going.
What it does
- Three difficulty levels, which change the word length to four, five or six letters, each with its own word list.
- A streak counter that carries over from one word to the next.
- An on-screen keyboard that picks up the same colors as the board, so you can see which letters you’ve ruled out.
- A sound toggle, and a layout that resizes the tiles to fit the screen.
The part I’m happiest with
The tricky bit of a game like this is repeated letters. If the answer has one E and you guess a word with three, only one of those tiles should light up, not all three. It’s an easy bug to write, because the obvious approach is to check each letter against the answer on its own.
The board colors a guess in two passes. The first pass finds the exact matches and removes those letters from a pool of the answer’s letters. The second pass goes through the guess again, and only marks a letter as misplaced if a copy of it is still in the pool, using that copy up as it goes. Letters that run out of copies stay gray.
How it’s put together
The game state lives in a single Redux Toolkit slice: the board, the current word and turn, the streak, which letters have been marked exact, misplaced or unused, a history of the run, and the list of words you haven’t seen yet, so words don’t repeat. The components read from it and send actions to it, so rules like “what happens when you win” are in one place instead of spread across the interface.
It was bootstrapped with Create React App. The source is public on GitHub.