Figured out my mistake void processSpecialKeys(int key, int xx, int yy)
I had x there earlier, it was changing that rather than the global x variable.
I miss Objective C now.