1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

My code won't recognize my identifiers

Discussion in 'Programming/Internet' started by Jacob Sanchez, Oct 8, 2018.

  1. I'm working on making a simple flash game for my coding class, but my code refuses to accept 0,1 and 2 as identifiers. I even tried rewriting the entire code, and even that didn't work. I can't exactly rewrite it another way either since my class wants it done this way. Any help you could provide would be awesome.

    <!DOCTYPE html>
    <html>
    <head>
    <title>Ninjaman</title>
    <style type="text/css">
    *{
    margin: 0;
    padding: 0;
    }
    .row {
    line-height: 0;
    }
    .wall {
    background-color: blue;
    height: 40px;
    width: 40px;
    display: inline-block;
    }
    .sushi {
    background-color: black;
    height: 40px;
    width: 40px;
    display: inline-block;
    background-image: url('sushi.png');
    background-size: contain;
    }
    .blank {
    background-color: blue;
    height: 40px;
    width: 40px;
    display: inline-block;
    }
    #ninjaman {
    background-color: blue;
    height: 40px;
    width: 40px;
    display: inline-block;
    background-image: url(ninja.gif);
    background-size: contain;
    position: absolute;
    left: 40px;
    }
    </style>
    </head>
    <body>
    <div id='world'>
    </div>
    <div id='ninjaman'></div>
    </body>
    <script type="text/javascript">
    var world = [
    [1,1,1,1,1],
    [1,0,2,2,1]
    [1,2,0,2,1]
    [1,2,2,2,1]
    [1,1,1,1,1]
    ];
    var worldDict = {
    0: 'blank',
    1: 'wall',
    2: 'sushi'
    }

    function drawWorld(){
    output = "";

    for(var row = 0; row < world.length; row++){
    output += "<div class = 'row'>"
    for(var x = 0; x < world[row].length; x++) {
    output += "<div class = '" +worldDict[
    world[row][x]] +"'></div>"
    }
    output += "</div>"
    }

    document.getElementById('world').innerHTML = output
    ;
    }
    drawWorld()
    </script>
    </html>


    The problem is on lines 59-61. That's where my identifiers are.

    Login To add answer/comment
     

Share This Page