Ship
Ship
We now want to bring a Ship into the equation.

Challenge
Create a new css rule that targets elements with an id of ship and sets the background-image to the ship.png file. Instantiate a new Ship object in JavaScript and then add a new method to the controller that selects's a #ship div and positions it under the .port element that corresponds to the ship's currentPort.
To complete this challenge, you will need to:
- Create a new instance of
Shipinside the inline JS inindex.html, passing in your itinerary. - Create a new
divwith the idshipas a child of the#viewportdiv, and as a sibling of the.portselement. - In
style.cssadd a new#shipruleset. You want to use theship.pngbackground image, and specify a width and height that matches that image's dimensions. You should also specify apositionofabsoluteas later on we will want to control our element's X/Y co-ordinates within the viewport. - Add a
renderShipmethod to yourController.prototype, which has a single parameter ofship. - Back in
index.html, callcontroller.renderShipand pass in yourshipfrom before. - In the
renderShipmethod, find the index of the ship'scurrentPortinside of itsitinerary. Usedocument.querySelectorwith an attribute selector to find a.portelement that has aportIndexdata attribute which corresponds to this index. - Prior to appending to the DOM, set the
topandleftCSS properties of your ship element to the offsetTop and offsetLeft values for the port element. - Add or subtract from your
offsetLeftand/oroffsetTopvalues to position your ship so it's centered directly underneath the port.