Connect Four (also known as Four Up, Plot Four, Find Four, Four in a Row, Drop Four, and Gravitrips in the Soviet Union) is a two-player connection board game, in which the players choose a color and then take turns dropping colored discs into a seven-column, six-row vertically suspended grid. The pieces fall straight down, occupying the lowest available space within the column. The objective of the game is to be the first to form a horizontal, vertical, or diagonal line of four of one's own discs. Connect Four is a solved game. The first player can always win by playing the right moves.
Main goal here is practicing Jquery without using arrays in Javascript.
Steps to make a game:
- First we define buttons with table in html file. We link Jquery file directly from jQury web site or you can download and link locally.
- We change button parameters in css file.
- We take input player names and define special color to each player. Each time when player changes, color also changes when click event happens.
- For finding row and column index number answer is on Stackoverflow.
- After every click on button in table we check horizontal or vertical or diagonal consicutive match of same colors. if there is a match we stop the game announce it with grabbing text on the top with jQuery and change it with winner players name.