Workshop › Battleship › Step 15 of 35
See your own fleet
What we are doing
You can see your own ships, grey on your sea; the enemy's stay hidden. drawSea gets the fleet and whether to show it.
```js
function drawSea(origin, size, shotsGrid, fleet, showShips) {
if (showShips && shipAt(fleet, r, c)) ctx.fillStyle = '#64748b'
drawSea(SEA, BIG, myShots, enemyFleet, false)
drawSea(HOME, SMALL, grid(null), myFleet, true)
```
What it means
- A square is grey only if ships are shown and a ship of that fleet is on it.
- The enemy's sea is drawn with
false (hidden), yours with true.
Your turn
- Add
fleet, showShips to drawSea's parameters.
- Under
ctx.fillStyle = '#1e3a8a' in drawSea, write the grey line.
- In
draw, add enemyFleet, false to the first call and myFleet, true to the second.
Skills: Drawing on a canvas
← Hit or miss? Sinking ships →
All steps
- A 10 by 10 sea
- A function for any sea
- Your own sea
- Draw again and again
- Grids and ships as lists
- A random fleet
- Two fleets
- Which ship is here?
- Fire at a square
- Show the shots
- Your shot
- Tap to fire
- A message line
- Hit or miss?
- See your own fleet
- Sinking ships
- Darker hits on a sunk ship
- Outline sunk ships
- Win in as few shots as you can
- A record of their shots
- Take turns
- The computer shoots back
- You can lose too
- A heat map
- Shoot the hottest square
- Hunt around a hit
- See the heat map
- H for heat
- Show their ships at the end
- A keyboard cursor
- Move with the arrows
- Fire with Enter, play again
- Your best game
- A side panel
- Build it yourself: ships apart