How To Build A Minesweeper Clone With JavaScript

How To Build A Minesweeper Clone With JavaScript

Web Dev Simplified

3 года назад

44,960 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@afooferrz
@afooferrz - 01.12.2022 05:30

how to make mines game

Ответить
@elQueFaltaba
@elQueFaltaba - 09.11.2022 18:38

This is still one of those technical tests some companies do. It tests your knowledge on navigating bidimensional arrays, add/remove event listeners, cancelling default behaviour and propagation of events, has a mini status machine, .. and it's fun. Good one WDS!

Ответить
@redtarget827
@redtarget827 - 17.09.2022 16:29

I have always wanted to make a minesweeper game since early days of windows 3.1. I am really enjoying your videos. Thanks for sharing your knowledge.

Ответить
@gauravdobriyal1337
@gauravdobriyal1337 - 18.08.2022 09:56

Your advance course have this video

Ответить
@aaxen7255
@aaxen7255 - 15.07.2022 21:10

This is really good, I learned a lot. I am returning to dev after a very long hiatus and found you using methods I didn't even know existed. I appreciate you explained the more unusual ones like bind, stopImmediatePropagation and such.

Ответить
@Proviper666
@Proviper666 - 05.07.2022 20:47

I have trouble making those mines=0 opening

Ответить
@astroidexadam5976
@astroidexadam5976 - 25.06.2022 15:03

Ik worked

Ответить
@Stayllnew
@Stayllnew - 06.05.2022 00:35

Create a tutorial How to make a browser game for dummies with build house and atack other players is not any tutorial to web:)

Ответить
@vasukannan.s7423
@vasukannan.s7423 - 07.03.2022 12:01

79th commemt😂

Ответить
@damvan8099
@damvan8099 - 23.02.2022 08:08

You do my 3 months project in less than 45 minutes I'm-

Ответить
@j0hannes5
@j0hannes5 - 18.02.2022 13:47

while (positions.length < numberOfMines ) is really smart.

I had the restriction that I only had as many loop iterations as there are numberOfMines
So I had to create a recursive random number function that doesn't allow a passed(exception) value:

function getRandomInt(min, max, exception) {
min = Math.ceil(min);
max = Math.floor(max);
const randomInt = Math.floor(Math.random() * (max - min)) + min
return (randomInt === exception) ? getRandomInt(0, max, exception) : randomInt
}

and is called like this:

mines[yPos][xPos] ?
//we don't want this combo of xPos and yPos when occupied ->
mines[getRandomInt(0, yLength, yPos)][getRandomInt(0, xLength, xPos)] = true :
//but usually we do ->
mines[yPos][xPos] = true

Ответить
@j0hannes5
@j0hannes5 - 18.02.2022 10:27

while re-building the game I'm really confused about something:

For some reason I'm only getting one row of tiles.
Even though my 'board' for sure is an array of arrays that is just like yours.
I'm iterating throguh it just like you:

board.forEach(row => {
row.forEach(tile => {
boardContainer.append(tile.element)

Ответить
@justletmelistthese
@justletmelistthese - 29.09.2021 14:07

I tried this one a 1d array and draw on canvas... I'm not okay.

Ответить
@mikeneikovych3700
@mikeneikovych3700 - 30.07.2021 10:45

Thanks a lot for great work!

Ответить
@Crashman1012
@Crashman1012 - 07.07.2021 00:07

I’m not sure if you have a video addressing this, but I notice you are looking at another screen quite frequently. I’m guessing you’re looking at the code, because you don’t have it memorized. This is one thing I want to get out to people: YOU DONT MEMORIZE CODE!! You spend just as much time googling as you do coding. For videos sake, he obviously had already written it. This is something I struggled with, wondering why I could just sit in my IDE and write code for an hour straight

Ответить
@j946atFIVEFOUR88AA
@j946atFIVEFOUR88AA - 04.07.2021 23:43

thanks for the vid! Was fun to follow along

Ответить
@harag9
@harag9 - 06.06.2021 04:18

Why don't you break your code down into objects / files - e.g. the "tile" should be an object and in a file called tile.js. Creating the tile object within a function just makes the code look messy and hard for maintenance.

Ответить
@nikhilraj1842
@nikhilraj1842 - 15.05.2021 11:31

Am i only one who come here to just learn how to play minesweeper

Ответить
@henryacosta3919
@henryacosta3919 - 11.05.2021 21:14

I have document its not defined error please help.

Ответить
@xiaokourou
@xiaokourou - 05.05.2021 14:24

Should use math.round instead of floor, otherwise you'll never get mines on the last row or column

Ответить
@Neckhawker
@Neckhawker - 03.05.2021 11:33

Why using forEach and not for of ?

Ответить
@PejmanTayebi
@PejmanTayebi - 19.04.2021 01:16

awesome

Ответить
@thorbjerke7977
@thorbjerke7977 - 19.04.2021 01:11

Really wish i found your channel earlier, keep up the great work

Ответить
@LuizFeReis
@LuizFeReis - 16.04.2021 08:19

Code "early" is not working for the course discount

Ответить
@nileshd2428
@nileshd2428 - 12.04.2021 16:19

This is by far the most well written piece of code I have come across.

Ответить
@jimhalpert9803
@jimhalpert9803 - 12.04.2021 15:15

If you're looking for a new video idea , you should definitely make a big 20-30 mins video explaining GitHub and git well (just like Tech with Tim's latest video). Your old git video is 2 years old and I feel like you could make a much better video now!

Ответить
@codingperks
@codingperks - 12.04.2021 07:10

Code is cluttered, separate the functions into separate files inside a minesweeper directory

Ответить
@maelstrom57
@maelstrom57 - 12.04.2021 01:40

I've just spent two days trying to do this project on my own but I got stuck at the revealTiles() function. Just can't get the damned thing to work recursively. \_:(_/

Ответить
@eugeniogonzato
@eugeniogonzato - 11.04.2021 23:55

Thanks , this is very interesting , thanks.
I whached this video so many times becouse there are some many inspiration. but, tell me the true: did you do it all by your self? if yes you are incredible!!
You are the best!!

Ответить
@devcon3977
@devcon3977 - 11.04.2021 23:38

can u make a video on how to make your own music streaming server

Ответить
@andrewdillard5961
@andrewdillard5961 - 11.04.2021 20:27

Wow I can't wait to watch this. I'm almost halfway through his course. It's so freaking amazing!

Ответить
@cardbored_
@cardbored_ - 11.04.2021 19:13

I was unaware that Johnny Bravo knew JavaScript!

Ответить
@tima1301
@tima1301 - 11.04.2021 18:46

nice video, thanks!

Ответить
@EdwinPWeston
@EdwinPWeston - 11.04.2021 18:14

Wow, thank you, so much great information. I noticed the lack of 'else' statements like you suggested in a prior video. I would love to see a video explaining why you do not use semicolons.

Ответить
@wissendev5490
@wissendev5490 - 11.04.2021 16:10

Simplified as always

Ответить
@HampusR
@HampusR - 11.04.2021 15:15

Nice and clear as always.

However, one small detail bothers me quite a bit. You say that you split the code into display and logic, but you still embed a div-element in your logic code basically mixing them anyways... Not by a lot, but still...

Ответить
@whoman7930
@whoman7930 - 11.04.2021 14:38

why don’t you just create a class called `Minesweeper`? So you could declare some private and public methods on it. Private methods are declared using ‘#’ as a prefix

Ответить
@danielkappacher33
@danielkappacher33 - 11.04.2021 13:40

Great video! Loved the clean way how you set up the nearbyTiles() function to also be able to call it recursively afterwards.
It was cool to see the .bind() trick, but in my opinion this makes the code less readable and adds unnecessary confusion for other developers that might not be as familiar with it. I just think explicitly passing the two parameters that are being processed is a little cleaner than passing null and the first parameter, while at the same time assuming everyone knows that the bind function will automatically add the iteration value to it.

Ответить
@uvaishassan
@uvaishassan - 11.04.2021 09:13

Super cool. Not gonna lie, felt a bit complicated in the middle but made it through. Good video. Thanks ❤️

Ответить
@lassebrustad
@lassebrustad - 11.04.2021 05:26

Minesweeper and Snake is probably the 2 best games to recreate for learning purposes. good video about Minesweeper, just as good as the Snake game! :D

Also, I love how you're saying the words "simple" and "easy" like REALLY often! x)

Ответить
@ankitsanghvi9248
@ankitsanghvi9248 - 11.04.2021 04:48

I finally unserstood how to play minesweeper today ! XD

Ответить
@nickwoodward819
@nickwoodward819 - 11.04.2021 01:58

Great guide man - I love that you're direct and concise enough that you convey a lot of information to those with slightly more than a basic knowledge of JS.

Ответить
@thalesfernandes8015
@thalesfernandes8015 - 11.04.2021 01:23

Couldn't you use a Set instead of an array for the mine positions? Instead of populating with objects, populating with indices from 0 to n^2-1

Ответить
@alwinvillero9505
@alwinvillero9505 - 11.04.2021 00:28

Do you have a TypeScript Tutorial? Please make one ^^

Ответить
@MHY-bu1hy
@MHY-bu1hy - 10.04.2021 22:28

Thanks for the great effort, Looking for the day you build a chess game application with JS !

Ответить