Vanilla JS Tutorials

JsIso Tutorials

RSS feed

05 - Adding an Isometric player that can be moved

Adding Ralph from the vanilla player movement tutorial is easy in JsIso, we also get the ability to take advantage of the height map with no extra work.
In this sample we have added a second layer which could hold NPCs, Pickups, Players, Trees, Pylons, Water Towers, Walls of Winterfell... endless possibilities.

With the new layer "objectLayer" we apply the same properties as the "tileLayer", but we set - heightMapOnTop: true// We want to draw only on top of the heightmap.
This makes all graphics in this layer drawn on top, however for this tutorial we only want to draw Ralph, so we use the tileImageOverwrite property of layer.draw():

 if (i === ralphX && j === ralphY) {
       objectLayer.draw(i, j, ralphGraphic);

As always, check out the live code viewer to fiddle, linked at the bottom:

    function(CanvasControl, TileField, imgLoad, CanvasInput) {

      // RGBA of color to use
      var tileColor = "(158, 154, 255, 1)";
      var groundColor =  "(100, 154, 100, 1)";

      // Our Tile Map
      var tileMap = [
        [groundColor, groundColor, groundColor, groundColor, groundColor, groundColor, groundColor],
        [groundColor, tileColor, groundColor, tileColor, groundColor, tileColor, groundColor],
        [groundColor, tileColor, tileColor, tileColor, groundColor, tileColor, groundColor],
        [groundColor, tileColor, groundColor, tileColor, groundColor, tileColor, groundColor],
        [groundColor, groundColor, groundColor, groundColor, groundColor, groundColor, groundColor]

      // Our Height Map 
      var tileHeightMap = [

      // X & Y drawing position, and tile span to draw 
      var xrange = 8;
      var yrange = 8;

      // X & Y Coordinates of Ralph
      var ralphX = 1;
      var ralphY = 1;

      var ralphGraphic = null; // Will contain the image of Raplh once it has been loaded

      var context = CanvasControl.create("canavas", 640, 640, {});

      // Two layers - one for the ground, second layer for objects, player objects, NPCS, pickups, etc etc
      var tileLayer = new TileField(context, CanvasControl().height, CanvasControl().width);
      var objectLayer = new TileField(context, CanvasControl().height, CanvasControl().width);

      // Create our Input controls and pass through the CanvasControl to it
      var input = new CanvasInput(document, CanvasControl());
      // Pressed is the keycode of user input, and keydown means the button is down rather than press ended
      input.keyboard(function(pressed, keydown) {
        if (!keydown) {
          switch(pressed) {
            // Move player
            case 37:
              ralphY ++;
            case 39:
              ralphY --;
            case 40:
              ralphX ++;
            case 38: 
              ralphX --;
          // Call draw Tile Map function

      var images = [
          graphics: [
            "/img/game/ground/blank-block.png" // The images we want to load using imgLoader
          graphics: [

      function drawTileMap() {
        // Clear drawn map before clearing
        context.clearRect(0, 0, CanvasControl().width, CanvasControl().height);
        // Loop through our tiles and draw the map  
        for (i = 0; i < 0 + xrange; i++) {
          for (j = 0; j < 0 + yrange; j++) {
            tileLayer.draw(i, j);
            if (i === ralphX && j === ralphY) {
              objectLayer.draw(i, j, ralphGraphic);

      // imgLoad uses Promises, once the images have loaded we continue and use the returned imgResponse
      imgLoad(images).then(function(imgResponse) {

        // set Raplphs image, imgResponse[1] because it was the second list of graphics to be loaded
        ralphGraphic = imgResponse[1].files["ralph.png"] 

          title: "Ground Layer",
          layout: tileMap,
          isometric: true, // Flag used to layout grid in isometric format
          tileHeight: 50,
          tileWidth: 100,
          heightMap: {
          map: tileHeightMap,
          // imgResponse[0] contains the first set of grpahic files[] we placed in the graphics array
          heightTile: imgResponse[0].files["blank-block.png"],
          offset: 0
          shadow: {
            offset: 50, // Offset is the same height as the stack tile
            verticalColor: '(5, 5, 30, 0.4)',
            horizontalColor: '(6, 5, 50, 0.5)'
        // Object Layer
          title: "Object Layer",
          isometric: true, // Flag used to layout grid in isometric format
          zeroIsBlank: true,
          layout: tileMap,
          tileHeight: 50,
          tileWidth: 100,
          heightMap: {
            map: tileHeightMap,
            offset: 50,
            heightMapOnTop: true// We want to draw only on top of the heightmap

        // Rotate our entire Map 

        // Set an offset so our map is on screen
        tileLayer.setOffset(200, 100);
        objectLayer.setOffset(200, 100);
        // Call draw Tile Map function

Check out the View Source to see tutorial.
Up Down Left Right to move Ralph

Tutorial Outcome (View & Run Source)


  1. This is great, awesome to continue learning how to maneuver this stuff, thank you. carpet cleaners medicine hat

    painters brandon mb Sun, 28 Apr 2019

  2. What an information-rich article! I'm glad I found you guys

    — Alex P Wed, 15 May 2019

  3. It’s very informative and you are obviously very knowledgeable in this area. garena free fire playerunknown's battlegrounds

    — samuelddarden Wed, 29 May 2019

  4. Wow! Amazing tutorials on adding isometric player. Very detailed information you have here! Thanks a lot! accident towing in ashburn va

    — Aryan Tue, 4 Jun 2019

  5. You have a great detailed information, I'm impressed on how you presented the important things. Keep it up! lawn care services

    — Daniel Perez Fri, 7 Jun 2019

  6. It's my pleasure to find this amazing website who provides mostly unseen information about every single topic which is i really like it. click here

    — Joshua A. Price Mon, 10 Jun 2019

  7. Nice job, I really like how your site looks. tree trimming

    — fred luis Wed, 12 Jun 2019

  8. Waow this is quite pleasant article, my sister love to read such type of post, I am going to tell her and bookmarking this webpage. Thanks

    voyante sérieuse par téléphone Thu, 11 Jul 2019

  9. This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free.

    voyance très fiable Sat, 13 Jul 2019

  10. Wow! Thanks for this tutorial. I hope I can do this in my end.

    lawn care company columbia Thu, 1 Aug 2019

  11. Codes are complex, Thanks for sharing this tutorial with us.

    Hvac Tech Support Thu, 1 Aug 2019

  12. Plenty of helpful info here. Kindly also discuss with my site =). wayhaven chronicles book 2

    — SAMS Thu, 1 Aug 2019

  13. Wow, I love your post today! This in just the perfect time. Thanks a bunch! Hudson's Concrete Contractor Pittsburgh

    Hudson's Concrete Contractor Pittsburgh Mon, 5 Aug 2019

  14. Amazing tutorial using JSiso which is Tile-Based engine which uses the HTML5 Canvas element.
    social security card application

    — Darius Oliver Tue, 6 Aug 2019

  15. You must be very astute at research and writing. This shows up in your original and unique content. our site

    — Cassandra D. Everhart Tue, 6 Aug 2019

  16. You make so many great points here that I read your article a couple of times. Your views are in accordance with my own for the most part. This is great content for your readers. domino88

    sam Wed, 7 Aug 2019

  17. I have added and shared your site to my social media accounts to send people back to your site because I am sure they will find it extremely helpful too. pengeluaran sgp

    sam Fri, 9 Aug 2019

  18. "Haarlem (Geluidsfragment uitspraak is een stad en gemeente in Nederland en
    de hoofdstad van de provincie Noord-Holland. De stad ligt aan de rivier
    het Spaarne en in de regio Zuid-Kennemerland / Haarlemmermeer." Haarlem online services Haarlemmermeer

    — MUNEER Thu, 15 Aug 2019

  19. Persons appreciate shopping for amazing, appealing, fascinating and from time to time attractive aromas for them selves and pertaining to others. This can be executed conveniently along with inexpensively in an on-line perfume shop. 리턴벳 먹튀

    sam Sat, 17 Aug 2019

  20. Great tutorial and thank you for sharing this routine/procedure for a movable isometric player. I'll try this out and at the same time share this to my friends at Seo Cincinnati who are also interested in this.

    — Terrence Foster Mon, 19 Aug 2019

  21. Een dakkapel uitwijkconsole is een steiger contructie voor op daken met een dakkapel. Ideaal voor onderhoud van uw dakkapel bij bijvoorbeeld schilderwerkzaamheden of gewoon het periodiek schoonmaken van uw dakkapel. Dakkapel Uitwijkconsole Steigercentrum heeft diverse lichte modellen op voorraad die eenvoudig zijn te monteren als ook te domonteren.

    — muneer ahmed Tue, 20 Aug 2019

  22. So luck to come across your excellent blog. Your blog brings me a great deal of fun.. Good luck with the site. worldwide trademark search

    sam Tue, 20 Aug 2019

  23. Thank you for the great tips. I both host and am a guest at poker nights every now and again, but never really considered why or how setting the tone of play is important. This makes things very clear, and I agree, it's better to be upfront about the expectations right from the start. Thanks for putting this together, I appreciated it.
    Snow Removal Saskatoon
    Maid Services Saskatoon
    Cement Contractor Saskatoon

    — Hank Gilbertson Tue, 20 Aug 2019

  24. Awesome tutorials! Glad I've reached your site. This is very useful in coding. Thanks a lot! business tax preparation

    — Karlyle Woodbridge Tue, 20 Aug 2019

  25. Awesome tutorials! I always look back here for coding and for updates. Good job! Keep it up! SEO VA

    — Kate Tue, 20 Aug 2019

  26. Appreciating the persistence you put into your blog and detailed information you provide. I’ve bookmarked your site and I’m adding your RSS feeds to my Google account. voyance amour

    sam Fri, 23 Aug 2019

  27. "Een makelaar bemiddelt bij koop en verkoop, huur en verhuur van huizen,
    winkels, horecabedrijven, kantoren, roerende zaken, verzekeringen, op de
    goederentermijnmarkt of ander roerend, onroerend of registergoed, regelt
    contracten en (ver)koopafspraken. Een groot deel van het werk bestaat uit
    het zoeken van (de makelaar van) een geschikte partij om dat bepaalde goed
    eenmalig mee te verhandelen. De makelaar is dus slechts tussenpersoon en
    is werkzaam krachtens een overeenkomst van bemiddeling. Het vak wordt de
    makelaardij genoemd. De makelaar verzorgt traditioneel alle zaken van
    opname tot de overdracht door de notaris. Hiervoor betaalt de klant een
    courtage, dit is een vooraf afgesproken percentage ( meestal tussen 1% en
    2% ) van de uiteindelijk gerealiseerde verkoopprijs. De Nederlandse
    Vereniging van Makelaars (NVM) hanteerde tot eind jaren 90 adviestarieven.
    Dit is door de Nederlandse Mededingingsautoriteit (NMa) verboden.
    Tegenwoordig zijn er ook makelaars, die een vast tarief hanteren ongeacht
    de verkoopwaarde. Zolang de werkzaamheden van de makelaar niet tot
    resultaat leiden, hoeft de verkopende klant meestal alleen de door de
    makelaar gemaakte kosten te vergoeden. Primair is de bemiddeling
    bij verkoop van woningen, appartementen, flat, bedrijfspand en winkels." Makelaarskantoor

    — muneer Sat, 24 Aug 2019

  28. I gave this website to my kid and he told me that he got the same result. I told him if he can edit some of the programming, and he did. Thank you so much, my kid actually learned something.

    harrisburg roof repair Mon, 26 Aug 2019

  29. This is a great idea to build a mini satellite map for usps change of address online upon checking locations out. This looks like a building which we can see from above.

    — Eliya Mon, 26 Aug 2019

  30. I can't beleive how much this has helped our local business to get with the times. Thanks so much!

    Ace Wed, 28 Aug 2019

  31. Great post, please keep on sharing amazing article like this! It makes me happy reading your post.

    Play Free Online Papa's Games Thu, 29 Aug 2019

  32. That's a great idea. Thanks for sharing. Please visit our website Katy Stamped Concrete if you are interested in Interior Designs.

    — Katy Stamped Wed, 4 Sep 2019

  33. This is cool post and I appreciate to peruse this post. your blog is phenomenal and you have great staff in your blog. pleasant sharing keep it up. 104 productivity

    sam Thu, 5 Sep 2019

  34. This is quite interesting. Thank you for sharing. Please visit Charlotte Septic Services.

    — Charlotte Septic Mon, 9 Sep 2019

  35. This is amazing. It is really amazing. Looking forward to trying this. Thank you for sharing this to us. It really helps.
    >> Tyler Sprinkler

    Tyler Sprinkler Tue, 10 Sep 2019

Please insert the result of the arithmetical operation from the following image:

Please insert the result of the arithmetical operation from this image. =