칸 아카데미라는 사이트에서 


고양이 점프시키는 자바스크립트 있어서


(https://ko.khanacademy.org/computing/computer-programming/programming-games-visualizations/side-scroller/a/beaver-character)


나도 따라해보려했는데 


이건 어디다가 써놓고 실행시켜야되는거냐? 나 그냥 할줄아는게 html 밖에 없어서 


이렇게 넣어버렸는데 안나오더라 ㅋㅋ 



<!DOCTYPE html>

<html lang="en" dir="ltr">

  <head>

    <meta charset="utf-8">

    <title>jump</title>

  </head>

  <body>


  <script type="text/javascript">


    var Beaver = function(x,y){

      this.x = x;

      this.y = y;

      this.img = getImage("img/NK");

      this.sticks = 0;

    };


      Beaver.prototype.draw = function(){

        this.y = constrain(this.y, 0, height-50);

        image(this.img, this.x, this.y, 40,40);

      };


      Beaver.prototype.hop = function(){

        this.img= getimage("img/NK");

        this.y -=5;

      };


      Beaver.prototype.fall = function() {

      this.img= getimage("img/NK");

      this.y +=5;

      };


      var beaver = new Beaver(10,300);


      draw = function(){

        background(255,255,255);

        if (keyIsPressed && key.code === 32){

          beaver.hop();

        }else {

          beaver.fall();

        }

       beaver.draw();

       };


  </script>

    </body>

</html>



알려주셈 ㅋㅋ