Giter Club home page Giter Club logo

emadnahed / my-tenzies Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 273 KB

The react project of Tenzies game, What is a Tenzies game? A game wherein there are 10 dice in hands looking with the numbers in all dice to be the same. The objective in the Tenzies game is to be the first player to get all ten of your dice to show the same number.

Home Page: https://main.d3qgqufyudkkl9.amplifyapp.com/

HTML 3.09% CSS 39.65% JavaScript 57.26%
front-end front-end-development frontend react react-hooks reactjs scrimba scrimba-frontend tenzies-game

my-tenzies's Introduction

My-Tenzies Project

Table of Contents

Why this project?

Learning development practically via game projects is important because it engages learners, applies theoretical knowledge to real-world scenarios, fosters problem-solving and project management skills, encourages collaboration and teamwork, integrates multiple disciplines, promotes creativity and innovation, facilitates feedback and iteration, builds portfolios, and, most importantly, makes learning enjoyable and rewarding. Through game development, learners gain hands-on experience, develop practical skills, and enhance their employability while having fun and exploring their creative potential.

Project Description:

This is a Tenzies game built with React JS. The game's objective is to roll a set of dice until all dice show the same number, at which point the player has achieved "Tenzies" and wins the game.

The main components of the game are:

  1. Dice : These are the clickable elements that represent each of the 10 dice in the game. Each die has a randomly assigned number between 1 and 6, and players can "hold" a die by clicking on it, freezing its value in place.
  2. Die : This is a reusable component that simulates the appearance of a physical die. It is used to create the 10 dice instances in the game.
  3. Footer : This is a separate component that likely contains the game's credits or any additional information.

The game allows players to roll a set of dice until they achieve the same number on all of them. The player can freeze the desired values by clicking on a die to "hold" its value. Once the player has achieved "Tenzies" (all dice showing the same number), they win the game.

After the first win, the best time is stored in the local storage so that users can come back and challenge their previous records.

Screenshot and link reference:

image

image

References:

How to Install and Run the Project?

To install and run the project, follow the steps below:

  1. Clone the repository : You can clone the repository by running the following command in your terminal:
git clone [email protected]:emadnahed/my-tenzies.git
  1. Navigate to the project directory** : Once you have cloned the repository, navigate to the project directory by running the following command:
cd project-name
  1. Install dependencies : This project requires several dependencies to be installed. To install them, run the following command:
npm install

The Learning Process:

The learning process for this project likely involves understanding the following concepts:

  • React.js : The project is built using React.js, a JavaScript library for building user interfaces. Familiarity with React's component-based architecture, state management, and lifecycle methods is required.
  • JavaScript Fundamentals : Core JavaScript concepts like variables, arrays, objects, functions, loops, and conditional statements are used throughout the code.
  • Functional Programming : The code contains various functional programming concepts, such as pure functions and the use of map, filter, and reduce.
  • Local Storage : The project uses the browser's localStorage to save and retrieve the best rolls and best time records.
  • Third-party Libraries : The code uses external libraries like nanoid for generating unique IDs and react-confetti for rendering confetti on the screen when the user wins the game.
  • Game Logic : Understanding the game rules and logic is essential for following the code. The goal is to roll a set of dice until all dice have the same value.
  • Timer Implementation : The project includes a count-up timer to track the time taken to complete the game. Familiarity with JavaScript's setInterval and useEffect hooks is necessary to understand how the timer is implemented.
  • Scoreboard : The code displays the best rolls and best time records on the scoreboard. Implementing this feature requires the use of React components and conditional rendering based on the stored records.

Here's an example of a high-level outline of what the learning process might look like:

  1. React.js Components : Familiarize yourself with the components used in the project, such as App, Footer, Die, and Scoreboard. Understand how they are structured, how they interact with each other, and how they use state and props.
  2. Game Logic : Understand the game rules and how the code implements the game logic with the dice state, tenzies state, and helper functions like allNewDice, generateNewDie, and holdDice.
  3. State Management : Study how the code manages state using useState and useEffect hooks. Learn how the different states, like dice, tenzies, rolls, and bestRolls, interact with each other and how they are updated based on user interactions.
  4. Game Updates : Understand how the game updates the UI based on user interactions and the game's state. See how functions like rollDice, updateRolls, and resetGame are called during the game's progression.
  5. Timer Implementation : Investigate how the timer is implemented using setInterval, useEffect, and useState. Understand how the timer updates and displays the elapsed time in the desired format.
  6. Scoreboard : Learn how the code displays the best rolls and best time records on the scoreboard. Familiarize yourself with the Scoreboard component and how it uses bestRolls and bestTime states to display the records.
  7. Local Storage : See how the code uses localStorage to store and retrieve the best rolls and best time records. Learn how to use JavaScript's localStorage API to save and retrieve data from the browser.
  8. Third-party Libraries : Understand how the code uses third-party libraries like nanoid and react-confetti to generate unique IDs and render confetti on the screen.

By studying the code and understanding the concepts mentioned above, you can learn from this project and improve your skills in React.js, JavaScript, and game development.

my-tenzies's People

Contributors

emadnahed avatar

Stargazers

 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.