lunedì 7 settembre 2015

Day 64: Perfected GUI

Today was another very positive day, and I made a lot of improvements to the engine.

I started by refactoring the the PointLight, DirectionalLight, PointLight, GameObject and Sprite.
They all had in common the lack of a global list to track their presence.
After the refactoring you can just create an object, and the engine will know it's there and will be able to render it and so on.

I also moved the batches logic to the deferred renderer class, so that now in the main game class everything is clean and details independent.

After that I proceeded to improve the GUI I've written yesterday.

First I've written an anchoring system, which is something that is often missing in game engines and I find very useful.
As you can see from the image, I just placed 4 sprites at the coordinates (0,0), (0,1), (1,0) and (1,1), and by changing the anchoring point they are easily placed inside the screen.

Then I solved the ratio problem by dividing ratio and size.
The sprite has a default ratio (obtained from the image itself), and setting the size to, for example, (100,100), will make the image 100 times bigger, but with respect for the original ratio.
It is possible to set the ration to 1, and the image will be exactly 100x100


Nessun commento:

Posta un commento