https://battleship-ilja.netlify.app/
- HTML
- Sass
- JavaScript
- Parcel
The building block of websites. Very little was used within directly within the index.html
file.
Sass stands for Syntactically Awesome Stylesheet. It is a preprocessor for CSS. It allows us to use a different syntax that I think makes writting styles easier. I use a version of Sass called SCSS, which uses braces to designate code blocks rather than indenation like pure Sass. These filese then get compiled into CSS which is what is then given to our HTML files for styling.
The main components of this project. We used a lot of different topics, Classes, Modules, a Bundler, Promises / Async Await, etc. I tried to separate concerns to each individual class, and to do my best to adhere to programming principles. I used parcel to allow me to seperate my JavaScript files.
Going into this I've seen other people do projects like this. I read the code and played with other battle ship projects online to get a feel for what I wanted to do. There were a lot of interesting things I saw people do. Being able to drag and drop ships, to displaying a coordinate based off of where your cursor is at, to shadowing in cells of where your ship would be placed.
I started off by just placing everything into functions and just getting it to work. Then, I thought about what variables and functions were interacting the most together and placing them into a class. I knew I wanted to have two representations of my grid. One would be in the browser and another would be stored in JavaScript. Allowing for the changes to occur through JavaScript rather than having to reach into the browser for the information.
Each, "cell" of the grid was represented by a Cell
object. This cell has properties that would are updated
to reflect the state of the cell. We also have a Ship
object representing our ships. Both of these objects would
be kept in our Board
object.
- Drag Events
- Custom Events
- Indicating Cells VS. Ships in Board Class
- Waiting for User Click
- Hiding computer's ships
- Extracting information into relevant classes
- Transition buttons with linear gradients
- Detecting correct ship placement
- Updating specific ship segment
- Making the AI smarter
- Instructions on how to play the game
- Indicator of who's turn it is
- Making sunk ship colors more contrasting
- Add animations to cells & ships to move them slightly
- Have the game say "You Win!" or "You Lose" before transitioning to "Play Again?" text
- Create a background gradient
- animate the background gradient to represent water moving
- Create grids for yourself & opponent
- Grid and column gaps should both be equal in width
- grid tiles should be mostly transparent (think sea foam)
- missed tiles will be colored in black
- hovered tiles will be white if there's nothing within the tile
- our ship pegs will be slightly darken when hovered. doesn't matter if they're hit or not
- hit or missed tiles will also darken slightly
- A model of the enemy's current fleet will be model beneath their field
- When an enemy ship is full destroyed the pegs of the ship will animate red
- Two red lines will follow the mouse cursor representing "coordinates"
- Above each grid will be a score for each player
- All text on the board should be the same color as the grid tiles
- When the user moves the cursor the "coordinate lines" should follow it
- User should be able to randomly position their ships
- User should be able to drag their ships onto the board
- An option to rotate the ship once it's been clicked
- An option to continue once all our ships are placed should be enabled
- Should detect if a ship is being placed in an already occupied spot
- Should detect clicks on only the opponent's side after the user has continued
- Should detect if it has clicked on an enemy ship
- Should detect when a game is completed
- Should update the score of whoever won
- Should allow for a user to play again once a game is completed