1 / 231

Game Programming

Game Programming. Introduction. Programmers create games But many great programmers not great game makers With budget shift, emphasis has shifted Game content creators are artist and designers Programmers can be thought of as providing services for content

valin
Télécharger la présentation

Game Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Game Programming

  2. Introduction • Programmers create games • But many great programmers not great game makers • With budget shift, emphasis has shifted • Game content creators are artist and designers • Programmers can be thought of as providing services for content • But fate of entire game rests in their hands

  3. Game Platforms

  4. Game platform • PC • Single player • Massive multi-player online game ( MMOG ) • Web-based Games • Console ( Video game console ) • Sony PS4 • Microsoft Xbox • Nintedo GameCube • Arcade ( Coin-operated entertainment machine ) • Mobile • Game Boy Advance ( GBA ) • Handheld video game console • iPhone

  5. Game development on PC • Designed for office application • Not for entertainment • A virtual memory system • Unlimited memory using • But video memory is limited • PCI/AGP might be a challenge • Open architecture • Compatibility test is important • Development is easy to setup

  6. Game development on console • Specific hardware designed for games • Single user / single process OS • In general no hard disk drive (??) • Closed system • Very native coding way • Proprietary SDK • Hardware related features • Limited resources • Memory

  7. Sony Playstation Chips • EE: Emotion Engine • GS: Graphics Synthesizer • IOP: Input / Output Processor • SPU: Sound Processing Unit

  8. Emotion Engine Components • MIPS R5000 core • VU0 & VU1: Vector Units • GIF: Graphics Interface • DMAC: DMA Controller • IPU: Image Processing Unit • SIF: Serial Interface • INTC: Interrupt Controller • DRAMC: DRAM Controller • TIMER: 4 timers

  9. Emotion Engine

  10. EE Core • 300 MHz MIPS R5000 CPU • Single floating point multiply/add unit, plus concurrent divider • 128 bit integer ALU • 16K instruction cache, 8K data cache • 16K scratchpad cache • Bus interface • MMU: Memory Management Unit • Core can use VU0 as a vector coprocessor

  11. Vector Units • 2 units: VU0 & VU1 (both are on the EE chip) • Each unit has 32 128 bit vector registers • VU0 has 4 floating point multiply/add units capable of producing a total of 8 results per clock cycle • VU0 also has 1 concurrent divide unit capable of producing 1 result every 7 clock cycles • VU1 has 5 MUL/ADDs and 2 dividers • Each VU has a 16 bit integer control processor that runs concurrently and runs control microprograms • VU0 has 4K code & 4K data memory • VU1 has 16K code & 16K data memory • VU0 can also run as a coprocessor to the main core • VIF: Vector Interface. Used for unpacking data (positions, colors, normals) sent into the VU’s. • Single precision floating point, non IEEE754 compliant

  12. GS: Graphics Synthesizer • 16 parallel pixel units, 8 if using texture mapping • 4M of on-chip VRAM (video memory) • Performs triangle filling computations • Features: • Texture mapping • Gouraud shading • Z-Buffer • Very simple alpha computations

  13. PS2 Processing Summary • CPU core runs main application program. Most AI, physics, game logic, happen on the core. • CPU core can use VU0 as a coprocessor. This allows the CPU to handle more complex physics and geometric computations efficiently. • VU1 runs as an independent processor and acts primarily as a ‘geometry engine’ for computing transformations and lighting for rendering. VU1 has a direct bus to the GS. • GS handles all pixel processing (Z-Buffer, texture mapping, Gouraud shading) and generates the actual video signal • SPU does audio DSP computations and generates the final audio signal • IOP reads input devices and manages DVD drive • DMAC manages and schedules data movement

  14. Three Kinds of Code • Gameplay Simulation • Numeric Computation • Shading

  15. Gameplay Simulation • Models the state of the game world as interacting objects evolve over time • High-level, object-oriented code • Written in C++ or scripting language • Imperative programming style • Usually garbage-collected

  16. Gameplay Simulation – The Numbers • 30-60 updates (frames) per second • ~1000 distinct gameplay classes • Contain imperative state • Contain member functions • Highly dynamic • ~10,000 active gameplay objects • Each time a gameplay object is updated, it typically touches 5-10 other objects

  17. Numeric Computation • Algorithms: • Scene graph traversal • Physics simulation • Collision Detection • Path Finding • Sound Propagation • Low-level, high-performance code • Written in C++ with SIMD intrinsics • Essentially functional • Transforms a small input data set to a small output data set, making use of large constant data structures.

  18. Shading • Generates pixel and vertex attributes • Written in HLSL/CG shading language • Runs on the GPU • Inherently data-parallel • Control flow is statically known • “Embarassingly Parallel” • Current GPU’s are 16-wide to 48-wide!

  19. Three Kinds of Code

  20. Game types RPG (Role playing games) AVG (Adventure games) RTS (Real-time strategy games) FPS (First-person shooting games) MMORPG ( Massively multiplayer online role playing game ) Strategy game Simulation game Sports Puzzle games Table games

  21. Game team members • Development Team • Producers • Executive producers • Game designers • Programmers • Artists • Level designers • Sound engineers • Sales and marketing • Testers • Game review committee

  22. Flowchart of game development Basic Procedures for Game Development Idea Proposal Production Integration Testing Debug Tuning Pre-alpha Concept Approval Prototype Alpha Beta Final > Concept Approval > Prototype > Pre-alpha > Alpha > Beta • Idea • Proposal • Production • Integration • Testing • Debug • Tuning

  23. Game Tools

  24. Code Development Tools • Compilers (C#, Java, CodeWarrior, GNU) • Debugger • Profiler • Editor • Revision control (CVS, SourceSafe) • Integrated development environment (IDE) • C++, Assembly • Graphics languages: pixel & vertex shaders… • Design analysis tools • Documentation, standards

  25. C++ (1 of 3) • Mid-late 1990’s, C was language of choice • Since then, C++ language of choice for games • First commercial release in 1985 (AT&T) • List pros (+) and cons (-) + C Heritage • Learning curve easier • Compilers wicked fast + Performance • Used to be most important, but less so (but still for core parts) • Maps closely to hardware (can “guess” what assembly instructions will be) • Can not use features to avoid cost, if want (ie- virtual function have extra step but don’t have to use) • Memory management controlled by user

  26. C++ (2 of 3) + High-level • Classes (objects), polymorphism, templates, exceptions • Especially important as code-bases enlarge • Strongly-typed (helps reduce errors) • ex: declare before use, and const + Libraries • C++ middleware readily available • OpenGL, DirectX, Standard Template Library (containers, like “vectors”, and algorithms, like “sort”)

  27. C++ (3 of 3) - Too Low-level • Still force programmer to deal with low-level issues • ex: memory management, pointers - Too complicated • Years of expertise required to master (other languages seek to overcome, like Java and C#) - Lacking features • No built-in way to look at object instances • No built-in way to serialize • Forces programmer to build such functionality (or learn custom or 3rd party library) - Slow iteration • Brittle, hard to try new things • Code change can take a looong time as can compile

  28. Java (1 of 3) • Java popular, and recently so for games • Invented in 1990 by Sun Microsystems + Concepts from C++ (objects, classes) • Powerful abstractions + Cleaner language • Memory management built-in • Templates not as messy • Object functions, such as virtualization + Code portability (JVM) (Hey, draw picture) + Libraries with full-functionality built-in

  29. Java (2 of 3) - Performance • Interpreted, garbage collection, security • So take 4x to 10x hit + Can overcome with JIT compiler, Java Native Interface (not interpreted) - Platforms • JVM, yeah, but not all games (most PC games not, nor consoles) + Strong for browser-games, mobile

  30. Java (3 of 3) • Used in: • Downloadable/Casual games • PopCap games • Mummy Maze, Seven Seas, Diamond Mine • Yahoo online games (WorldWinner) • Poker, Blackjack • PC • Star Wars Galaxies uses Java (and simplified Java for scripting language) • You Don’t Know Jack and Who Wants to be a Millionaire all Java

  31. Scripting Languages (1 of 3) • Not compiled, rather specify (script) sequence of actions • Most games rely upon some • Trigger a few events, control cinematic • Others games may use it lots more • Control game logic and behavior (Game Maker has GML) + Ease of development • Low-level things taken care of • Fewer errors by programmer - But script errors tougher, often debuggers worse • Less technical programming required • Still, most scripting done by programmers • Iteration time faster (don’t need to re-compile all code) • Can be customized for game (ex: just AI tasks)

  32. Scripting Languages (2 of 3) + Code as an asset • Ex: consider Peon in C++, with behavior in C++, maybe art as an asset. Script would allow for behavior to be an asset also • Can be easily modified, even by end-user in “mod” - Performance • Parsed and executed “on the fly” • Hit could be 10x or more over C++ • Less efficient use of instructions, memory management -Tool support • Not as many debuggers, IDEs • Errors harder to catch - Interface with rest of game • Core in C++, must “export” interface • Can be limiting way interact • (Hey, draw picture)

  33. Scripting Languages (3 of 3) • Python • Interpreted, OO, many libraries, many tools • Quite large (bad when memory constrained) • Ex: Blade of Darkness, Earth and Beyond, Eve Online, Civilization 4 (Table 3.2.1 full list) • Lua (pronounced: Loo-ah) • Not OO, but small (memory). Embed in other programs. Doesn’t scale well. • Ex: Grim Fandango, Baldur’s Gate, Far Cry (Table 3.2.2 full list) • Others: • Ruby, Perl, JavaScript • Custom: GML, QuakeC, UnrealScript • Implementing own tough, often performs poorly so careful!

  34. Macromedia Flash (1 of 2) • More of a platform and IDE (ala Game Maker) than a language (still, has ActionScript) • “Flash” refers authoring environment, the player, or the application files • Released 1997, popular with Browser bundles by 2000 • Advantages • Wide audience (nearly all platforms have Flash player) • Easy deployment (embed in Web page) • Rapid development (small learning curve, for both artists and programmers) • Disadvantages • 3D games • Performance (interpreted, etc.)

  35. Macromedia Flash (2 of 2) • Timeline Based • Frames and Frame rate (like animations) • Programmers indicate when (time) event occurs (can occur across many frames) • Vector Engine • Lines, vertices, circles • Can be scaled to any size, still looks crisp • Scripting • ActionScript similar to JavaScript • Classes (as of Flash v2.0) • Backend connectivity (load other Movies, URLs)

  36. Game Development Tools for Artists • 3D tools • Discrete 3dsMax • Maya • Softimage XSI • 2D tools • Photoshop • Illustrator • Motion tools • Motion capture devices • Motion Builder • FiLMBOX

  37. Audio Tools • Recording • Composing (ProTools) • Sound effects (Reason) • In-game tools

  38. Example Game

  39. Gears of War • Resources • ~10 programmers • ~20 artists • ~24 month development cycle • ~$10M budget • Software Dependencies • 1 middleware game engine • ~20 middleware libraries • OS graphics APIs, sound, input, etc

  40. Software Dependencies Gears of War Gameplay Code~250,000 lines C++, script code … Unreal Engine 3 Middleware Game Engine ~250,000 lines C++ code DirectX Graphics OpenAL Audio OggVorbis Music Codec Speex SpeechCodec wxWidgets Window Library ZLib Data Compr- ession

  41. What are the hard problems? • Performance • When updating 10,000 objects at 60 FPS, everything is performance-sensitive • Modularity • Very important with ~10-20 middleware libraries per game • Reliability • Error-prone language / type system leads to wasted effort finding trivial bugs • Significantly impacts productivity • Concurrency • Hardware supports 6-8 threads

  42. 2D game

  43. Snake (1970s) Control a snake to move, and avoid hitting to wall or its growing tail.

  44. Galaxian (1979 by Namco)

  45. Pac Man 1980 by Namco

  46. Game & Watch 1980 Game & Watch is a line of handheld electronic games produced by Nintendo from 1980 to 1991. Ball: the first game & watch game

  47. Tetris Design by 阿列克謝·帕基特諾夫 (Алексей Леонидович Пажитнов)in 1984 Puzzle game

  48. Super Mario World. 1990 Rich color, Parallax scrolling, zoom and rotate sprite.

  49. Doom 1993 A landmark 1993 first-person shooter (FPS)video game by id Software.

  50. Social game Happy Farm

More Related