Adventure Map


Create a map of your next adventure world. Put together a map of the world you want using terrain types you choose. This could be the beginning of your next big adventure game!

To see a working example click here


Directions
  1. If you are coding outside of WoofJS.com (like in Sublime), insert the Woof_JS source tag into the <head>section of your project page:

    <script src="https://rawgit.com/stevekrouse/WoofJS/master/dist/woof.js"></script>

    Your code now speaks Woof!

  2. Setup a dark background for your project.

  3. Think of 5-7 tile types you want to use in your map and find images for each. These can be any size you find, we’ll scale them down to tile size later.

  4. Put the URL’s to the tiles in an array. Then create another array of tileNames[] and put the name of each tile in the corresponding cell in that array.

  5. Write a function to print out the legend on the side of your screen. HINT: You can iterate through the tiles and the tile names in the same loop.

  6. Now create 2-D array containing your adventure map matrix, like so:

    var mapMatrix = [
      [1,4,4,4,4,1,2,2,2,2],
      [1,1,4,4,1,1,1,2,2,2],
      [1,1,3,5,1,1,1,1,2,4],
      [1,3,3,5,1,1,2,2,2,5],
      [4,3,1,1,2,2,3,2,2,2],
      [4,3,1,1,3,3,3,3,3,2],
      [1,3,1,1,1,3,3,3,3,2],
      [3,3,3,1,1,3,3,3,3,3],
      [3,3,3,3,3,3,3,1,3,3],
      [3,3,3,3,3,3,3,3,3,3],
    ];
    


  7. Write your main function, to display the tile map. Use nested FOR-LOOPS to iterate through the 2-D matrix array and read the tile type in each square. Then figure out the X and Y of the tile, and create it using new Image({})

  8. EXTRA CREDIT: Create a simple text-box editor to let you edit the map matrix in the browser.








(c) 2016 by Code Craft Academy