Update time!Disclaimer: the video doesn't capture 50Hz properly, also lots of debug are enabled and it looks "weird"; but the game is updating at 25 FPS.What does the debug mean:
- Red boxes show mini-buffers in use, which is tiles affected by sprites being drawn. Take into account the red boxes are erased in moving sprites (remove the sprite and leave the background), so there are few things going on.
- The thin border lines (not very visible on the video) signal when an update happens on time (25 FPS!), thick lines or a complete red frame means the update was late (slow-down!). There are no thick lines on the video, meaning: yay!
https://twitter.com/reidrac/status/952689606255939584I've been optimising few bits that were OK for my previous games but a waste of time in this one; that includes better batched draw (e.g. the engine fire on the player's ship, now is not a composition of player + fire) and few places where I was was being silly using CPU (e.g. even for fixed path enemies, I tend to be lazy and make them "smart", looking for obstacles, although I know the complete path when the map is loaded).
I'm also updating the HUD when the game isn't busy, so it may delay updating the score a frame or two, but it will never slow down the action.
Next thing is improving how bullets are drawn. For performance I don't support blitting arbitrary sprite sizes but a limited fixed set (8x8, 8x16 and 8x24). Bullets can be consolidated into 4x4, and I may even not use a mask because the shape is square-ish.
With that change I think I'll be really close to the performance that is required for the game, and 25 FPS.
(to be honest, this game would play just fine at 16 FPS; but now that I'm used to play it at 25 FPS, it would be hard to play it at a lower frame rate)