Advertisement Jump to content
  • Advertisement
  • entries
  • comments
  • views

Toasty Update #3

Sign in to follow this  


Things done for this update:

SFMLDeltaTimer Added

I added an SFML based timer so that it can be used instead of the chrono timer on windows.

SFMLRenderSystem Added


So the SFML render system is pretty simple, it's constructor takes width, height and a window title. It automatically creates a window with those attributes (Which you can change or get after creation). It also handles management of textures, if you try and load a texture twice it will return the original texture. this works for sprites as well. The render system currently has a single view which one can manipulate, it basically just exposes zooming, moving and rotating of a view, support for multiple views will come eventually. If the window is closed it will return false on it's Update function and close the window.

This system updates a render components position, rotation and scale to that of the entity just before drawing the entity. The system does no culling of any sort at the moment nor does it have any kind of depth sorting it is just last component added is the one drawn on top.

SFMLRenderComponent Added


This is essentially just a sprite, it requires a string and an SFML render system to create. It uses the SFML render system to get a texture pointer which it uses to create the sprite.

SFMLTextRenderComponent Added


Just used to render some text onto the screen and at the moment will load and use it's own font resource, it's something I'll have to change.

SFMLAnimationSystem Added


This is a spritesheet based animation system and is not that robust at the moment. If the animation component has been set to play it will advance the position of the frame to the next one after the frame timer goes past the allowed frame time.

SFMLAnimationComponent Added

This just contains a map of strings to animation data, what the current animaiton is and whether it is playing. It has functionality for stopping and playing at the moment. It requires a SFMLRenderComponent to be able to be created as it uses it's sprite, it's best to give it the component that is attached to the entity! After it's created you have to give it very specific data:

  • frameWidth
  • frameHeight
  • frameNumber
  • startX
  • startY
  • currentFrame
  • currentRow
  • currentCol
  • animationTime
  • frameTime

    It's done this way because you might have different sized animations in the same atlas.
    SFMLTileMapComponent Added


    During my test I noticed performance issues trying to render my own little map, so I decided to make this to alleviate that. It's a simple class and takes a string to use as the texture atlas, an int* for the data, the dimensions of the tiles and the desired width and height of the map. The data is just ints ranging from 0 to how many tiles you have, the SFMLTileMapComponent will assign 0...N in a row first left to right order, so that the top left tile is 0 and the on to it's right is 1. I basically stole some code off the SFML wiki to get this working.

    I plan on having several TileMap implementations, a simple one like this one and a multi-layer, multi-atlas one, I'll probably think of more features as I think on it.


    I added the ability to create an entity in the game system, this makes creating a relevant entity to use in a game system a lot neater. I also added an ability to get all entities in a radius, it's pretty fast but I wouldn't use it if you had more than...say 1000 entities. I had a crazy bug when I first started:


    and after a bunch of debugging and optimising it turned out I had just copy pasted x where y should have been...


    I am already seeing failures in my API design and so I am re-evaluating and might do a refactor, although not before I get this version 'done'.

    The (MinSizeRel) ToastySFMLRenderSystem.dll is about 64 KB.

    Stuff TODO:

    • Fix crash if texture load failed from the render system
    • Add an action based sfml input system (Unity style)
    • Add basic collision system for SFML (no collision response)
    • Add culling pluggability into the SFML Render System
    • Have at least one culling mechanism to use in the SFML Render System
    • GUI, I'll probably base it on an already existing GUI.
    • A way to re-order render components

      That's it for now! Thanks for reading!
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!