DEV Community

Duke Norsworthy
Duke Norsworthy

Posted on

Project 1 Complete: DogSweeper!

Our first project is officially finished! We were tasked with three requirements: first, to fetch data from a public API, second, to run the app on one page only, and lastly, to use 3 separate event listeners. Since Minesweeper involves a lot of clicking, and I personally want to focus on game design and development as a career, I thought that this idea would suit wonderfully.

Making the actual game was easier than I thought. I created a bunch of cells using loops to create the x and y-axis of the board. As each cell was created, attributes are distributed so that the cells can have mines, a number of mines adjacent to them, or 0. After that was some grueling math in order to randomize the mines, and it was off to the event listeners!

In order to start the game and create the board, I created a simple start button to fill one of the 3 required event listeners. The second was using onclick() in order to play the actual game, reveal mines, etc. The third I used as both a test for the API, to make sure the images would come in perfectly, and that is my "I deserve a dog" button. Clicking this button will fetch the data from the dog image API I chose to use, so anyone needing a picture of a good dog could easily get one. The game will also fetch a dog for us when we win, but it's nice to have dogs on command!

This project, though poorly timed due to some family emergencies, was a blast to get through. It also reaffirmed myself that a career in game development is very possible, so I am thankful for the opportunity that FlatIron has given me.

If you need me, I'm going to go decompress from this week with some classic Dogsweeper.

Also, here is my dog. I have put her in the API as well. <3
Alt Text

Top comments (0)