Canvas drawImage drawing in repl.it website, but not outside of repl.it

I’m making a website that has a canvas in it, and it works fine when I run it inside of repl.it, but when I run it outside, some of the images don’t show up.

Here is the code that makes them appear when the canvas is clicked.

Game.canvas.onclick = function(event) {
   Game.mousex = event.pageX
   Game.mousey = event.pageY
   if (Game.selected == 'lummox') {
   Game.lummox = new Game.Lummox(Game.mousex,Game.mousey)
   Game.cards.push(Game.lummox)
}
}
and in a different place.
      const g = setInterval(function() {
        Game.ctx.clearRect(0,0,Game.canvas.width,Game.canvas.height)
        Game.drawbackground()
        for (let i = 0; i < Game.cards.length; i++) {
          Game.cards[i].render()
        }
      },10)

And this is all after the images have been loaded.

Can someone tell me why this is happening?

Hey, @DRMAN welcome to the forums.

Can you please share the link to the repl?

1 Like

https://replit.com/@GilbertSchmidle/thing

Edit: fixed link

1 Like

Looks like you tried to post a join link. That lets anybody edit the code and delete it all. Can you please share a link to the cover instead?

1 Like

Is this is the Repl? thing - HTML, CSS, JS Repl - Replit

It seems to work fine for me…
In Chrome:


In Replit (on Chrome):

1 Like

I tried on my mobile and result was opposite to yours. Though I couldn’t debug because my mobile couldn’t handle your functions.

1 Like