The exact opposite of Giygas. Oh, and the Setup menu so far.
So after redoing the Person, Fighter, and Item classes (the biggies) and also cleaning out the main Game class, we have the screenshot above. Nothing too impressive, but the windows know to move the cursor back to the top if you try to move it past the bottom.
Here's one aspect of the windows in Earthbound which made drawing the windows in Javabound much easier, but I didn't notice it at first:
It's a GRID!
Yes, in Earthbound the windows are snapped to a grid of 8-pixel squares.
In addition, the height of each window in pixels is equal to:
(the number of lines of text + 1 ) * 16
Or in Java, we can do a faster bit shift, since 16 = 2^4
(the number of lines of text + 1 ) << 4
So to make a Window in Javabound like the upper-right one in the above screenshot, I call:
new Window(12,1,19,3);
12 grid squares from the left
1 square from the top
19 squares wide
Enough room for 3 lines of text
The parameters are handled like so:
Multiply 12 by 8 (or bitshift 12 << 3) to get the top-left corner's distance from the left (96 pixels)
Do the same thing for 1 to get the top-left corner's distance from the top (8)
Same for 19, to get its width (152)
As for the 3 lines of text, (3 lines + 1) * 16 = 64 pixels, the window's height
This makes windows much easier to handle. Consider the Equip menu, where one window is positioned right up against another. Previously, I had to find the precise pixel values and draw the windows until they were lined up, in attempt to stay true to the original game.
But now, doing that is much easier.
In addition, the height of each window in pixels is equal to:
(the number of lines of text + 1 ) * 16
Or in Java, we can do a faster bit shift, since 16 = 2^4
(the number of lines of text + 1 ) << 4
So to make a Window in Javabound like the upper-right one in the above screenshot, I call:
new Window(12,1,19,3);
12 grid squares from the left
1 square from the top
19 squares wide
Enough room for 3 lines of text
The parameters are handled like so:
Multiply 12 by 8 (or bitshift 12 << 3) to get the top-left corner's distance from the left (96 pixels)
Do the same thing for 1 to get the top-left corner's distance from the top (8)
Same for 19, to get its width (152)
As for the 3 lines of text, (3 lines + 1) * 16 = 64 pixels, the window's height
This makes windows much easier to handle. Consider the Equip menu, where one window is positioned right up against another. Previously, I had to find the precise pixel values and draw the windows until they were lined up, in attempt to stay true to the original game.
But now, doing that is much easier.