Apologies in advanced for not submitting a game. Does anybody feel an unbreakable urge to just break from free of the dreary day job and write games for fun each time you see a HN post like this? My fantasy is to just go and Browserize a game (and not just by wasming it). Gaaaaah the tragedy of limited time!
Yes and yes. I've been trying write a game from scratch (emphasis on "scratch" considering the scale of the itch) as a side project, but that quickly evolved into an excercise in overcoming analysis paralysis. I'm currently stuck on "can I count on the HTML Canvas to optimise cases where a tile is out of view or should I make a fancy system to calculate that now ?" I get an average of 2h a week to do this, so I need…
I am not sure if I understand you correctly, but since I did wrote a canvas game from scratch, I can tell you that you cannot count on the canvas to optimize anything (and likely not what you want in this case)
Every browser does it a bit different and it will depend on the hardware and OS what optimisation features are avaiable.
On average the canvas is quite performant, though.
Performant enough, that in my case, I draw everything on a big map - zoom in and then move the map around, when the player moves.
On a gaming PC, maps can be quite large - but on an average mobile not so much.
But I autogenerate the levels which means I can dynamically adjust size, so this works for my game.
But in general yes, you want a small canvas, the size of the screen - and then only draw what is needed.
EaselJS may help with that. It is basically flash on the canvas, but does exactly this. You put all your graphic objects on the stage - and easelJS will figure out which one of those needs to be drawn at the current frame. I initially used it, but not anymore as it was not optimized for my use case, making LOTS of new draw calls on the map every tick. But for a classic game with limited entities, it is very performant.