Skip to main content
Notice removed Draw attention by nabla-f
Bounty Ended with Scotty Jamison's answer chosen by nabla-f
Notice added Draw attention by nabla-f
Bounty Started worth 50 reputation by nabla-f
added 2 characters in body; edited tags
Source Link
nabla-f
  • 183
  • 11

I'm working on building a simple game in vanilla JS (tic-tac-toe). Some weeks ago I created a functional MVP and asked some questions about it (Vanilla JS Tic-Tac-Toe). The code worked, but it was a single monolithic mess and the uiUI was ugly, so I decided to improve it.

I'm working on building a simple game in vanilla JS (tic-tac-toe). Some weeks ago created a functional MVP and asked some questions about it (Vanilla JS Tic-Tac-Toe). The code worked, but it was a single monolithic mess and the ui was ugly, so I decided to improve it.

I'm working on building a simple game in vanilla JS (tic-tac-toe). Some weeks ago I created a functional MVP and asked some questions about it (Vanilla JS Tic-Tac-Toe). The code worked, but it was a single monolithic mess and the UI was ugly, so I decided to improve it.

https://meta.stackoverflow.com/questions/328379/why-are-fellow-users-removing-thank-yous-from-my-questions
Source Link

I'm working on building a simple game in vanilla jsJS (tic-tac-toe). Some weeks ago created a functional MVP and asked some questions about it (Vanilla JS Tic-Tac-Toe). The code worked, but it was a single monolithic mess and the ui was ugly, so I decided to improve it.

So, I refactored the code. I organized it ininto three files:

  1. main.js - contains the state and controls the game flow
  2. UIFunctions.js - uiUI related (painting cells, cleaning the screen, etc)
  3. gameCheckerFunctions - process the state and verifies if we have a winner
  4. gameStateFunctions - basically saves moves made and change the current player
  1. How to implement a MVC pattern? Right now, the state and htmlHTML elements are global variables, but I think this could be stored in state and UI clases.classes Also, I'm having troubles with the concept of controller. AreIs main.js the code that will be the controller in an MVC pattern?

  2. There's a better algorithm to check for the winner?

  3. Is it a good looking code? How it could will be improved? What looks ugly and could be done in a better way? I really would like to develop good practices from the beginning.

  4. Some features that iI would like to implement are a CPU player, storing the score in localStorage, remember the player name, auth, two-player network gamming, etc. I'm in the correct way of doing things?

Many thanks in advance!

I'm working on building a simple game in vanilla js (tic-tac-toe). Some weeks ago created a functional MVP and asked some questions about it (Vanilla JS Tic-Tac-Toe). The code worked, but it was a single monolithic mess and the ui was ugly, so I decided to improve it.

So, I refactored the code. I organized it in three files:

  1. main.js - contains the state and controls the game flow
  2. UIFunctions.js - ui related (painting cells, cleaning the screen, etc)
  3. gameCheckerFunctions - process the state and verifies if we have a winner
  4. gameStateFunctions - basically saves moves made and change the current player
  1. How to implement a MVC pattern? Right now the state and html elements are global variables, but I think this could be stored in state and UI clases. Also, I'm having troubles with the concept of controller. Are main.js the code that will be the controller in an MVC pattern?

  2. There's a better algorithm to check for the winner?

  3. Is it a good looking code? How it could will be improved? What looks ugly and could be done in a better way? I really would like to develop good practices from the beginning.

  4. Some features that i would like to implement are a CPU player, storing the score in localStorage, remember the player name, auth, two-player network gamming, etc. I'm in the correct way of doing things?

Many thanks in advance!

I'm working on building a simple game in vanilla JS (tic-tac-toe). Some weeks ago created a functional MVP and asked some questions about it (Vanilla JS Tic-Tac-Toe). The code worked, but it was a single monolithic mess and the ui was ugly, so I decided to improve it.

So, I refactored the code. I organized it into three files:

  1. main.js - contains the state and controls the game flow
  2. UIFunctions.js - UI related (painting cells, cleaning the screen, etc)
  3. gameCheckerFunctions - process the state and verifies if we have a winner
  4. gameStateFunctions - basically saves moves made and change the current player
  1. How to implement a MVC pattern? Right now, the state and HTML elements are global variables, but I think this could be stored in state and UI classes Also, I'm having troubles with the concept of controller. Is main.js the code that will be the controller in an MVC pattern?

  2. There's a better algorithm to check for the winner?

  3. Is it a good looking code? How it could be improved? What looks ugly and could be done in a better way? I really would like to develop good practices from the beginning.

  4. Some features that I would like to implement are a CPU player, storing the score in localStorage, remember the player name, auth, two-player network gamming, etc. I'm in the correct way of doing things?

added 80 characters in body
Source Link
nabla-f
  • 183
  • 11

I'm working on building a simple projectgame in vanilla js (tic-tac-toe). ISome weeks ago created a functional MVP and asked some questions about it (Vanilla JS Tic-Tac-Toe). The code worked, but it was a single monolithic mess and the ui was ugly, so I decided to improve it.

So, I organized the refactored the code. I organized it in three files:

  1. How to implement a MVC pattern with this code? Right now the state and html elements are global variables, but I think this could be stored in the state and UI clases. Also, I'm having troubles with the concept of controller. Are main.js the code that corresponds towill be the controller in an MVC pattern? TLDR: how to transform this code to MVC?

  2. There's a better wayalgorithm to check for the winner?

  3. Is it a good looking code? How it could will be improved? What looks ugly and could be done in a better way? I really would like to develop good practices from the beginning.

  4. My goals with this areSome features that i would like to implement are a CPU player, storestoring the score in localStorage, remember the player name, auth, two-player network gamming, etc. I'm in the correct way of doing things?

I'm working on a simple project in vanilla js (tic-tac-toe). I created a MVP and asked some questions about it Vanilla JS Tic-Tac-Toe. The code worked, but it was a single monolithic mess and the ui was ugly, so I decided to improve it.

I organized the refactored code in three files:

  1. How to implement a MVC pattern with this code? Right now the state and html elements are global variables, but I think this could be stored in the state and UI clases. Are main.js the code that corresponds to the controller in an MVC pattern? TLDR: how to transform this code to MVC?

  2. There's a better way to check for the winner?

  3. Is it a good looking code? How it could will be improved? What looks ugly and could be done in a better way? I really would like to develop good practices from the beginning

  4. My goals with this are implement a CPU player, store the score, remember the player name, two-player network gamming, etc. I'm in the correct way of doing things?

I'm working on building a simple game in vanilla js (tic-tac-toe). Some weeks ago created a functional MVP and asked some questions about it (Vanilla JS Tic-Tac-Toe). The code worked, but it was a single monolithic mess and the ui was ugly, so I decided to improve it.

So, I refactored the code. I organized it in three files:

  1. How to implement a MVC pattern? Right now the state and html elements are global variables, but I think this could be stored in state and UI clases. Also, I'm having troubles with the concept of controller. Are main.js the code that will be the controller in an MVC pattern?

  2. There's a better algorithm to check for the winner?

  3. Is it a good looking code? How it could will be improved? What looks ugly and could be done in a better way? I really would like to develop good practices from the beginning.

  4. Some features that i would like to implement are a CPU player, storing the score in localStorage, remember the player name, auth, two-player network gamming, etc. I'm in the correct way of doing things?

Source Link
nabla-f
  • 183
  • 11
Loading