Step 3: Line Breaks

If you test the application, it should look like this:


The text is blitting correctly, however there is an ugly "AAAA" where our two line breaks should be. This is because Windows uses 2 characters to indicate a line break. Carriage return, commonly known as \r in programming, it makes it jump back to the beginning of the line and then the actual line break, which goes down one line, known as \n.

So the "AAAA" you are seeing is actually "\r\n\r\n". In MMF2, we can't directly test if a character is a \r or a \n because they are displayed as invisible characters. However, because \r and \n do not appear in CharSheet (because they cannot be directly written as a single character) it means that their numeric position will not be found with the Find function, and a value of -1 is returned.

In MMF2, if you change the animation frame value to -1 it is rounded up to 1 and frame number 1 is "A". This explains the "AAAA". So, to test for a line break, we test if the ID value of a Character object is -1.
At a line break, the current character is a \r and the ID of that Character object will be -1. So, we destory the object, move the Blitter back to the X margin and then down 20 pixels. Remember each line break is actually \r\n, so we must add 1 to the CurrentPosition to skip the \n.

6