Game programming
Encyclopedia
Game programming, a subset of game development
, is the programming of computer, console
or arcade games. Though often engaged in by professional game programmer
s, many novices may program games as a hobby
. Some software engineer
ing students program games as exercises for learning a programming language
or operating system
.
, which itself has several possible origins. Occasionally the game development process starts with no clear design in mind, but as a series of experimentations. For example, game designer Will Wright began development of The Sims
—the best-selling PC game of all time—by getting programmers to experiment with several ideas.
Prototypes are developed quickly with very little time for up-front design and mostly act as a proof of concept or to test ideas.
and the art and programming lead
for ideas and strategies for the game design. Often individuals in non-lead 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.
to create the game described in the game's 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 programmer's schedules, talent and resourcefulness.
While many programmers have some say in a game's content, most game producer
s 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 game's programming and for pointing out limitations. The lead programmer may also pass on suggestions from the programmers as to possible features they'd like to implement.
With today's visually rich content, the programmer must often interact with the art staff. This very much depends on the programmer's role, of course. For example, a 3D graphics programmer may need to work side by side with the game's 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 ad-hoc and buggy due to time constraints (time for development of such tools is often not included in a game's schedule) as well as because they are only for in-house use anyway. Many game tools are developed in RAD
languages for quicker development and may be discarded after the completion of the game.
testing process, performed by professional game testers, begins well into game development. High-budget titles may begin testing with the first playable alpha, while low-budget 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.
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 game's 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 server
s.
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.
. The patch may take weeks or months to develop, but it's intended to fix most bugs and problems with the game. Occasionally a patch may include extra features or content or may even alter gameplay.
to the actual program (called the executable) by a compiler
. Source code can be generated by almost any text editor
, but most professional game programmers use a full Integrated Development Environment
(IDE). Once again, which IDE one uses depends on the target platform. Popular ones for Xbox and Windows development are Microsoft Visual Studio
and CodeWarrior
.
In addition to IDEs, many game development companies create custom tools
developed to be used in-house. Some of these include prototypes and asset conversion tools (programs that change artwork, for example, into the game's 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 dominating his office or cubicle.
Once the game's 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 (such as PlayStation
or Microsoft Windows
), the execution speed requirements and the language of any game engine
s, APIs
or libraries being used.
Today, because it is object oriented
and compiles to binary (the native language of the target platform), the most popular game development language is C++
. However, Java
and C
are also popular, but inappropriate for some projects. Assembly language
is necessary for some video game console
programming and in some routines that need to be as fast as possible, or require very little overhead. Fringe languages such as C#, Ada and Python
have had little impact upon the industry and are primarily used by hobbyists familiar with the languages, though C# is popular for developing game development tool
s.
High-level
scripting language
s are increasingly being used as embedded extensions to the underlying game written in a low
or mid-level programming language such as C++. Many developers have created custom languages for their games, such as id Software
's QuakeC
and Epic Games
' UnrealScript
. Others have chosen existing ones like Lua
and Python in order to avoid the difficulties of creating a language from scratch and teaching other programmers a proprietary language.
Vertex and pixel shaders
are increasingly used in game development as programmable GPU
s have become more prevalent. This has led to the increasing use of High Level Shader Language
s in game programming, such as nVidia
's Cg, though it cannot be used for all of game logic.
s 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 engine
s 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 are not available for Microsoft Windows
and vice-versa. However, there are game frameworks available that allow or ease cross-platform 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
, Xbox
, PSP
and Microsoft Windows.
used to be the norm for games released through the mid-1990s, most games now boast full 3D graphics
. This is true even for games which are largely 2D in nature, such as Civilization III
.
The most popular personal computer
target platform is Microsoft Windows. Since it comes pre-installed on almost ninety percent of PCs
sold, it has an extremely large 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 programmer
s. Both are natively supported on most modern 3D hardware for the PC.
DirectX is a collection of game APIs. Direct3D
is DirectX's 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 Microsoft's Xbox
and portable devices which run the Pocket PC
operating system). The DirectX API is updated far more often than OpenGL implementations. As a result, new features of the latest 3D cards are included in the API much faster than with OpenGL.
OpenGL is a portable API specification. Code written with OpenGL is easily ported between platforms with a compatible implementation. Quake II
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 college
s and universities
around the world. In addition, the development tools provided by the manufacturers of some video game consoles (such as the Nintendo GameCube, the Nintendo DS, and the PSP) use graphic APIs that resemble OpenGL. OpenGL often lags behind on feature updates due to the lack of a permanent development team and the requirement that implementations begin development after the standard has been published. Programmers who choose to use it can access some hardware's latest 3D features, but only through non-standardized extensions. The situation may change in the future as the OpenGL architecture review board (ARB) has passed control of the specification to the Khronos Group
in an attempt to counter the problem.
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 manufacturer
s 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. Third-party developers also sell toolkits or libraries that ease the development on one or more of these tasks or provide special benefits, such as cross-platform development capabilities.
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 doesn't 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 user's input. The game loop allows this. A highly simplified game loop, in pseudocode
, might look something like this:
The game 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 most consoles can dominate and exploit available processing resources without restraint. However, game 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 hyper-threading
or multicore
processors and on multiprocessor platforms. With the computer industry's 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.
s. 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 distributes a game development framework, XNA
, which runs on both Microsoft Windows and Xbox 360. Games written for Windows often can be ported to Xbox with few changes. This allows individuals and small teams to develop games for consoles. Some hobbyists also develop homebrew games
, especially for handheld systems or obsolete consoles.
Game development
Game development is the software development process by which a video game is developed. Development is undertaken by a game developer, which may range from a single person to a large business. Mainstream games are normally funded by a publisher and take several years to develop. Indie games can...
, is the programming of computer, console
Console game
A console game is a form of interactive multimedia used for entertainment. The game consists of manipulable images generated by a video game console, and displayed on a television or similar audio-video system. The game itself is usually controlled and manipulated using a handheld device connected...
or arcade games. Though often engaged in by professional game programmer
Game programmer
A game programmer is a software engineer, programmer, or computer scientist who primarily develops codebase for video games or related software, such as game development tools. Game programming has many specialized disciplines all of which fall under the umbrella term of "game programmer"...
s, many novices may program games as a hobby
Hobby
A hobby is a regular activity or interest that is undertaken for pleasure, typically done during one's leisure time.- Etymology :A hobby horse is a wooden or wickerwork toy made to be ridden just like a real horse...
. Some software engineer
Software engineer
A software engineer is an engineer who applies the principles of software engineering to the design, development, testing, and evaluation of the software and systems that make computers or anything containing software, such as computer chips, work.- Overview :...
ing students program games as exercises for learning a programming language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....
or operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...
.
Development process
Professional game development usually begins with a game designGame design
Game design, a subset of game development, is the process of designing the content and rules of a game in the pre-production stage and design of gameplay, environment, storyline, and characters during production stage. The term is also used to describe both the game design embodied in a game as...
, which itself has several possible origins. Occasionally the game development process starts with no clear design in mind, but as a series of experimentations. For example, game designer Will Wright began development of The Sims
The Sims
The Sims is a strategic life-simulation computer game developed by Maxis and published by Electronic Arts. Its development was led by game designer Will Wright, also known for developing SimCity...
—the best-selling PC game of all time—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 pre-production, before the design document is complete, and may help determine what features the design specifies.Prototypes are developed quickly with very little time for up-front design and mostly act as a proof of concept or to test ideas.
Game design
Though the programmer's 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 producerGame producer
A video game producer is the person in charge of overseeing development of a video game.The earliest documented use of the term producer in games was by Trip Hawkins, who established the position when he founded Electronic Arts in 1982...
and the art and programming lead
Lead programmer
A lead programmer is a software engineer in charge of one or more software projects. Alternative titles include Development Lead, Technical Lead, Senior Software Engineer, Software Design Engineer Lead , Software Manager, or Senior Applications Developer...
for ideas and strategies for the game design. Often individuals in non-lead positions also contribute, such as copywriters and other programmers and artists.
Programmers often closely follow the game design document
Game design document
A game design document is a highly descriptive living design document of the game design for a video game. A GDD is created and edited by the developer team and it is primarily used in the video game industry to organize efforts within a developer team...
. As the game development progresses, the design document changes as programming limitations and new capabilities are discovered and exploited.
Production
During production, programmers churn out a great deal of source codeSource code
In computer science, source code is text written using the format and syntax of the programming language that it is being written in. Such a language is specially designed to facilitate the work of computer programmers, who specify the actions to be performed by a computer mostly by writing source...
to create the game described in the game's 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 programmer's schedules, talent and resourcefulness.
While many programmers have some say in a game's content, most game producer
Game producer
A video game producer is the person in charge of overseeing development of a video game.The earliest documented use of the term producer in games was by Trip Hawkins, who established the position when he founded Electronic Arts in 1982...
s solicit input from the lead programmer
Lead programmer
A lead programmer is a software engineer in charge of one or more software projects. Alternative titles include Development Lead, Technical Lead, Senior Software Engineer, Software Design Engineer Lead , Software Manager, or Senior Applications Developer...
as to the status of a game programming development. The lead is responsible for knowing the status of all facets of the game's programming and for pointing out limitations. The lead programmer may also pass on suggestions from the programmers as to possible features they'd like to implement.
With today's visually rich content, the programmer must often interact with the art staff. This very much depends on the programmer's role, of course. For example, a 3D graphics programmer may need to work side by side with the game's 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
Game development tool
A game development tool is a specialized software application that assists or facilitates the making of a computer or video game. Some tasks handled by tools include the conversion of assets into formats required by the game, level editing and script compilation.Almost all game development tools...
. Many of these may be ad-hoc and buggy due to time constraints (time for development of such tools is often not included in a game's schedule) as well as because they are only for in-house use anyway. Many game tools are developed in RAD
Rapid application development
Rapid application development is a software development methodology that uses minimal planning in favor of rapid prototyping. The "planning" of software developed using RAD is interleaved with writing the software itself...
languages for quicker development and may be discarded after the completion of the game.
Testing
The formal quality assuranceQuality Assurance
Quality assurance, or QA for short, is the systematic monitoring and evaluation of the various aspects of a project, service or facility to maximize the probability that minimum standards of quality are being attained by the production process...
testing process, performed by professional game testers, begins well into game development. High-budget titles may begin testing with the first playable alpha, while low-budget 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 bugs—from minor to catastrophic—that 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 game's 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 server
Server (computing)
In the context of client-server architecture, a server is a computer program running to serve the requests of other programs, the "clients". Thus, the "server" performs some computational task on behalf of "clients"...
s.
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 they've obtained enough feedback, the programmers start working on a patchPatch (computing)
A patch is a piece of software designed to fix problems with, or update a computer program or its supporting data. This includes fixing security vulnerabilities and other bugs, and improving the usability or performance...
. The patch may take weeks or months to develop, but it's 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
Game development programs are generated from source codeSource code
In computer science, source code is text written using the format and syntax of the programming language that it is being written in. Such a language is specially designed to facilitate the work of computer programmers, who specify the actions to be performed by a computer mostly by writing source...
to the actual program (called the executable) by a compiler
Compiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...
. Source code can be generated by almost any text editor
Text editor
A text editor is a type of program used for editing plain text files.Text editors are often provided with operating systems or software development packages, and can be used to change configuration files and programming language source code....
, but most professional game programmers use a full Integrated Development Environment
Integrated development environment
An integrated development environment is a software application that provides comprehensive facilities to computer programmers for software development...
(IDE). Once again, which IDE one uses depends on the target platform. Popular ones for Xbox and Windows development are Microsoft Visual Studio
Microsoft Visual Studio
Microsoft Visual Studio is an integrated development environment from Microsoft. It is used to develop console and graphical user interface applications along with Windows Forms applications, web sites, web applications, and web services in both native code together with managed code for all...
and CodeWarrior
CodeWarrior
CodeWarrior is an integrated development environment for the creation of software that runs on a number of embedded systems. Prior to the acquisition of the product by Freescale Semiconductor, versions existed for Macintosh, Microsoft Windows, Linux, Solaris, PlayStation 2, Nintendo GameCube,...
.
In addition to IDEs, many game development companies create custom tools
Game development tool
A game development tool is a specialized software application that assists or facilitates the making of a computer or video game. Some tasks handled by tools include the conversion of assets into formats required by the game, level editing and script compilation.Almost all game development tools...
developed to be used in-house. Some of these include prototypes and asset conversion tools (programs that change artwork, for example, into the game's custom format). Some custom tools may even be delivered with the game, such as a level editor
Level editor
A level editor is a software tool used to design levels, maps, campaigns, etc and virtual worlds for a video game. In some cases the creator of a video game releases an official level editor for a game, but other times the community of fans step in to fill the void...
.
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 dominating his office or cubicle.
Programming languages
Language | Strengths | Weaknesses |
---|---|---|
Assembly Assembly language An assembly language is a low-level programming language for computers, microprocessors, microcontrollers, and other programmable devices. It implements a symbolic representation of the machine codes and other constants needed to program a given CPU architecture... |
Low overhead | Error-prone, slow development, difficult for novices, not portable |
BASIC BASIC BASIC is a family of general-purpose, high-level programming languages whose design philosophy emphasizes ease of use - the name is an acronym from Beginner's All-purpose Symbolic Instruction Code.... |
Great for beginners, easy to find/fix bugs | Not the most flexible language |
C C (programming language) C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system.... |
Widely known, numerous tools | No built-in OO Object-oriented programming Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,... support, difficult for large projects or multiple platforms. |
C++ C++ C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell... |
Built-in OO support, widely used, numerous tools | No protection from memory leak Memory leak A memory leak, in computer science , occurs when a computer program consumes memory but is unable to release it back to the operating system. In object-oriented programming, a memory leak happens when an object is stored in memory but cannot be accessed by the running code... s |
C# | Very OO, RAD language Rapid application development Rapid application development is a software development methodology that uses minimal planning in favor of rapid prototyping. The "planning" of software developed using RAD is interleaved with writing the software itself... , easy to use |
High memory usage |
Java Java (programming language) Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities... |
Very OO, easy to use, portable | Not generally available on game consoles |
Eiffel Eiffel (programming language) Eiffel is an ISO-standardized, object-oriented programming language designed by Bertrand Meyer and Eiffel Software. The design of the language is closely connected with the Eiffel programming method... , Smalltalk Smalltalk Smalltalk is an object-oriented, dynamically typed, reflective programming language. Smalltalk was created as the language to underpin the "new world" of computing exemplified by "human–computer symbiosis." It was designed and created in part for educational use, more so for constructionist... , Ada Ada (programming language) Ada is a structured, statically typed, imperative, wide-spectrum, and object-oriented high-level computer programming language, extended from Pascal and other languages... , etc. |
Fringe game languages, few game development tools | |
Scripting languages like Lua, Python Python (programming language) Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive... , etc. |
Often used for gameplay scripting, but not for the bulk of the game code itself |
Once the game's 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 (such as PlayStation
PlayStation
The is a 32-bit fifth-generation video game console first released by Sony Computer Entertainment in Japan on December 3, .The PlayStation was the first of the PlayStation series of consoles and handheld game devices. The PlayStation 2 was the console's successor in 2000...
or Microsoft Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...
), the execution speed requirements and the language of any game engine
Game engine
A game engine is a system designed for the creation and development of video games. There are many game engines that are designed to work on video game consoles and personal computers...
s, APIs
Application programming interface
An application programming interface is a source code based specification intended to be used as an interface by software components to communicate with each other...
or libraries being used.
Today, because it is object oriented
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...
and compiles to binary (the native language of the target platform), the most popular game development language is C++
C++
C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...
. However, Java
Java (programming language)
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...
and C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....
are also popular, but inappropriate for some projects. Assembly language
Assembly language
An assembly language is a low-level programming language for computers, microprocessors, microcontrollers, and other programmable devices. It implements a symbolic representation of the machine codes and other constants needed to program a given CPU architecture...
is necessary for some video game console
Video game console
A video game console is an interactive entertainment computer or customized computer system that produces a video display signal which can be used with a display device to display a video game...
programming and in some routines that need to be as fast as possible, or require very little overhead. Fringe languages such as C#, Ada and Python
Python (programming language)
Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...
have had little impact upon the industry and are primarily used by hobbyists familiar with the languages, though C# is popular for developing game development tool
Game development tool
A game development tool is a specialized software application that assists or facilitates the making of a computer or video game. Some tasks handled by tools include the conversion of assets into formats required by the game, level editing and script compilation.Almost all game development tools...
s.
High-level
High-level programming language
A high-level programming language is a programming language with strong abstraction from the details of the computer. In comparison to low-level programming languages, it may use natural language elements, be easier to use, or be from the specification of the program, making the process of...
scripting language
Scripting language
A scripting language, script language, or extension language is a programming language that allows control of one or more applications. "Scripts" are distinct from the core code of the application, as they are usually written in a different language and are often created or at least modified by the...
s are increasingly being used as embedded extensions to the underlying game written in a low
Low-level programming language
In computer science, a low-level programming language is a programming language that provides little or no abstraction from a computer's instruction set architecture. Generally this refers to either machine code or assembly language...
or mid-level programming language such as C++. Many developers have created custom languages for their games, such as id Software
Id Software
Id Software is an American video game development company with its headquarters in Richardson, Texas. The company was founded in 1991 by four members of the computer company Softdisk: programmers John Carmack and John Romero, game designer Tom Hall, and artist Adrian Carmack...
's QuakeC
QuakeC
QuakeC is an interpreted language developed in 1996 by John Carmack of id Software to program parts of the computer game Quake. Using QuakeC, a programmer is able to customize Quake to great extents by adding weapons, changing game logic and physics, and programming complex scenarios...
and Epic Games
Epic Games
Epic Games, Inc., also known as Epic and formerly Epic MegaGames, is an American video game development company based in Cary, North Carolina. Its most recent success has been the Gears of War series of games, although it is also known for its Unreal Engine technology. It is the parent company of...
' UnrealScript
UnrealScript
UnrealScript is the scripting language of the Unreal Engine and is used for authoring game code and gameplay events....
. Others have chosen existing ones like Lua
Lua programming language
Lua is a lightweight multi-paradigm programming language designed as a scripting language with extensible semantics as a primary goal. Lua has a relatively simple C API compared to other scripting languages.- History :...
and Python in order to avoid the difficulties of creating a language from scratch and teaching other programmers a proprietary language.
Vertex and pixel shaders
Shader
In the field of computer graphics, a shader is a computer program that is used primarily to calculate rendering effects on graphics hardware with a high degree of flexibility...
are increasingly used in game development as programmable GPU
Graphics processing unit
A graphics processing unit or GPU is a specialized circuit designed to rapidly manipulate and alter memory in such a way so as to accelerate the building of images in a frame buffer intended for output to a display...
s have become more prevalent. This has led to the increasing use of High Level Shader Language
High Level Shader Language
The High Level Shader Language or High Level Shading Language is a proprietary shading language developed by Microsoft for use with the Microsoft Direct3D API. It is analogous to the GLSL shading language used with the OpenGL standard...
s in game programming, such as nVidia
NVIDIA
Nvidia is an American global technology company based in Santa Clara, California. Nvidia is best known for its graphics processors . Nvidia and chief rival AMD Graphics Techonologies have dominated the high performance GPU market, pushing other manufacturers to smaller, niche roles...
's Cg, though it cannot be used for all of game logic.
APIs and libraries
A key decision in game programming is which, if any, APIApplication programming interface
An application programming interface is a source code based specification intended to be used as an interface by software components to communicate with each other...
s and libraries
Library (computer science)
In computer science, a library is a collection of resources used to develop software. These may include pre-written code and subroutines, classes, values or type specifications....
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
Artificial intelligence
Artificial intelligence is the intelligence of machines and the branch of computer science that aims to create it. AI textbooks define the field as "the study and design of intelligent agents" where an intelligent agent is a system that perceives its environment and takes actions that maximize its...
tasks such as pathfinding
Pathfinding
Pathfinding generally refers to the plotting, by a computer application, of the shortest route between two points. It is a more practical variant on solving mazes...
. There are even entire game engine
Game engine
A game engine is a system designed for the creation and development of video games. There are many game engines that are designed to work on video game consoles and personal computers...
s 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
PlayStation 2
The PlayStation 2 is a sixth-generation video game console manufactured by Sony as part of the PlayStation series. Its development was announced in March 1999 and it was first released on March 4, 2000, in Japan...
development are not available for Microsoft Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...
and vice-versa. However, there are game frameworks available that allow or ease cross-platform development, so programmers can program a game in a single language and have the game run on several platforms, such as the Wii
Wii
The Wii is a home video game console released by Nintendo on November 19, 2006. As a seventh-generation console, the Wii primarily competes with Microsoft's Xbox 360 and Sony's PlayStation 3. Nintendo states that its console targets a broader demographic than that of the two others...
, PlayStation 3, Xbox 360
Xbox 360
The Xbox 360 is the second video game console produced by Microsoft and the successor to the Xbox. The Xbox 360 competes with Sony's PlayStation 3 and Nintendo's Wii as part of the seventh generation of video game consoles...
, Xbox
Xbox
The Xbox is a sixth-generation video game console manufactured by Microsoft. It was released on November 15, 2001 in North America, February 22, 2002 in Japan, and March 14, 2002 in Australia and Europe and is the predecessor to the Xbox 360. It was Microsoft's first foray into the gaming console...
, PSP
PlayStation Portable
The is a handheld game console manufactured and marketed by Sony Corporation Development of the console was announced during E3 2003, and it was unveiled on , 2004, at a Sony press conference before E3 2004...
and Microsoft Windows.
Graphic APIs
Today, graphics are a key defining feature of most games. While 2D graphics2D computer graphics
2D computer graphics is the computer-based generation of digital images—mostly from two-dimensional models and by techniques specific to them...
used to be the norm for games released through the mid-1990s, most games now boast full 3D graphics
3D computer graphics
3D computer graphics are graphics that use a three-dimensional representation of geometric data that is stored in the computer for the purposes of performing calculations and rendering 2D images...
. This is true even for games which are largely 2D in nature, such as Civilization III
Civilization III
Sid Meier's Civilization III, commonly shortened to Civ III or Civ 3, is the third installment of the Sid Meier's Civilization turn-based strategy computer game series. It was preceded by Civilization II and followed by Civilization IV. The game offers very sophisticated gameplay in terms of both...
.
The most popular personal computer
Personal computer
A personal computer is any general-purpose computer whose size, capabilities, and original sales price make it useful for individuals, and which is intended to be operated directly by an end-user with no intervening computer operator...
target platform is Microsoft Windows. Since it comes pre-installed on almost ninety percent of PCs
IBM PC compatible
IBM PC compatible computers are those generally similar to the original IBM PC, XT, and AT. Such computers used to be referred to as PC clones, or IBM clones since they almost exactly duplicated all the significant features of the PC architecture, facilitated by various manufacturers' ability to...
sold, it has an extremely large user base. The two most popular 3D graphics APIs for Microsoft Windows are Direct3D
Direct3D
Direct3D is part of Microsoft's DirectX application programming interface . Direct3D is available for Microsoft Windows operating systems , and for other platforms through the open source software Wine. It is the base for the graphics API on the Xbox and Xbox 360 console systems...
and OpenGL
OpenGL
OpenGL is a standard specification defining a cross-language, cross-platform API for writing applications that produce 2D and 3D computer graphics. The interface consists of over 250 different function calls which can be used to draw complex three-dimensional scenes from simple primitives. OpenGL...
. The benefits and weaknesses of each API are hotly debated among Windows game programmer
Game programmer
A game programmer is a software engineer, programmer, or computer scientist who primarily develops codebase for video games or related software, such as game development tools. Game programming has many specialized disciplines all of which fall under the umbrella term of "game programmer"...
s. Both are natively supported on most modern 3D hardware for the PC.
DirectX is a collection of game APIs. Direct3D
Direct3D
Direct3D is part of Microsoft's DirectX application programming interface . Direct3D is available for Microsoft Windows operating systems , and for other platforms through the open source software Wine. It is the base for the graphics API on the Xbox and Xbox 360 console systems...
is DirectX's 3D API. Direct3D is freely available from Microsoft
Microsoft
Microsoft Corporation is an American public multinational corporation headquartered in Redmond, Washington, USA that develops, manufactures, licenses, and supports a wide range of products and services predominantly related to computing through its various product divisions...
, 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 Microsoft's Xbox
Xbox
The Xbox is a sixth-generation video game console manufactured by Microsoft. It was released on November 15, 2001 in North America, February 22, 2002 in Japan, and March 14, 2002 in Australia and Europe and is the predecessor to the Xbox 360. It was Microsoft's first foray into the gaming console...
and portable devices which run the Pocket PC
Pocket PC
A Pocket PC is also known by Microsoft as a 'Windows Mobile Classic device'. It is a hardware specification for a handheld-sized computer, personal digital assistant , that runs the Microsoft 'Windows Mobile Classic' operating system...
operating system). The DirectX API is updated far more often than OpenGL implementations. As a result, new features of the latest 3D cards are included in the API much faster than with OpenGL.
OpenGL is a portable API specification. Code written with OpenGL is easily ported between platforms with a compatible implementation. Quake II
Quake II
Quake II, released on December 9, 1997, is a first-person shooter computer game developed by Id Software and distributed by Activision. It is not a sequel to Quake; it merely uses the name of the former game due to Id's difficulties in coming up with alternative names.The soundtrack for Quake II...
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 college
College
A college is an educational institution or a constituent part of an educational institution. Usage varies in English-speaking nations...
s and universities
University
A university is an institution of higher education and research, which grants academic degrees in a variety of subjects. A university is an organisation that provides both undergraduate education and postgraduate education...
around the world. In addition, the development tools provided by the manufacturers of some video game consoles (such as the Nintendo GameCube, the Nintendo DS, and the PSP) use graphic APIs that resemble OpenGL. OpenGL often lags behind on feature updates due to the lack of a permanent development team and the requirement that implementations begin development after the standard has been published. Programmers who choose to use it can access some hardware's latest 3D features, but only through non-standardized extensions. The situation may change in the future as the OpenGL architecture review board (ARB) has passed control of the specification to the Khronos Group
Khronos Group
The Khronos Group is a not-for-profit member-funded industry consortium based in Beaverton, Oregon, focused on the creation of open standard, royalty-free APIs to enable the authoring and accelerated playback of dynamic media on a wide variety of platforms and devices...
in an attempt to counter the problem.
Other APIs
For development on Microsoft Windows, the various APIs of DirectX may be used for input, sound effects, music, networkingComputer network
A computer network, often simply referred to as a network, is a collection of hardware components and computers interconnected by communication channels that allow sharing of resources and information....
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 manufacturer
Console manufacturer
A console manufacturer is a company that manufactures and distributes video game consoles. It is also known as a first-party video game publisher...
s 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. Third-party developers also sell toolkits or libraries that ease the development on one or more of these tasks or provide special benefits, such as cross-platform 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 user's input or lack thereof.Most traditional software programs respond to user input and do nothing without it. For example, a word processor
Word processor
A word processor is a computer application used for the production of any sort of printable material....
formats words and text as a user types. If the user doesn't 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 user's input. The game loop allows this. A highly simplified game loop, in pseudocode
Pseudocode
In computer science and numerical computation, pseudocode is a compact and informal high-level description of the operating principle of a computer program or other algorithm. It uses the structural conventions of a programming language, but is intended for human reading rather than machine reading...
, might look something like this:
while( user doesn't exit )
check for user input
run AI
move enemies
resolve collisions
draw graphics
play sounds
end while
The game 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
MS-DOS
MS-DOS is an operating system for x86-based personal computers. It was the most commonly used member of the DOS family of operating systems, and was the main operating system for IBM PC compatible personal computers during the 1980s to the mid 1990s, until it was gradually superseded by operating...
and most consoles can dominate and exploit available processing resources without restraint. However, game 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 hyper-threading
Hyper-threading
Hyper-threading is Intel's term for its simultaneous multithreading implementation in its Atom, Intel Core i3/i5/i7, Itanium, Pentium 4 and Xeon CPUs....
or multicore
Multi-core (computing)
A multi-core processor is a single computing component with two or more independent actual processors , which are the units that read and execute program instructions...
processors and on multiprocessor platforms. With the computer industry's focus on CPUs with more cores that can execute more threads, this is becoming increasingly important. Consoles like the Xbox 360
Xbox 360
The Xbox 360 is the second video game console produced by Microsoft and the successor to the Xbox. The Xbox 360 competes with Sony's PlayStation 3 and Nintendo's Wii as part of the seventh generation of video game consoles...
and PlayStation 3
PlayStation 3
The is the third home video game console produced by Sony Computer Entertainment and the successor to the PlayStation 2 as part of the PlayStation series. The PlayStation 3 competes with Microsoft's Xbox 360 and Nintendo's Wii as part of the seventh generation of video game consoles...
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 systemOperating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...
s. 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 distributes a game development framework, XNA
Microsoft XNA
Microsoft XNA is a set of tools with a managed runtime environment provided by Microsoft that facilitates video game development and management. XNA attempts to free game developers from writing "repetitive boilerplate code" and to bring different aspects of game production into a single system...
, which runs on both Microsoft Windows and Xbox 360. Games written for Windows often can be ported to Xbox with few changes. This allows individuals and small teams to develop games for consoles. Some hobbyists also develop homebrew games
Homebrew (video games)
Homebrew is a term frequently applied to video games or other software produced by consumers to target proprietary hardware platforms not typically user-programmable or that use proprietary storage methods...
, especially for handheld systems or obsolete consoles.
External links
- GameDev.net, a leading resource for game development
- DevMaster.net, another popular game development site
- International Game Developers Association (IGDA)
- One ex-game programmer's experience in the game development industry
- Game industry veteran Tom Sloper's advice on game programming