Git Product home page Git Product logo

projectone's Introduction

projectOne - Tile Madness

ScreenShot

Description

The goal is to rearraange the tiles in numerically ascending order from lowest to highest, from top left to bottom right

Installation

None required, to play just go: Here

Project Workflow

This project was an A-Z exercise in creating a fully functional, ES6 class based game. I started with several hours of whiteboarding and planning, which prompted me to ask myself many questions along the way that I hadn't thought of before. Once i had my basic design, I started with functionality first design second. I began with pure function expressions in one page, app.js. Once I had the game working, I linted, and brokes the components into classes, tiles and game. From there, I created the main.js and created the instances. Because this was a small game the design was minimal. The complexity lies in the functionlity.

1. Whiteboarding and notes

Whiteboard Notes Notes Notes

Technologies Used

  1. Javascript ES6
  2. HTML / CSS
  3. git locally
  4. GitHub
  5. Github pages for deployment

Unsolved Problems

I designed the game in such a manner to build a small MVP and once functional, simply refactor the CSS to accomodate any number of tiles to scale the game. Knowing that some things take me a long time, I strived for scalability last, and ran out of time.

The issue is a bug in the setWinArrPattern() function. When I create larger instances, the game starts "missing" random numbers. This is seen here

here

Given a few more hours, I fell this bug is easily fixable.

projectone's People

Contributors

madriver44 avatar

Watchers

James Cloos avatar Vincent Abruzzo avatar  avatar

projectone's Issues

running in circles on wincheck

I read and re-read the code from the tic tac toe logic. I am having trouble mapping the current position to an array because i have a parent div holding the square that is movable.

scope problem, one line above variable is read next line, it's undefined

`  checkWin(arr) {
    let winArr = arr;
    const currentArrayPattern = [];
    const idParents = document.querySelectorAll('.parent'); // NodeList
    idParents.forEach(function idparents(item, index) {
      if (item.children.length === 1) {
        currentArrayPattern[index] = item.children[0].innerHTML;
      } else {
        currentArrayPattern[index] = null;
    }
  

       "it reads winArr here"
      //console.log('THIS IS curr',currentArrayPattern, 'This is winArr',winArr);
    }); // forEach
  

       "next line, i get error can not read property 'length' of undefined...."
       console.log('This is winArr',winArr);
       if (currentArrayPattern.length !== this.winArr.length) {
         return false;
      }
      for (let i = 0; i < this.winArr.length; i += 1) { // GAME
         if (currentArrayPattern[i] !== this.winArr[i]) {
           return false;
          }
         this.createWinDiv();
         return true;
       }
     //equals(currentArrayPattern, arr /*winningArrayPattern*/);
  }// function`

upon click, winning condition is giving me preclick data

When I click on a square, within the click event, the forEach loop is returning data that is old. For example:
Winning array pre-click = ['0', '1', '2', null], the Current Array =[]....

Upon click on square 0, which moves to the empty parent div becomes....
Winning array post-click = ['0', '1', '2', null], Current Array =['0', '1', '2', null] // old state

When I re-click box with '0'....to return to original pattern...winning condition
Winning array = ['0', '1', '2', null], Current Array = [null, '1', '2', '0'] // old state -- get it? because pre-click, this was exactly correct, null in index 0, 1 in index 2.

js fiddle

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.