This is the “running text” that I’m talking about:
I’m inefficiently implementing that running text for a few hours, and I am starting to get discouraged of refactoring the code. I bloated it up, and I know I made it completely unreadable.
When I think of the running text, I came up with using just 4 variables in the beginning. 1 that remembers the beginning of a sentence, and the other 2 remembers the end of each line, where the dialog has 2 lines of sentences that can be used. For the text drawing, I need to use a Graphics object obtained from BufferStrategy, in order to draw the custom fonts that I have packaged into my JAR file.
For example, “Happening” and “tomorrow” are two words in one sentence.
Using lots of if…else conditional checks, I managed to have it line wrap if it can’t fit in one line. But just that feature alone made me implement a lot of variables. So, I thought there might be a better way of efficiently implementing this.
'Twas just 4 variables, now it’s like 10 of them. And I feel as if I’m doing something that I don’t know how to explain.
Here’s the code, using Pastebin: http://pastebin.java-gaming.org/acdd63b9b8c
How do you optimize? And if possible, can anyone provide tips on efficient ways of implementing the running text?
Thanks in advance.