+ 1
frame is not cleared
the circle method is drawn, but the next frame does not clear, but the ob method is cleared https://code.sololearn.com/WUR1QS7aN78R/?ref=app
4 Answers
+ 2
I uncommented a lot of code, consistently indented and got the graphics to show.
Your clear function works fine but you're not properly opening and closing paths when you draw arcs.
Adding these 2 lines to your circle function fixed the issue for me:
var circle=function (x,y,r,color,fill,thickness)
{
ctx.fillStyle=color;
ctx.lineWidth=thickness;
ctx.beginPath(); // ADD THIS LINE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ctx.arc(-camera.x+x,-camera.y+y,r,0, Math.PI*2,false);
ctx.closePath(); // ADD THIS LINE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if(fill==true){
ctx.fill();
} else {
ctx.stroke();
};
};
If you post a similar question later, try to make it easier to reproduce the bug without any code changes. Asking someone else to change code to reproduce a bug makes it harder to help you. It is easy to add new bugs or unknowingly fix the bug you're asking about when code is updated.
+ 1
You must have changed the code in question a lot since posting the question because I can't see anything when I run your code. I ran in both Edge and Chrome.
It would be easier to help if you refrained from changing the code you link to or paste relevant code in your question. It is easy to copy it and continue your efforts with an independent copy while waiting for an answer.
Mostly unrelated to your question, some minor improvements would be nice with your code.
Your < and > characters in buttons should be converted to entities like this:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<canvas id="c"></canvas>
<div id="con"> </div>
<div id="s" align="center">
<button class="b" id="lButton">&lt;</button>
<button class="b" id="uButton">^</button>
<button class="b" id="dButton">â</button>
<button class="b" id="rButton">&gt;</button>
</div>
</body>
</html>
0
I didn't change the code, all the techniques of rooms in the comment, because they lead to errors.
0
Thank you very much I did not when Bi did not solve this problem.