Javascript Canvas one item flickering -
i trying make objects move towards each other in canvas, when meet , overlap 1 should disappear , other should fall down. got animation that, 1 of items flickering. <!doctype html> <html> <head> <style> canvas{border:#666 3px solid;} </style> </head> <body onload="draw(530,15); draw1(1,15);"> <canvas id="canvas" width="600" height="400"></canvas> <script> function draw(x,y){ var canvas = document.getelementbyid('canvas'); var ctx = canvas.getcontext('2d'); ctx.save(); ctx.clearrect(x, y, 600, 400); ctx.fillstyle = "rgba(0,200,0,1)"; ctx.fillrect (x, y, 70, 50); ctx.restore(); x -= 0.5; if(x==300) { return; }; var looptimer = settimeout('draw('+x+','+y+')',5); }; function draw1(w,e){ var canvas = document.getelementbyid('canvas'); var ct...