how the same video game is coded for different platforms

421 views

how the same video game is coded for different platforms

In: 8

8 Answers

Anonymous 0 Comments

Our codebase uses a programming concept called “abstraction.” Say you wanted to read the state of the various buttons on a controller. The actual code needed will differ based on whether the controller is an Xbox controller or a Playstation controller or a Switch joycon, etc. So we built a library of generic controller functions (e.g. our code uses labels like “Button1” which is the primary button – A on Xbox and Cross on PS).

An implementation of these functions is written for each platform we support; we’ll write a version for Xbox controllers that calls Xbox API functions and another version for PS controllers that calls the Playstation API functions and each version will be it’s own code file (something like ControllerInputXbox.cpp and ControllerInputPS5.cpp).

Our project is set up so that each platform target uses a different implementation code file for our generic functions. This means that, from the perspective of the code that wants to check the state of the controller, it only needs to ask what the state is for “Button1” and it will get the correct answer because it was compiled to translate “Button1” into the appropriate controller button for the platform.

Now apply this concept to other platform-specific parts of the game, such as graphics, audio, and file systems, and you can write the vast majority of your code to be platform independent with only a relatively small amount platform-specific code hidden behind such generic functions.

Hope that makes sense!

You are viewing 1 out of 8 answers, click here to view all answers.