Handmade Hero»Forums»Code
Iker Murga
43 posts
Why advance bitmap pointer after loading bmps?
At the beginning of GameUpdateAndRender, the Bitmap pointer is advanced after loading the head, cape, torso and alignment correctionsfor each of the directions. Although advancing it for the first three is necessary, once the fourth direction is set, why is it advanced again? (line 308 in handmade.cpp on both days 39 and 40)

At first I thought it was just so that if more directions are added at some other time you will already have it advanced. But the length of hero_bitmaps array in GameState would need to be modified so it doesn't seem like it saves any extra work.

So, am I missing something or is it just copy pasta?
Lachlan Easton
14 posts
Technically a Programmer
Why advance bitmap pointer after loading bmps?
Edited by Lachlan Easton on
I wouldn't call it copy pasta since it doesn't mess the code up in any way. As it is the increment has no effect (as Bitmap is not used later in the function). However, it's more useful to keep it as it makes adding new parts easier and makes the loading of each piece symmetrical which makes it easier to pull the code out into its own function if desired.
Iker Murga
43 posts
Why advance bitmap pointer after loading bmps?
Edited by Iker Murga on
I did think about the adding new parts, but hand't realized about the part of making it easier to pull the code out. Thanks for clearing that up for me RJTracer!