0

So I'm doing a project and I'm developing a fall down type game.

The problem seems to be on this line: createRect(20, 40, 25, 15, "red");

It looks like the rect is drawn but instantly disappears any idea on how to fix this? I'm not sure why this happens and I'm learning javascript so I don't have the experience to understand why this occurs

  • Welcome to Stack Overflow! You've done a pretty good job with your first question, properly putting the code in a code block and describing the problem. It would be helpful if you would explain what you have tried to do to debug this, and why you think that particular line is the problem. – Basya Sep 06 '17 at 18:22

1 Answers1

0

The problem is that you keep resetting the cavas size several times a second:

setInterval(function(){
    canvas.width = 360;
    canvas.height = 640;
    createMenu();
}, 1000 / fps);

Resetting the size is a (bad) way to clear the canvas (see How to clear the canvas for redrawing), and thus the newly drawn rectangle disappears.

Sphinxxx
  • 12,484
  • 4
  • 54
  • 84