Toasty Update #3
c++ entity component based system toasty update sfml 2d engine
I added an SFML based timer so that it can be used instead of the chrono timer on windows.
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.
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.
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.
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:
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.
- 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