by unfortunate · 15y ago · 0 comments
If your code crashes every browser, your code is shit. Yes the browsers could do better, but you shouldn't write shit code that crashes them.
I genuinely have no idea how I can improve the quality of the code in this.
I won't jump to conclusions, but this attitude is kind of indicative of the Dunning-Kruger effect (http://en.wikipedia.org/wiki/Dunning-Kruger_effect) being at play, especially given that you seem to be blaming browser makers for your game crashing.
Even the very best programmers can think of ways to improve the quality of their code. In fact, they're more likely to find problems in their own code - that's part of why they're the best.
In any case, assuming you aren't suffering from the Dunning–Kruger effect, can you mention what attempts you've made to narrow down the problem?
Have you tried disabling parts of the game (like rendering for example) to see if the browser still crashes? That would be a simple, albeit tedious, way of narrowing down where the problem is. Come up with a minimal crash case.
If you find a legitimate problem across all 4 browsers, then you can use that minimal case to demonstrate the problem and file a bug report. Or, more likely, you'll figure out what's wrong in your code this way and fix it.
Your code can only be as good as the platform you're working with. You can't code features beyond what are supported, and if you're trying to do too much, you need to scale back. If you based a games design on the idea that every computer was quad core with a huge graphics card, it would be pretty amazing, but no-one except a select few could play it.
Short of it is, you're code doesn't work, whatever is wrong with it, it doesn't work. And you can't expect browsers to change to suit you, if you really don't know how to improve it, scrap it and start again but at the moment you can't blame the browsers for not being able to support your, probably brilliant, game.
Have you tried to put them into sprite sheets?
I've recently been reading into making use of sprite sheets with Canvas apps, and the drawImage method makes using sprite sheets a breeze. You simply need to keep track of cellsize, number of cells, and your current cell.
Well, if you're using dom-based animation, spritesheets also work better for animations since it's much faster to adjust background-image-position in a div, compared to just replacing the background-image.