Показать сообщение отдельно
  #3 (permalink)  
Старый 13.11.2019, 08:10
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,070

Jimy,
<!DOCTYPE html>

<html>
<head>
  <title>Untitled</title>
  <meta charset="utf-8">

</head>

<body>
<canvas id="canvas" width="800" height="600"></canvas>
<script>
var ctx=document.getElementById("canvas").getContext("2d");

ctx.rect(0,0,800,600);
ctx.stroke();
circle=function(x,y,radius){
    ctx.beginPath();
    ctx.arc(x,y,radius,0,Math.PI*2,false);
    ctx.fill();
};
var ball=function(){
    this.x=100;
    this.y=100;
    this.xSpeed=-2;
    this.ySpeed=5;
    this.draw=function(){
        circle(this.x,this.y,20);
    };
};
var b = new ball();
b.draw();
b.x = 200;
b.draw();
b.y = 200;
b.draw();
b.x = 100;
b.draw();
  </script>
</body>
</html>
Ответить с цитированием