I am on the last few pages on JavaScript for kids book and I seem to be stuck on the snow man challenge. The challenge is to make a snowman appear if I call out drawSnowman(50,50) The snow man should appear at the x coordinate 50 and the y coordinate 50. Here is what I came close too. Here is what I have so far. I tried to build a constructer that would come close to what I have done before but can’t seem to find a proper solution that fits. In a nut shell. How do I make the snowman move all at once without having to modify ctx.arc each time to build a new circle.
\\
<body>
<canvas id = "canvas" width ="200" height ="200"></canvas>
<script>
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
//ctx.strokeStyle = "Green";
var Circle = function (x,y){
this.x = x;
this.y = y;
};
var circle = function(x,y,radius) {
ctx.lineWidth = 4;
ctx.beginPath();
ctx.arc(x,y,radius,0,Math.PI * 2, false);
ctx.stroke();
};
ctx.lineWidth = 4;
ctx.strokeStyle = "Black";
circle(100,100,20,false);
circle(100,150, 30);
circle(105,97, 1, true);
circle(95,97,1,true);
//Buttons for snow
circle(99,135,1,true);
circle(99,148,1,true);
circle(99,164,1,true);
var drawSnowman= function (circle){
circle.css({
position:"absolute",
left:circle,x,
top:circle.y
});
}
var boom = new circle(20,20);
circle(boom);
</script>
<h1> Hello World!, my name is Sonny!</h1>
</body>
\\\