Git Product home page Git Product logo

wordle-game's Introduction

Wordle

๐Ÿฆถ Steps

  • Add your HTML code to the index.html file
  • Add your CSS code to the style.css file
  • Add your JavaScript code to the wordle.js file
  • Push your changes to the remote main branch

๐Ÿ“ƒ Notes

  • The page reads a dictionary of words from this endpoint: https://api.masoudkf.com/v1/wordle. The endpoint requires an API key (sw0Tr2othT1AyTQtNDUE06LqMckbTiKWaVYhuirv). You can use fetch and add the key like the following:

    const res = await fetch("https://api.masoudkf.com/v1/wordle", {
        headers: {
        "x-api-key": "sw0Tr2othT1AyTQtNDUE06LqMckbTiKWaVYhuirv",
        },
    });
  • Here's a sample response of what the endpoint returns. It returns a JSON object. You don't need to be concerned about the statusCode property; what you want is dictionary:

    {
    "statusCode": 200,
    "dictionary": [
        {
            "word": "Pain",
            "hint": "Attending any class other than ENSF 381 gives you ____"
        },
        {
            "word": "Nerd",
            "hint": "You may be considered one, if you like Star Trek"
        }
        ]
    }
  • Unlike the original Wordle game, you don't need to check if the word exists in the dictionary

  • You only read from the endpoint once per page refresh. Hitting the Start Over button shouldn't send another request if the user hasn't refreshed the page. It only picks a random new word from the already-loaded dictionary. You can generate a random number between 0 and N using the following code:

    Number.parseInt(Math.random() * N)
  • The Start Over button should become disabled while the code is getting the dictionary from the endpoint for the first time, and say Loading...

  • You need to capture key events from the user and populate the boxes. The key event used in the demo is keyup, and the boxes are marked up using the table element. But feel free to change that

  • Users can use the Backspace key to remove characters from the word

  • Users must use the Enter key to submit an answer. On Mac OS, the key is called Return, but the key code is the same

  • If a user hits the Enter key while the word is not complete, the page should alert the user to finish the word first. You can use window.alert("first complete the word") for this

  • After a word submission:

    • Letters in the right spot should get a green background
    • Letters in the word but in the wrong spot should get a yellowish background
    • Letters not in the word should get a gray background
  • At any time in the game, users can use the ? icon on the menu to see a hint about the word. This hint is part of the dictionary returned from the endpoint

  • When a user wins, the page should show a congratulation image. You can find the one used in the demo here

  • When a user loses, they should get a message with a red background saying they couldn't guess the word and lost

  • The i icon in the menu shows the game instructions

  • The Moon icon in the menu can toggle the page from Light to Dark theme

  • I didn't use any CSS framework for the layout, but feel free to use one if you want

  • The icons on the menu are HTML characters (◑ for the Dark Mode icon; ? for the Hint icon; and ⓘ for the Game Instructions icon)

  • I used vanilla javascript

The Result of the final project! Screenshot 2023-07-22 at 8 57 02 PM Users can get Instructions Screenshot 2023-07-22 at 9 02 06 PM

When all guesses are wrong Screenshot 2023-07-22 at 9 04 31 PM

Users can take a guess Screenshot 2023-07-22 at 9 06 00 PM

It contains a word

Screenshot 2023-07-22 at 9 07 32 PM

Also supports dark mode Screenshot 2023-07-22 at 9 09 22 PM

Mobile friendly also Screenshot 2023-07-22 at 9 11 37 PM

Guessed the word correctly and won the round Screenshot 2023-07-22 at 9 12 33 PM

wordle-game's People

Contributors

bobinho100 avatar github-classroom[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.