Weekly 1: Linehandler and Tweening

26 June 2020, Algot

Little less than a year ago, I decided to make a text editor for this game. For this, some way of converting ‘Logical’ lines (those separated by \n) to ‘Physical’ lines (Those separated by the limitation of the screen width), would be needed. This was similar logic to that already present in Console, so I decide to make one class to handle that. This became the class LineHandler. It handled cursor position, logical lines, converting those lines to physical, line numbers and scrolling.

Now, one year later I had to remake it. The reason being that the rendering system had changed. This caused problems since LineHandler was built to handle rendering itself. That was a stupid design choice from my part. There was no need for this class to be dependent on the rendering system, and it caused many bugs when trying to change it.

Now, when remaking it, I made the smarter decision to make LineHandler independent from the rendering system. Let whatever application creates it handle the rendering and just give lineHandler its size and then request its data as a string.

This has been a great improvement since LineHandler and its tests will not require any significant changes if the rest of the system changes. From this I have realized the importance of making code modular. From now on I will try to make classes, where possible, ‘stand-alone’ in a way that they could theoretically be used in a completely different project and still work well.

During this time Ecen has, among other things, been working on tweening for the colors of the text. So now you can make nice effects when typing. We also did some cleanup this week. Removing unused classes and moving some other classes to more relevant packages.