Open andyg0808 opened 2 years ago
I changed most of the let
to const
excepting the resize function variables and my delta variable. However, I would have thought I could declare line 39 as const
but this seems to break the canvas. I tried separating the bits from the drivers and the jimmy thinking it may have something to do with the array but it still breaks. Any thoughts? Is this something to do with the x and y coordinate changes as part of the animating functions of PIXI?
Looks like it's not legal to declare a const ahead of time:
(I tried it out in my browser console to see what would happen)
Try dropping line 39 altogether and put the const
s on lines 48, 52, etc.
Gotcha thank you! I'll have a look at this now.
https://github.com/mhomami/Tank/blob/74e115e25ae04a530c524b3d3756b83eb56cb745/js/script.js#L39
const
instead oflet
whenever possible, because it makes it clear that the variable only ever has one value. Of course, if you need to change the value over time (as happens with_w
and_h
, for example), then you'll need to uselet
.