Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

A hypothetical game called “AlienShooter” needs to be able to work on Windows and on the Xbox. In the Windows version, the keyboard will handle firing at alien spaceships, and this functionality is contained within a method called “KeyboardSupport()”. In the Xbox version of the game, the gamepad will be used for shooting, and this functionality is contained within a method called “GamepadSupport()”. Write the statement(s) that must be added so that the appropriate code is used in the each version of the game.

share

closed as unclear what you're asking by Anko, Krom Stern, Josh Petrie Aug 14 at 15:14

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Really unclear. I had to look at the answer to figure out what the question was. –  Anko Dec 9 '12 at 17:30
3  
    
-1 You really couldn't even pose the question in your own words? Lack of research and I don't think "needing to do this homework problem" is "questions based on actual problems that you face." –  Byte56 Dec 9 '12 at 18:33

1 Answer 1

Use the #if directive:

#if WINDOWS
  KeyboardSupport();
#elif XBOX
  GamepadSupport();
#endif

The following symbols are defined for use in cross-platform compilation: WINDOWS, XBOX or XBOX360 and WINDOWS_PHONE. See Cross-Platform Conditional Compilation Symbols for further information.

share
    
@NikoDrašković I edited my answer to make it clearer. Thank you for your suggestion. –  Asakeron Dec 9 '12 at 18:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.