#summary Development notes on game engine quirks
#labels Phase-Implementation
<wiki:toc max_depth="2" />
= Introduction =

This Wiki is probably only going to be of use to developers... 


== Toggling the Debug Layer ==
_In FoFiX's main menu_, pressing *ALT + D* will toggle the Debug Layer on and off.  This layer provides real-time information on the inner workings of FoFiX, and could be of use to some advanced developers.

This should be togglable anywhere; except that further layers of menus and UIs have their own keyListeners and the ALT-D doesn't seem to make it all the way out to the FretsOnFire.py code.  It does, however, work during gameplay (if you are not using "D" for any gameplay key) - you can toggle the debug layer on and off while playing the game.

Although this is probably simple to fix (passing ALT-Ds back to the main keyListener, for example), it is not necessary... toggle it on in the Main Menu and then go play and watch it.  Restart the game or exit out to the main menu if you've seen enough.


== Image and Text Positioning ==
In the FoFiX game engine, images are positioned (anchored) by their exact center, by exact pixel coordinates.  These are typically scaled using relative values between 0.0 and 1.0.  Width and height have separate scales; an image positioned at (0.5, 0.5) will be _exactly_ centered in the viewport.

Text is positioned (anchored) by it's upper left corner, with a small margin.  

One quirk of this; fonts are positioned by relative coordinates between 0.0 and 1.0.  However, the scale is EQUAL for both width and height of the screen, and depends only on the aspect ratio.  
Examples using our current 4:3 aspect ratio viewport:
 * Font position (x, y) = (0.0, 0.0) will write text starting in the upper left corner of the screen.
 * Font position (x, y) = (1.0, 0.0) will attempt to write text starting in the upper *RIGHT* corner of the screen, and no text will be visible as it starts at the right edge and continues right.
 * Font position (x, y) = (0.0, 0.75) will attempt to write text starting at the *LOWER* left corner of the screen, which will not be visible due to the text displaying down and to the right of it's given position.
 * Font position (x, y) = (1.0, 0.75) will attempt to write text starting at the *LOWER RIGHT* corner of the screen, and no text will be visible as it starts at both the right AND bottom edges and continues down and right.

Nickman has created a handy tool to help represent this quirk visually; run his program and move the mouse around the screen to see the FoFiX text coordinates of the cursor location: [http://www.mediafire.com/file/d1yn05inrjn/FoFiX_SH.zip Download Skin Helper application], or [http://www.fretsonfire.net/forums/viewtopic.php?f=11&t=25040&p=345683#p345700 Take a look at the Skin Helper source].

_Please keep in mind that this does not directly apply to all theme.ini positioning settings - several of these user-accessible font coordinates represent a more centered position of the text for a more user-friendly theming interface.  This section represents the inner workings of the FoFiX font / image rendering engine.  However, the whole thing about 0.75 being the max font vertical position still applies to theme creators._

_This text Y positioning quirk seems like it may have been fixed in PyGame 1.8.1 - which is not being used for FoFiX yet, but is still good to know about._

== How the neck is drawn ==
_The following are my scribblings that allowed me to figure out how to scroll incoming guitar solo necks towards you (click for full-size):_

[http://i34.tinypic.com/jimexs.jpg http://i36.tinypic.com/10dw2hj.jpg]