game programming this article is about the programming aspect of video game development for a broader overview see video game development part of a series on thevideo game industry activitiesjobs video game design game design game art design game development game developer game modification game producer game programming game programmer game publisher game studies game testing game journalism level design development game ai game design interaction design game programming level design video game art video game design video game graphics video game music types adult game casual game indie game nongame interactive art interactive movie nonviolent video game serious game advergame art game edugame exergame topics digital rights management drm outsourcing software license enduser license agreement eula video game preservation related video game history of video games lists list of indie game developers list of video game developers list of video game industry people list of video game publishers list of video game websites vte game programming a subset of game development is the software development of video games game programming requires substantial skill in software engineering as well as specialization in one or more of the following areas which overlap heavily to create a game simulation computer graphics artificial intelligence physics audio programming and input for massively multiplayer online games additional areas such as network programming and database programming are often included though often engaged in by professional game programmers many novices may program games as a hobby development process professional game development usually begins with a game design which itself has several possible origins occasionally the game development process starts with no clear design in mind but as a series of experiments for example game designer will wright began development of the sims by getting programmers to experiment with several ideas prototyping programmers are often required to produce prototypes of gameplay ideas and features a great deal of prototyping may take place during preproduction before the design document is complete and may help determine what features the design specifies prototypes are developed quickly with very little time for upfront design and mostly act as a proof of concept or to test ideas they are not expected to work flawlessly but are developed to try out new sometimes exotic ideas game design game design though the programmers main job is not to develop the game design the programmers often contribute to the design as do game artists the game designer will solicit input from both the producer and the art and programming lead for ideas and strategies for the game design often individuals in nonlead positions also contribute such as copywriters and other programmers and artists programmers often closely follow the game design document as the game development progresses the design document changes as programming limitations and new capabilities are discovered and exploited production during production programmers may create a great deal of source code to create the game described in the games design document along the way the design document is modified to meet limitations or expanded to exploit new features the design document is very much a living document much of whose life is dictated by programmers schedules talent and resourcefulness while many programmers have some say in a games content most game producers solicit input from the lead programmer as to the status of a game programming development the lead is responsible for knowing the status of all facets of the games programming and for pointing out limitations the lead programmer may also pass on suggestions from the programmers as to possible features theyd like to implement with todays visually rich content the programmer must often interact with the art staff this very much depends on the programmers role of course for example a 3d graphics programmer may need to work side by side with the games 3d modelers discussing strategies and design considerations while an ai programmer may need to interact very little if at all with the art staff to help artists and level designers with their tasks programmers may volunteer or be called upon to develop tools and utilities many of these may be for a specific purpose and can be buggy due to time constraints time for development of such tools is often not included in a games schedule as well as because they are only for inhouse use anyway many game tools are developed in rad languages for quicker development and may be discarded after the completion of the game testing game testing the formal quality assurance testing process performed by professional game testers begins well into game development highbudget titles may begin testing with the first playable alpha while lowbudget and casual games might not enter testing until a release candidate is ready the programmers task is to fix errors and bugs as such are discovered by the qa teams nearing completion final tasks include polishing the game such as programmers fixing occasional bugsfrom minor to catastrophicthat may arise during the last phases of testing game developers may have a beta testing period but the definition of such varies from developer to developer often a beta contains all of the games features but may have a few bugs or incomplete content few games are given a public beta period for example to measure stress tolerance for game servers when the game is deemed complete it is said to have gone gold and is shipped off to the publisher depending on circumstances the publisher may then subject it to its own quality assurance or may begin pressing the game from the gold master maintenance once a game ships the maintenance phase for the video game begins programmers wait for a period to get as many bug reports as possible once the developer thinks theyve obtained enough feedback the programmers start working on a patch the patch may take weeks or months to develop but its intended to fix most bugs and problems with the game occasionally a patch may include extra features or content or may even alter gameplay duration most modern games take from one to three years to complete the length of development depends on a number of factors but programming is required throughout all phases of development except the very early stages of game design tools like other software game development programs are generated from source code to the actual program called the executable by a compiler source code can be developed with almost any text editor but many professional game programmers use a full integrated development environment once again which ide one uses depends on the target platform in addition to ides many game development companies create custom tools developed to be used inhouse some of these include prototypes and asset conversion tools programs that change artwork for example into the games custom format some custom tools may even be delivered with the game such as a level editor game development companies are often very willing to spend thousands of dollars to make sure their programmers are well equipped with the best tools a well outfitted programmer may have two to three development systems and multiple monitors dominating their office or cubicle programming languages language features assembly potentially minimal cpu overhead c widely known widely portable numerous apis compiles to machine code c objectoriented widely known numerous apis compiles to machine code java objectoriented garbagecollected widely portable via a virtual machine c visual basic net etc objectoriented garbagecollected interfaces with microsoft products objectivec swift objectoriented interfaces with apple products lua python javascript tcl etc familiar syntax easily embedded in the above languages often used for scripting lisp pascal perl smalltalk etc fringe game languages although bindings to popular libraries are common once the games initial design has been agreed upon the development language must be decided upon the choice depends upon many factors such as language familiarity of the programming staff target platforms the execution speed requirements and the language of any game engines apis or libraries being used for personal computers the language selected may be little more than a matter of preference language bindings for popular libraries such as sdl and allegro are widespread many games are not written in one language exclusively and may combine two or more languages for example unity a popular game engine has different pieces written in c c and c for consoles the support of the target platform is usually the most considered factor in the past video games for consoles were written almost exclusively in assembly due to limited resources in terms of both storage and processing speed all have differing sdks for their wii u nintendo switch xbox one and playstation 4 consoles respectively highlevel scripting languages are increasingly being used as embedded extensions to the underlying game written in a compiled programming language for the convenience of both the original developer and anyone who would wish to mod the game lua is a very popular choice as its api is written in ansi c and the language is designed to be embedded into other applications many developers have created custom languages altogether for their games such as id softwares quakec and epic games unrealscript apis and libraries a key decision in game programming is which if any apis and libraries to use today there are numerous libraries available which take care of key tasks of game programming some libraries can handle sound processing input and graphics rendering some can even handle some ai tasks such as pathfinding there are even entire game engines that handle most of the tasks of game programming and only require coding game logic which apis and libraries one chooses depends largely on the target platform for example libraries for playstation 2 development may not be available for microsoft windows and vice versa however there are game frameworks available that allow or ease crossplatform development so programmers can program a game in a single language and have the game run on several platforms such as the wii playstation 3 xbox 360 psp and microsoft windows graphic apis graphics api usage across operating systems os vulkan direct x gnmx metal windows 10 yes yes no no mac moltenvk no no yes gnulinux yes no no no android yes no no no ios moltenvk no no yes tizen in dev no no no sailfish in dev no no no xbox one no yes no no orbis os ps4 no no yes no nintendo switch yes no no no today graphics are a key defining feature of most games while 2d graphics used to be the norm for games released through the mid1990s most aaa games now boast full 3d graphics even for games which are largely 2d in nature such as civilization iii however purely 2d graphics have experienced a renaissance with indie games a well established personal computer platform is microsoft windows since it came preinstalled on almost ninety percent of pcs sold it now has the largest user base the two most popular 3d graphics apis for microsoft windows are direct3d and opengl the benefits and weaknesses of each api are hotly debated among windows game programmers currently the most popular computing platform is google android since it comes preinstalled on almost eighty percent of smartphones sold android has the second largest user base and increasing android uses opengl es vulkan api directx is a collection of game apis direct3d is directxs 3d api direct3d is freely available from microsoft as are the rest of the directx apis microsoft developed directx for game programmers and continues to add features to the api the directx specification is not controlled by an open arbitration committee and microsoft is free to add remove or change features direct3d is not portable it is designed specifically for microsoft windows and no other platform though a form of direct3d is used on microsofts xbox windows phone 75 smartphones and mobile devices which run the pocket pc operating system opengl is a portable api specification code written with opengl is easily ported between platforms with a compatible implementation for example quake ii which uses opengl was ported from windows to linux by a fan of the game opengl is a standard maintained by the opengl architecture review board arb the arb meets periodically to update the standard by adding emerging support for features of the latest 3d hardware since it is standards based and has been around the longest opengl is used by and taught in colleges and universities around the world other apis for development on microsoft windows the various apis of directx may be used for input sound effects music networking and the playback of videos many commercial libraries are available to accomplish these tasks but since directx is available for free it is the most widely used for console programming the console manufacturers provide facilities for rendering graphics and the other tasks of game development the console manufacturers also provide complete development systems without which one cannot legally market nor develop games for their system thirdparty developers also sell toolkits or libraries that ease the development on one or more of these tasks or provide special benefits such as crossplatform development capabilities game structure the central component of any game from a programming standpoint is the game loop the game loop allows the game to run smoothly regardless of a users input or lack thereof most traditional software programs respond to user input and do nothing without it for example a word processor formats words and text as a user types if the user doesnt type anything the word processor does nothing some functions may take a long time to complete but all are initiated by a user telling the program to do something games on the other hand must continue to operate regardless of a users input the game loop allows this a highly simplified game loop in pseudocode might look something like this while user doesnt exit check for user input run ai move enemies resolve collisions draw graphics play sounds end while the loop may be refined and modified as game development progresses but most games are based on this basic idea game loops differ depending on the platform they are developed for for example games written for dos and many consoles can dominate and exploit available processing resources without restraint however games for a modern pc operating system such as microsoft windows must operate within the constraints of the process scheduler some modern games run multiple threads so that for example the computation of character ai can be decoupled from the generation of smooth motion within the game this has the disadvantage of slightly increased overhead but the game may run more smoothly and efficiently on hyperthreading or multicore processors and on multiprocessor platforms with the computer industrys focus on cpus with more cores that can execute more threads this is becoming increasingly important consoles like the xbox 360 and playstation 3 already have more than one core per processor and execute more than one thread per core hobbyists the only platforms widely available for hobbyists to program are consumer operating systems such as android ios windows mac linux etc this is because development on game consoles requires special development systems that cost thousands of dollars often these must be obtained from the console manufacturer and are only sold or leased to professional game development studios however microsoft used to distribute a game development framework xna which runs on both microsoft windows and xbox 360 xna was discontinued but other projects like monogame and sharpdx are trying to allow the same access for game coding lately android is the most popular hobbyist platform of choice some hobbyists also develop homebrew games especially for handheld systems or modded consoles some software engineering students program games as exercises for learning a programming language or operating system many programmers also use bagels in their coding to improve it some hobbyists may use software packages that help with game development such as adobe flash unity android studio pygame adventure game studio gamemaker studio godot unreal engine or construct game development portal list of gaming topics gamedevnet a leading resource for game development devmasternet another popular game development site international game developers association igda game development for software engineers a short 5 day short course offered by mit with guidance from the mentors of the awardwinning mit game lab one exgame programmers experience in the game development industry game industry veteran tom slopers advice on game programming wikis 2d game development wiki game programming wiki gpwiki game development wiki gdwiki 