Hot answers tagged

3

If I recall correctly, both Prince of Persia and Flashback (as well as its predecessor, Another World/Out of This World) only allowed movement in set 'steps': if the player ran or walked, they would move a predetermined amount of space (i.e. 8 pixels for a single step, or 32 pixels for a running stride). They were effectively tile-based, and the player's ...


3

SurvivalMachine nailed one of your problems (you can see that the texture is repeated twice). Your other problem (the texture is a big blob instead of a crosshair) is because you don't use transparency : some of the completely transparent pixels of your texture have a green color value (that's a common sight with optimized PNGs). Just enable blending with ...


2

Maybe there's more problems, but at least this looks incorrect: gl.glTexCoord2f(2f, 1.0f); Your texture is repeated horizontally 2 times because its wrap mode is repeat and the coordinates you set are over 1 (in this case 2f). To fix this, replace 2f with 1f: gl.glTexCoord2f(1f, 1.0f);


2

You should not have if-statements nor case-statements; at least not nearly so many. The immediate problem is that you're hard-coding a bunch of logic where a data-driven approach would work better. What you have here on first glance is a state graph (or a finite state machine). Rebuilding this as a state graph with inputs triggering transitions would be a ...


1

Variables and objects in different translation units (c++ / object files) do not have a guaranteed initialization order. It is possible that your std::vector is being used by another global (or static) object constructor in another file before it is actually initialized. Put all the dependent variables in order within the same file or initialize them in a ...


1

Upon first glance, it looks like you call TTF_OpenFont to create your font in your label constructor, but you do not call TTF_CloseFont in the destructor. You should. You also call createSurface in both the constructor and setText. When called from setText, createSurface will immediately allocate a new m_surface and m_texture, causing you to lose the things ...



Only top voted, non community-wiki answers of a minimum length are eligible