With early preview demo release of the Courier of the Crypts I found out there is this rendering bug on some systems where stuff got rendered over the player sprite while it should be under it. Z-rendering & sprite ordering were playing tricks on me.
I was relying only on Z value of sprites instead of drawing them in the correct order. It worked on most of the systems but sytems with integrated graphic card had the mentioned problem. I had to add sorting to the sprite manager and I simply removed
disabled the Z-rendering since I don’t really need it for the game. I also used this chance to change and add quite some stuff to the engine.
This is something I should do at the start but I’ve got used to the hardcoded texture & coordinates loading that I didn’t think much about it or at least I didn’t want to spend extra time on the engine side. It’s very simple but it saves me so much time.
- Slice textures into custom sized tileset grid
- Create custom texture pieces from selection and set a custom pivot of the slice
- Select textures you want to load in the game
Loading textures & coordinates + assigning textures to sprite
~ Texture Manager ~ //Load texture "Player.png" and set its name to "Player" _AddTexture("Player.png" , "Player"); //Create coordinates from texture "Player" named "PlayerGrid" with slice size, rows and columns _AddCoords("Player" , "PlayerGrid" , 16, 25, 40, 40 ); ~ Object ~ pSprite->SetTexture("Player"); pSprite->SetCoordinates("PlayerGrid");
~ Object ~ pSprite->SetTexture("Player");
Drawing custom bounds of the texture
//I had to calculate those bounds in image editor for every custom texture area RectFloat rctFlameHud(1.f, 272.f, 188.f, 377.f); SpriteHud.Draw(rctFlameHud, position.x, position.y);
//ID = id of the custom object bounds SpriteHud.SetDrawObject(ID, position.x, position.y);
These are just two examples of many other stuff I’ve implemented. Calculating those bounds in image editor for every single piece was really tearing my nerves apart. Now all I have to do is to drag a mouse over the piece in the Texture Editor and I have an ID ready to use for rendering. I can also create sprite animations from custom coordinates now.
Before all that I was calling Render functions in the right order but I removed all of that from the game logic now. I just assign sprite to the layer and Sprite Manager handles everything from there. It sorts every layer by the sprite’s Y position as well as height. I also seperated HUD from all the sprites as well as lights.
Map Editor – tileset objects
Some of you may noticed another rendering bug in the game where player was hidden behind the object while the piece of player’s shadow was popping out, drawing over the object? That’s because objects like caskets, pillars, stone pieces etc. were rendered as the tileset and I can’t sort every tile like objects. Now I won’t be drawing those objects with the tileset but as the standalone objects. Take a look at this gif:
This is also great for level design because object position won’t be limited to the grid now. I’ll be able to place it few pixels left or right as well as move it to some other place quickly without deleting the tiles first and placing new ones.
I’ve used this week to create texture editor, changed how to sprites work, implement all of that changes to the map editor (which meant almost full remake of it) and next week I’ll implement that changes to the game as well. This will be quite fast since all I have to do is to remove long lines of code with single lines. After that, development continues smile
Question: shouldn’t you work on the game rather on the engine?
Yes but most of the changes were necessary either to solve bugs or to make the development much easier for me. On the long term, it’s a good thing.
Piece of advice – don’t make games in your own engine.
Until next time wink