back to work:) working with focusing


For the first time in the last two months, I fully returned to coding for an hour or two. It was difficult to find the point to continue from, but it's good that I write everything in the git commit names, all the todos, and micro-progress - I worked on refocusing objects.

What's the focus? Since the game has two high-level rendering systems - Flame and a custom one, objects can be rendered in both renders. This imposes some restrictions but also gives a performance boost.

For example, the custom one is needed to render as quickly as possible only what is on the screen.

Flame components render what contains some custom behavior. Ideally, there shouldn't be many such objects, especially in the visible area.

What's the complexity? The complexity lies in combining the state and position of objects.

For example, in the current task, I need to draw the focus border of a tent. In a Flame component, this could be done through a regular render function, but since my objects are rendered customly, they are not components. In this case, I came up with the following approach:

Since the state of the object is always known and taken to the top level (beyond the rendering systems), it is relatively easy to get what and where needs to be added/rendered in any of the systems. Because the behavior is custom, I decided to add a Flame component called Focused Surface Component, through which only the border of the focused object is rendered (and possibly handle various custom effects like hover, gestures, etc.).

The obvious downside is a certain detachment of the object from rendering its "effects." On the other hand, this allows for layering and more flexible management.

How it will turn out in the future is unclear, but it's interesting to see how such a separation will behave as the system becomes more complex.

But the coolest part is that it's a complex task with absolutely unpredictable results, and it's great to think about it!

Leave a comment

Log in with itch.io to leave a comment.