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.
- 顯示結果 UI 仍然有些顯示 Bug。
- 待將 updateBoard()以 useMemo 改寫。
Note: Delete this note and update the table of contents based on what sections you keep.
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
- Solution URL: https://github.com/Chious/front-mentor-connect-four-game
- Live Site URL: https://dazzling-conkies-026a37.netlify.app
- Create App Component, Reset CSS, Font, Menu, Starter (4hr)
This App is come up with:
- Starter
- Rule
- MainGame: Main(Control game play), PlayerCounter(show how many games player won), footer(show timer and result)
- Main Game(3 Days)
Game state would be control by Timer.js
and Main.js
Main.js
should be able to:
- Know who win the game
- reset gameBoard conditionally
- change player if no one win
Time.js
deal with time related game rule, and should be able to:
- start counting time by 5s if first player start to play.
- if timer is 0s, nowPlayer should lost the game.
- if someone show menu, the timer should pause and restart if close.
- User Info (4hr)
- Semantic HTML5 markup
- SASS -- to manage CSS setting
- React
Note: These are just examples. Delete this note and replace the list above with your own choices
-
It's my first time to handle complex project, everything is great at the begining, and my code get into a mess while design game and time related algorithm. Next time, it's better to draw a greater flow chart before design.
-
first time to learn how to design timer and change state in different component.
-
it seems somwhat redundent while need to use stetes in child component, I need to code such
stateXXX
andsetState
again and again. Wondering if there's better way to manage useState. -
It's troublesome while items in same position but with different z-index, sometimes
position: relative / absolute
ordisplay: flex
would be trouble, I sould be get deeper understand with css. -
It's good to re-think about how to build the rule about game and timer. I fill like to bounce back and forth between
timer.js
,footer.js
, and some else component.
- Since it take me lots of time while design method, I didn't desgin RWD for laptop and phone view.
- While player win, board should show oordinates. I've tried to display this by
renderGameRecord
inMain.js
, not sure why this didn't work. - while palyer draw, it should present draw result and clear board.
- console keep shows warning about useEffect
- it's wired showing "0" at the
starter
.