var PlayButton = [690,760,390,430]
window.onload = function(){
	var canvas = document.getElementById('canvas');
	var ctx = canvas.getContext('2d');
	var clavier = new Clavier();

	var fond = new Image();
    var farfadet = new Image();

    var code = "";
    var LastLetter = "";
    fond.src = "Images/cave.jpg";
	farfadet.src = 'Images/farfadet.png';

    fond.onload = function(){setInterval(boucle,20); }

    function CtxFill(Element,X,Y,Color,Shadow) {
        ctx.globalAlpha = Shadow; ctx.fillStyle = Color;
        if (typeof(Element[0])=="string") {ctx.font = Element[1]+"px "+Element[2]; ctx.fillText(Element[0],X,Y);}
        if (typeof(Element[0])=="number") {ctx.fillRect(X,Y,Element[0],Element[1]);}
    }

    function boucle() {
        ctx.save();
        ctx.drawImage(fond,0,0,1560,680);
        ctx.drawImage(farfadet,850,350,200,200);
        CtxFill(["Code: "+code,40,"Serif"],800,200,"white",1);
        CtxFill(["Salutation jeune aventurier intrepide",40,"Serif"],600,270,"white",1);
        CtxFill(["Avant de rentrer dans la cave tu doit me donner le code",40,"Serif"],600,330,"white",1);
        if(clavier.a&&LastLetter!="a"){code+="a";LastLetter="a"}
        if(clavier.b&&LastLetter!="b"){code+="b";LastLetter="b"}
        if(clavier.c&&LastLetter!="c"){code+="c";LastLetter="c"}
        if(clavier.d&&LastLetter!="d"){code+="d";LastLetter="d"}
        if(clavier.e&&LastLetter!="e"){code+="e";LastLetter="e"}
        if(clavier.f&&LastLetter!="f"){code+="f";LastLetter="f"}
        if(clavier.g&&LastLetter!="g"){code+="g";LastLetter="g"}
        if(clavier.h&&LastLetter!="h"){code+="h";LastLetter="h"}
        if(clavier.i&&LastLetter!="i"){code+="i";LastLetter="i"}
        if(clavier.j&&LastLetter!="j"){code+="j";LastLetter="j"}
        if(clavier.k&&LastLetter!="k"){code+="k";LastLetter="k"}
        if(clavier.l&&LastLetter!="l"){code+="l";LastLetter="l"}
        if(clavier.m&&LastLetter!="m"){code+="m";LastLetter="m"}
        if(clavier.n&&LastLetter!="n"){code+="n";LastLetter="n"}
        if(clavier.o&&LastLetter!="o"){code+="o";LastLetter="o"}
        if(clavier.p&&LastLetter!="p"){code+="p";LastLetter="p"}
        if(clavier.q&&LastLetter!="q"){code+="q";LastLetter="q"}
        if(clavier.r&&LastLetter!="r"){code+="r";LastLetter="r"}
        if(clavier.s&&LastLetter!="s"){code+="s";LastLetter="s"}
        if(clavier.t&&LastLetter!="t"){code+="t";LastLetter="t"}
        if(clavier.u&&LastLetter!="u"){code+="u";LastLetter="u"}
        if(clavier.v&&LastLetter!="v"){code+="v";LastLetter="v"}
        if(clavier.w&&LastLetter!="w"){code+="w";LastLetter="w"}
        if(clavier.x&&LastLetter!="x"){code+="x";LastLetter="x"}
        if(clavier.y&&LastLetter!="y"){code+="y";LastLetter="y"}
        if(clavier.z&&LastLetter!="z"){code+="z";LastLetter="z"}
        if (code=="kayakobeme") {window.location.href = "castle.htm";}
        ctx.restore();
    }
}