Skip to content

jay-ike/connect-four-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Frontend Mentor - Connect Four game solution

This is a solution to the Connect Four game challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.

Table of contents

Overview

The goal of the game is to connect four discs vertically, horizontally or diagonally and the first to do it wins

The challenge

Users should be able to:

  • View the game rules
  • Play a game of Connect Four against another human player (alternating turns on the same computer)
  • View the optimal layout for the interface depending on their device's screen size
  • See hover and focus states for all interactive elements on the page
  • Bonus: See the discs animate into their position when a move is made
  • Bonus: Play against the computer

Screenshot

a view of the game in a mobie phone

Links

My process

Built with

  • Semantic HTML5 markup
  • CSS custom properties
  • CSS Mask
  • CSS Grid
  • Mobile-first workflow
  • Custom Event for reactivity

What I learned

In terms of css we can create a custom shape with the help of clip-path and svg or with the help of mask-image (which can take any image even css gradients)

.pawn::before {
    -webkit-mask-image: radial-gradient(circle, transparent 50%, black 0);
    mask-image: radial-gradient(circle, transparent 50%, black 0);
}
/*this was used to create the hole in the grid items of each disc*/

In tems of javascript we can use Custom Event to notify DOM nodes

        function notify(time) {
            const timeUpdated = new CustomEvent("timeupdated", {
                detail: {time}
            });
            node.dispatchEvent(timeUpdated);
        };

Continued development

Next I should implement the play vs CPU feature to make it more pleasing

Useful resources

Author

Acknowledgments

I was highly inspired by this solution to check a win in the connect-four game so feel free to check here in case you whant to take a look PS: The code is written in python The stackexchange community for code review

About

FrontendMentor connect-four game challenge

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published