Video game programming

Last updated

Game programming, a subset of game development, is the software development of video games. Game programming requires substantial skill in software engineering and computer programming in a given language, as well as specialization in one or more of the following areas: simulation, computer graphics, artificial intelligence, physics, audio programming, and input. For multiplayer games, knowledge of network programming is required (the resultant code, in addition to its performance characteristics, is commonly referred to as the game's netcode by players and programmers alike). In some genres, e.g. fighting games, advanced network programming is often demanded, as the netcode and its properties (e.g. latency) are considered by players and critics to be some of the most important metrics of the game's quality. For massively multiplayer online games (MMOGs), even further knowledge of database programming and advanced networking programming are required. Though often engaged in by professional game programmers, there is a thriving scene of independent developers who lack a relationship with a publishing company.

Contents

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 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. They are not expected to work flawlessly, but are developed to try out new, sometimes exotic, 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 producer 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.

Production

During production, programmers may create a great deal of source code 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 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 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. [1] [2] 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 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

The formal quality assurance 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. [3]

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 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 they've obtained enough feedback, the programmers start working on a patch. 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

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 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 and multiple monitors dominating their office or cubicle.

Programming languages

LanguageFeatures
Assembly Potentially minimal CPU overhead
C Widely known, widely portable, numerous APIs, compiles to machine code
C++ Object-oriented, widely known, numerous APIs, compiles to machine code
Java Object-oriented, garbage-collected, widely portable (via a virtual machine)
C#, Visual Basic .NET, etc.Object-oriented, garbage-collected, interfaces with Microsoft products
Objective-C, Swift Object-oriented, 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 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, 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, [4] [5] and the performance gap between idiomatic code written in modern compiled languages is negligible. [6] [7] The most popular languages are usually procedural or object-oriented and implemented via compilers; for example, C, [8] C++, [8] [9] and Java. [10] However, developers may take into account domain-specific features, such as interfacing with the operating system, and resilience to reverse engineering for online video games. [11] 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#. [12]

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. [13] However, as technology has advanced, so have the options for game development on consoles. Nintendo, [14] Microsoft, and Sony [15] all have differing SDKs for their Wii U, Nintendo Switch, Xbox One, and PlayStation 4 consoles, respectively.

High-level 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. [9] [16] Many developers have created custom languages altogether for their games, such as id Software's 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 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, PSP and Microsoft Windows.

Graphic APIs

Graphics API usage across Operating Systems:
OS Vulkan Direct X GNMX Metal
Windows 10yesyesnono
Mac MoltenVK nonoyes
Linuxyesnonono
Androidyesyesyesno
iOS MoltenVK yesyesyes
Tizenin Devnonono
Sailfishin Devnonono
Xbox Onenoyesnono
Orbis OS (PS4)nonoyesno
Nintendo Switchyesnonono

Today, graphics are a key defining feature of most games. While 2D graphics used to be the norm for games released through the mid-1990s, 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. [17]

A well established personal computer platform is Microsoft Windows. Since it came pre-installed on almost ninety percent of PCs sold, it now has the largest user base.[ citation needed ] 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 pre-installed 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 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, Windows Phone 7.5 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.[ citation needed ] 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. [18]

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. 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 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 :

while (user does not 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. [19]

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 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.

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 for mobile developers. [20] 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.

Some hobbyists may use software packages that help with game development, such as Adobe Animate, Unity, Android Studio, pygame, Adventure Game Studio, Roblox Studio, GameMaker Studio, Godot, Unreal Engine, Pixel Game Maker MV, or Construct.


See also

Related Research Articles

<span class="mw-page-title-main">Blitz BASIC</span>

Blitz BASIC is the programming language dialect of the first Blitz compilers, devised by New Zealand-based developer Mark Sibly. Being derived from BASIC, Blitz syntax was designed to be easy to pick up for beginners first learning to program. The languages are game-programming oriented but are often found general purpose enough to be used for most types of application. The Blitz language evolved as new products were released, with recent incarnations offering support for more advanced programming techniques such as object-orientation and multithreading. This led to the languages losing their BASIC moniker in later years.

<span class="mw-page-title-main">DirectX</span> Collection of multimedia related APIs on Microsoft platforms

Microsoft DirectX is a collection of application programming interfaces (APIs) for handling tasks related to multimedia, especially game programming and video, on Microsoft platforms. Originally, the names of these APIs all began with "Direct", such as Direct3D, DirectDraw, DirectMusic, DirectPlay, DirectSound, and so forth. The name DirectX was coined as a shorthand term for all of these APIs and soon became the name of the collection. When Microsoft later set out to develop a gaming console, the X was used as the basis of the name Xbox to indicate that the console was based on DirectX technology. The X initial has been carried forward in the naming of APIs designed for the Xbox such as XInput and the Cross-platform Audio Creation Tool (XACT), while the DirectX pattern has been continued for Windows APIs such as Direct2D and DirectWrite.

<span class="mw-page-title-main">OpenGL</span> Cross-platform graphics API

OpenGL is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics. The API is typically used to interact with a graphics processing unit (GPU), to achieve hardware-accelerated rendering.

<span class="mw-page-title-main">Allegro (software library)</span> Software library for video game development

Allegro is a software library for video game development. The functionality of the library includes support for basic 2D graphics, image manipulation, text output, audio output, MIDI music, input and timers, as well as additional routines for fixed-point and floating-point matrix arithmetic, Unicode strings, file system access, file manipulation, data files, and 3D graphics. The library is written in the C programming language and designed to be used with C, C++, or Objective-C, with bindings available for Python, Lua, Scheme, D, Go, and other languages. Allegro comes with extensive documentation and many examples.

In computing, cross-platform software is computer software that is designed to work in several computing platforms. Some cross-platform software requires a separate build for each platform, but some can be directly run on any platform without special preparation, being written in an interpreted language or compiled to portable bytecode for which the interpreters or run-time packages are common or standard components of all supported platforms.

<span class="mw-page-title-main">Windows API</span> Microsofts core set of application programming interfaces on Windows

The Windows API, informally WinAPI, is Microsoft's core set of application programming interfaces (APIs) available in the Microsoft Windows operating systems. The name Windows API collectively refers to several different platform implementations that are often referred to by their own names. Almost all Windows programs interact with the Windows API. On the Windows NT line of operating systems, a small number use the Native API.

Direct3D is a graphics application programming interface (API) for Microsoft Windows. Part of DirectX, Direct3D is used to render three-dimensional graphics in applications where performance is important, such as games. Direct3D uses hardware acceleration if it is available on the graphics card, allowing for hardware acceleration of the entire 3D rendering pipeline or even only partial acceleration. Direct3D exposes the advanced graphics capabilities of 3D graphics hardware, including Z-buffering, W-buffering, stencil buffering, spatial anti-aliasing, alpha blending, color blending, mipmapping, texture blending, clipping, culling, atmospheric effects, perspective-correct texture mapping, programmable HLSL shaders and effects. Integration with other DirectX technologies enables Direct3D to deliver such features as video mapping, hardware 3D rendering in 2D overlay planes, and even sprites, providing the use of 2D and 3D graphics in interactive media ties.

Fahrenheit was an effort to create a unified high-level API for 3D computer graphics to unify Direct3D and OpenGL. It was designed primarily by Microsoft and SGI and also included work from an HP-MS joint effort.

A game programmer is a software engineer, programmer, or computer scientist who primarily develops codebases 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". A game programmer should not be confused with a game designer, who works on game design.

GameMaker is a series of cross-platform game engines created by Mark Overmars in 1999 and developed by YoYo Games since 2007. The latest iteration of GameMaker was released in 2022.

Direct3D and OpenGL are competing application programming interfaces (APIs) which can be used in applications to render 2D and 3D computer graphics. As of 2005, graphics processing units (GPUs) almost always implement one version of both of these APIs. Examples include: DirectX 9 and OpenGL 2 circa 2004; DirectX 10 and OpenGL 3 circa 2008; and most recently, DirectX 11 and OpenGL 4 circa 2011. GPUs that support more recent versions of the standards are backwards compatible with applications that use the older standards; for example, one can run older DirectX 9 games on a more recent DirectX 11-certified GPU.

<span class="mw-page-title-main">OpenGL ES</span> Subset of the OpenGL API for embedded systems

OpenGL for Embedded Systems is a subset of the OpenGL computer graphics rendering application programming interface (API) for rendering 2D and 3D computer graphics such as those used by video games, typically hardware-accelerated using a graphics processing unit (GPU). It is designed for embedded systems like smartphones, tablet computers, video game consoles and PDAs. OpenGL ES is the "most widely deployed 3D graphics API in history".

Adreno is a series of graphics processing unit (GPU) semiconductor intellectual property cores developed by Qualcomm and used in many of their SoCs.

<span class="mw-page-title-main">WebGL</span> JavaScript bindings for OpenGL in web browsers

WebGL is a JavaScript API for rendering interactive 2D and 3D graphics within any compatible web browser without the use of plug-ins. WebGL is fully integrated with other web standards, allowing GPU-accelerated usage of physics, image processing, and effects in the HTML canvas. WebGL elements can be mixed with other HTML elements and composited with other parts of the page or page background.

Game Sprockets is a collection of application programming interfaces (APIs) supporting gaming on the classic Mac OS. It consisted of four main parts, DrawSprocket, InputSprocket, SoundSprocket and NetSprocket, each providing a library of pre-rolled routines for common gaming tasks. SpeechSprocket was a relabelled version of the Speech Recognition Manager that provided speech recognition support, and QuickDraw 3D RAVE provided 3D hardware acceleration.

<span class="mw-page-title-main">Marmalade (software)</span>

Marmalade SDK was a cross-platform software development kit and game engine from Marmalade Technologies Limited that contains library files, samples, documentation and tools required to develop, test and deploy applications for mobile devices.

ANGLE is an open source, cross-platform graphics engine abstraction layer developed by Google. ANGLE translates OpenGL ES 2/3 calls to DirectX 9, 11, OpenGL or Vulkan API calls. It's a portable version of OpenGL but with limitations of OpenGL ES standard.

Stage3D is an Adobe Flash Player API for rendering interactive 3D graphics with GPU-acceleration, within Flash games and applications. Flash Player or AIR applications written in ActionScript 3 may use Stage3D to render 3D graphics, and such applications run natively on Windows, Mac OS X, Linux, Apple iOS and Google Android. Stage3D is similar in purpose and design to WebGL.

Vulkan is a low-level low-overhead, cross-platform API and open standard for 3D graphics and computing. It was originally developed as Mantle by AMD, but was later given to Khronos Group. It was intended to address the shortcomings of OpenGL, and allow developers more control over the GPU. It is designed to support a wide variety of GPUs, CPUs and operating systems, it is also designed to work with modern multi-core CPUs.

WebGPU is the working name for a potential web standard and JavaScript API for accelerated graphics and compute, aiming to provide "modern 3D graphics and computation capabilities". It is developed by the W3C GPU for the Web Community Group with engineers from Apple, Mozilla, Microsoft, Google, and others.

References

  1. Bouknight, W. Jack (September 1970). "A procedure for generation of three-dimensional half-toned computer graphics presentations". Communications of the ACM. 13 (9): 527–536. doi: 10.1145/362736.362739 . ISSN   0001-0782. S2CID   15941472.
  2. Millington, Ian (2019-03-18). AI for Games. doi:10.1201/9781351053303. ISBN   9781351053303. S2CID   186504701.
  3. Schubotz, Moritz (2016-12-12). "Cogex: A logic prover for question answering". Datasakura.
  4. "SDL Language Bindings" . Retrieved 2015-11-08.
  5. "Allegro - Language bindings" . Retrieved 2015-11-08.
  6. Corlan, Alexandru-Dan (2003). "Programming language benchmarks" . Retrieved 2015-11-08.
  7. Corlan, Alexandru-Dan (2011-06-11). "Programming Languages Benchmarks" . Retrieved 2015-11-08.
  8. 1 2 Corlan, Alexandru-Dan (2011). "Game Programming in C and C++" . Retrieved 2015-11-08.
  9. 1 2 DeLoura, Mark (2009-03-05). "The Engine Survey: General results" . Retrieved 2015-11-08.
  10. Corlan, Alexandru-Dan. "LWJGL - Projects". Archived from the original on 2015-11-10. Retrieved 2015-11-08.
  11. 'No Bugs' Hare (30 November 2015). "Chapter V(b) from "Development&Deployment of MMOG"".
  12. Corlan, Alexandru (2011). "Game Programming in C and C++". Datasakura.
  13. Hyde, Randy (1985). Using 6502 Assembly Language.
  14. Helgason, David (November 2, 2012). "Game developers, start your Unity 3D engines". GamesBeat (Interview). Interviewed by Dean Takahashi. VentureBeat . Retrieved July 13, 2014.
  15. "[Phoronix] Why Sony Is Using LLVM/Clang On The PlayStation 4". Phoronix.com. Retrieved 17 November 2014.
  16. Corlan, Alexandru-Dan (2015-03-24). "Lua: Uses". Archived from the original on 2019-07-24. Retrieved 2015-11-08.
  17. "Why Are Most Indie Games 2D Instead of 3D?". Rampant Games. 2013-05-16. Retrieved 2017-01-01.
  18. "Khronos Places OpenGL and OpenGL ES Conformance Tests into Open Source". Khronos Group Press Release. Archived from the original on 2008-05-03.
  19. Stutz, Michael (2001). Programming Linux Games, Chapter 1 . ISBN   1-886411-48-4.
  20. "Report: 79% Of Mobile Developers Prefer To Build For Android". 29 August 2016.

Wikis