Giter VIP home page Giter VIP logo

connect-4's People

Contributors

rosell-dk avatar

Watchers

 avatar  avatar

connect-4's Issues

Don't play sounds until user interacted with the page

First of all, it is not very nice to be bombarded with sounds when you open your browser containing lots of old tabs.

Secondly, it generates an error in the console on Chrome if you try. While this doesn't hurt the user experience, it certainly hurts the developer experience.

I btw tried to avoid the error, but it seems the only way to avoid it is not to try playing sound. Even creating a new AudioContext(); and testing if its state is suspended results in an error in the console when user hasn't interacted

Save game

Save game locally and retrieve old games

3-player game (n player)

Ok, this isn't directly in the specification.
I'm just curious to try out how such a rule will work.
Of course, it will be too hard to connect 4 pieces, so it should also be possible to change that rule so only 3 pieces are required

One SVG for the entire board

We currently have a SVG for each cell.

We want to do animation and it would be neat to do it inside the SVG. For that we would need the cells in a column to be part of the same SVG. But lets make the rows part of the same SVG too. This will make the process of placing discs a breeze and will allow animations that affects the whole board.

Draw game

Detect when game is over because no other discs can be placed

Play discs with keybord arrow keys

Choose column with left and right arrows. Drop it with down arrow.

This is not as fast as simply pressing a number (#5), but the risk of dropping it the wrong place is reduced

We need a disc array

Currently, we have the information about discs stored in a two-dimensional array, "board"
The array keeps track of the state of each cell in the board (0 = empty, 1 = it contains a player 1 disc, ...)
So discs are actually just states of a cell

However, in order to do animation, we need the discs to have their own life (Imagine for example that we want to implement the "popout" rule, which allows you to remove a disc from the bottom. Such a game move will potentially affect several discs).

So: Lets add a disc array of played discs to the model.
We can still keep the "board" array, as it is useful for the logic. The model will then contain redundant information, which is not ideal, but its practical

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.