Giter Club home page Giter Club logo

game-puzzle's Introduction

Puzzle Game

Welcome to the Puzzle Game project! This is a simple web-based puzzle game where you can move puzzle pieces on a game board to solve the puzzle. The project also includes some additional features like animations and a background soundtrack. Let's take a closer look at how the project is structured and what each part does.

Getting Started

To play the Puzzle Game, you can simply open the index.html file in a web browser.

Project Structure

The project consists of the following main files:

  • index.html: The main HTML file that creates the structure of the game interface.
  • puzzle.css: The CSS file containing the styles for the game interface.
  • puzzle.js: The JavaScript file containing the game logic, animations, and interactions.

How to Play

  1. Open the index.html file in a web browser.
  2. Use the play button in the navigation to control the background audio.
  3. Arrange the puzzle pieces by dragging and dropping them onto the game board.
  4. Try to solve the puzzle by swapping pieces to the correct positions.
  5. The game will keep track of your moves using the turn counter.
  6. If you exceed a certain number of moves(35), a game over alert will appear.
SShot

game-puzzle's People

Contributors

mahtabvariyani avatar

Watchers

 avatar

game-puzzle's Issues

project1-feedback

Hello Mah,

First off, I want to applaud your effort and enthusiasm for this project. It's clear that you're dedicated to learning and pushing your coding skills forward, which is truly commendable. I took a close look at your code project, and I'd like to share some feedback with you to help you grow even more as a developer.

Root Directory :

Srart.html => index.html
start.js => script.js
start.css => style.css

Taking a moment to tidy up the file names can have a big impact. The small details like correcting typos in file names make a world of difference. Just imagine how much smoother it'll be for everyone (including yourself) to navigate your project when the names make sense. Remember, these seemingly minor adjustments add up to a more professional and organized project.

  • There are many unnecessary files in the root directory which that should be cleaned up or moved to another folder, for example :
    Create a new folder in the root directory called assets and move the following files and folders into it :
wallpaperflare.com_wallpaper(1).jpg 
images
IconBackground
  • You should not include the slides presentation in your coding repository, this is an unrelated folder in your project and it is misleading. for example, use Google Drive to store your various types of data.

  • having just one HTML file is recommended. Instead of having multiple .js and .css files with hasty names, strive for consistency and clarity in naming, using appropriate conventions. This practice will facilitate collaboration with other developers in the future.
    For example, html.html, js.js, and css.css, this is all bad practice… Sometimes Uppercase sometimes Lowercase… etc, also not good.

  • Why the start.js file is redirecting to another html file? What is the purpose of doing this extra step?

puzzle.js file :

There is a lack of using classes and OOP. Actually the file is a mixture of functional and classes!! I don’t know why.
It's great that you're experimenting with different techniques, but mixing functional and class-based code might make the project harder to understand and maintain. Consider grouping related functionalities into classes and methods, utilizing the power of OOP. This will make your codebase more organized and comprehensible.
For example,
Creating the tiles :

for (let r = 0; r < rows; r++) {
    for (let c = 0; c < columns; c++) {
      //<img>
      let tile = document.createElement("img");

      if ((tile.src = "../IconBackground/blank2.jpg")) {
        tile.style.opacity = "0.5";
      }

      tile.addEventListener("dragstart", dragStart);
      tile.addEventListener("dragover", dragOver);
      tile.addEventListener("dragenter", dragEnter);
      tile.addEventListener("dragleave", dragLeave);
      tile.addEventListener("drop", dragDrop);
      tile.addEventListener("dragend", dragEnd);

      document.getElementById("board").append(tile);
    }
  }

Creating the pieces :

 let pieces = [];
  for (let i = 1; i <= rows * columns; i++) {
    pieces.push(i.toString());
  }
  pieces.reverse();
  for (let i = 0; i < pieces.length; i++) {
    let j = Math.floor(Math.random() * pieces.length);

    let tmp = pieces[i];
    pieces[i] = pieces[j];
    pieces[j] = tmp;
  }

  for (let i = 0; i < pieces.length; i++) {
    let tile = document.createElement("img");
    tile.src = "../images/" + pieces[i] + ".jpg";

    tile.addEventListener("dragstart", dragStart);
    tile.addEventListener("dragover", dragOver);
    tile.addEventListener("dragenter", dragEnter);
    tile.addEventListener("dragleave", dragLeave);
    tile.addEventListener("drop", dragDrop);
    tile.addEventListener("dragend", dragEnd);

    document.getElementById("gall").append(tile);
  }
};

All the rest of the functions can be turned into methods inside the classes
Using the this keyword inside an Object and not Class, why? Hope it wasnt just copy and paste :

function CustomAlert(message, title) {
  console.log("triggered");
  this.alert = function (message, title) {
  …

Why there is a function named “wanna”? what is the meaning of this name?
The following line of code was beyond my understanding, can you please explain? What is this if statement all about? What is this condition/assignment or mix of both?

 if ((tile.src = "../IconBackground/blank2.jpg")) {
        tile.style.opacity = "0.5";
 }

Final Thoughts:

Your enthusiasm and ambition to learn advanced coding are truly inspiring. You're on the right path, and with a little more attention to detail and organization, your projects will shine even brighter. Don't let the rush get in the way of your potential. Take the time to refine your work, and I'm certain you'll see incredible results. Keep up the fantastic work, and remember that growth takes time. Your dedication will undoubtedly lead you to become a standout developer with a remarkable eye for detail. Stay curious and keep coding it's your passion and commitment that will drive you to excel.

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.