Here is the classic game of Connect Four, on Scratch. -- Instructions -- Connect Four is a two player game in which each player takes turns dropping a token of their colour into a grid. The winning player is the first to get four tokens of their colour in a row, whether it be vertical, horizontal or diagonal. Each player picks a colour (red or yellow) at the start. I have implemented a scoring system in this version: when a player gets four in a row, their score increases by one and the board resets. this allows you to challenge your opponent to a 'first to ____' match without having to keep track of the score. -- Controls -- To insert a token into the grid, either click the desired column with your mouse pointer, or use the number keys (each column has been labelled with the corresponding number for those who cannot be bothered to work it out for themselves). This game is mobile friendly. Tell me if there are any bugs/glitches or anything that should be added. Goodbye, for now...
I may make an online multiplayer version of this at some point, but for now it is local two players. I started making this project on another account, but felt it was significantly better than most of the projects I had made so far, and decided to start afresh. More projects are to come (hopefully). The hardest thing about making this project was the four-in-a-row detection. It didn't take very long to make the basic game, but writing the row detection code took a while and was quite a pain, especially for the diagonals. If you click 'see inside' you may notice that there is a ridiculous amount of code for this purpose, much of it repeated. There is probably a better and much quicker method than the one I used, and if you can think of one, please comment below. -- Credits -- Original game invented by Howard Wexler and first sold under the 'Connect Four' Trademark by the Milton Bradley company in 1974. All code and graphics by me.