I am a newbie, in crafty as well as js, so pardon me if I might have made very silly errors in the following program.
What is wrong with the following code? The following code is supposed to create 5*5 matrix where each block would be a 60 pixel high and wide iceblock as stored in iceblock.jpg.

window.onload=function()
    {
        Crafty.init(500,500);
        Crafty.canvas();
        Crafty.sprite(60,"iceblock.jpg",{block : [0,0]});
        Crafty.c("iceblock",function(){
            init: function(){
                this.addComponent("2D, Canvas, Mouse, block");
                this.w = 60;
                this.h = 60;
            }
        });


    };
    for(var i=0;i<5;i++)
        {
            for(var j=0;j<5;j++)
            {
                Crafty.e("iceblock").attr({x: i*60,y: j*60})
            }
        }

The corresponding HTML code is:-

<!DOCTYPE html>
<head>
    <script type="text/javascript" src="crafty.js"></script>
    <script type="text/javascript" src="assignment.js"></script>
    <title>My Crafty Game</title>

</head>
<body>
</body>
</html>

When I open the HTML page, the complete output page is blank.
This is the link to the image.
http://postimage.org/image/ivqfhmjt9/

Nevr mind... found the solution. Thnaks anyways.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.