Top Banner
Game Programming Game Programming (Game Architecture) (Game Architecture) 2006. Spring
30

Game Programming (Game Architecture)

Dec 30, 2015

Download

Documents

colleen-gentry

Game Programming (Game Architecture). 2006. Spring. Real-Time Software. Video games Real-time software applications Data acquisition and response must be performed under time-constrained conditions The internal of the system A data acquisition module (ex. Physical radar) - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Game Programming (Game Architecture)

Game ProgrammingGame Programming(Game Architecture)(Game Architecture)

Game ProgrammingGame Programming(Game Architecture)(Game Architecture)

2006. Spring

Page 2: Game Programming (Game Architecture)

Real-Time Software

■ Video games Real-time software applications

• Data acquisition and response must be performed under time-constrained conditions

The internal of the system• A data acquisition module (ex. Physical radar)• A display/computation module (ex. Help Ground

personnel visualize data)• An interaction module (ex. To send signals to planes)

Page 3: Game Programming (Game Architecture)

Real-Time Software

■ Games Time dependent interactive application

• Virtual world simulator Feeds real-time data (Part I)

• Presentation module Displays it (Part II)

• Control mechanisms Allow the player to interact with the world

Game programming is about trying to defy that limit and creating something beyond the platform’s capabilities

Page 4: Game Programming (Game Architecture)

Real-Time Loops

■ All real-time interactive application Three takes running concurrently

• The state of the world must be constantly recomputed• The operator must be allowed to interact with it• The resulting state must be presented to the player

Using onscreen data, audio, and any other output device available

Two portions• An update and a render routine• Both run simultaneously

In an ideal world parallel processors Most Computers

− Single processor with limited memory and speed

Page 5: Game Programming (Game Architecture)

Real-Time Loops

■ Coupled Approach Implement both routine in a loop Each update is followed by a render call (equal importance) Problem

• Performance variation Frame-per-second(FPS) rate varies

due to system performance The render and update sections in sync makes c

oding complex− Update fixed frequency− Render variant frequency

Coupled Approach

Page 6: Game Programming (Game Architecture)

Real-Time Loops

■ One solution Update and render would be in a loop But, the granularity of the update portion would depend on

the H/W speed• Valid solution, but worthless

Decision making is a complex process

■ Twin-threaded approach One thread executes the rendering portion while the other

take care of the world updating

Twin-thread Approach

Page 7: Game Programming (Game Architecture)

Real-Time Loops

Ex) game render 60 fps, AI update 15 fps• Only one of every 4 frames will carry out an AI update

More frames means nothing − All the frame in an AI cycle look exactly the same

• Solution AIs are broken down two sections

− Real AI code : fixed time step− Simpler routine such as animation interpolation and traj

ectory update routine : a per–frame basis

The idea is very good but does not implement well on some H/W platform

Page 8: Game Programming (Game Architecture)

Real-Time Loops

■ Single thread fully decoupled Decouple the render from the update routine

• Render is called as often as possible• Update is synchronized with time

Storing a time stamp for update call

Better control than thread and simpler programming

Poor man’s thread Approach

long timelastcall=timeGetTime();while (!end) { if ((timeGetTime()-timelastcall) > 1000/frequency) { game_logic(); timelastcall=timeGetTime(); } presentation();}

Page 9: Game Programming (Game Architecture)

The Game Architecture

■ Game FrameworkThe Game Logic Section (Update)• Updating the player• Updating the world• Updating the nonplaying characters (NPCs)

The Presentation Section (Render)• Rendering the game world• Rendering NPCs• Rendering the player

Page 10: Game Programming (Game Architecture)

The Game Logic Section

■ Player Update Player input module

• Interaction requests by the player must be checked for• Control mechanism (Ch. 5)

Joysticks, keyboards, mics, … Use abstract device controller

− The game code does not actually interact with the physical controller

Player restriction routine (the hardest of the three)• Restrictions to player interaction• Ex) collision detection(Ch. 21), logical restrictions

Player update routine• Player see the result of their interactions

noninteractive behavior is common in games

Page 11: Game Programming (Game Architecture)

The Game Logic Section

■ World UpdateGame world entities

• Passive elements Items that belong to the world game but do not have an attached behavior Ex) walls, scenario items

• Active elements Those that have an embedded behaviors Logic based elements

− Ex) doors, elevators, or moving platforms, decorative elements (flying birds)

AI based elements− Ex) enemies

Page 12: Game Programming (Game Architecture)

The Game Logic Section

■ The processing of updating active elements1. Sort according to relevance

• A filter will select those elements that are relevant to the gameplay

• Ex) LOD (Level of Detail)

2. The state of the active elements must be updated

• Logical entities Execute control mechanism Update state

• Intelligent entities Goals and current state must be analyzed Restrictions must be sensed A decision/plan making engine must be implemented that effectivel

y generates behavior rules Update the world state accordingly

(flight simulator)(obtaining pos, heading, state of the weapon systems, damage)

(avoiding collision)

(chase the player, blow it up)

(store data the enemy moved,or eliminate it from the DB if it was shot down)

Page 13: Game Programming (Game Architecture)

The Game Logic Section

Game logic

Player updateSense player inputCompute restrictionsUpdate player state

World updatePassive elements

Pre-select active zone for engine useLogic-based elements

Sort according to relevanceExecute control mechanismUpdate state

AI Based elementsSort according to relevanceSense internal state and goalsSense restrictionsDecision engineUpdate world state

End

Page 14: Game Programming (Game Architecture)

The Presentation Section

■ World Rendering Render visually and sonically the game world Focus on the passive elements(ex. wall, ground) and simple l

ogical-based devices(ex. opening door) of the world World rendering pipeline

• Selecting the relevant subset• Taking care of the actual rendering

Page 15: Game Programming (Game Architecture)

The Presentation Section

■ World Rendering Graphics pipeline

• Reduce to the visual part Clipping, culling and computing occlusions

• Assigned a suitable LOD (option) Ex) 500m tree (10,000 triangles) occupy single pixel ??

• Geometry packing• Packed geometry is sent to the Graphics H/W

Actual paint it on screen Audio rendering

• Filtering Can’t just filter what is visible and what is not. Using some distance versus volume metric

• Attenuation can be computed • Sending the audio files to the sound card

Page 16: Game Programming (Game Architecture)

The Presentation Section

■ NPC RenderingNeed specific pipeline due to their animation properties Filtering the character lists (more expensive)

• Visibility step• Use an LOD pass (option)

Animation routine must be computed• From key framed to skeletal animations and so on

Static geometry data that represents the current snapshot of how the character must look for a given frame

Packed using an efficient representation Sent to the H/W for display

Page 17: Game Programming (Game Architecture)

The Presentation Section

■ The Player Nothing but a very special case NPC Rendering pipeline is simpler

• The player is generally visible No need to check him for visibility

• No need for LOD processing Use high resolution meshes

Player Rendering Pipeline• Animation step (High quality)• Packing• Render step

Page 18: Game Programming (Game Architecture)

The Presentation Section

Game presentationWorld presentation

Select visible subset (graphics) Clip

Cull Occlude(Select resolution)Pack geometryRender world geometry

Select audible sound sources (sound)Pack audio dataSend to audio Hardware

NPC presentationSelect visible subset(Select resolution)AnimatePackRender NPC data

Player presentationAnimatePackRender NPC data

End

Page 19: Game Programming (Game Architecture)

Game Framework

Complete game framework

Game logic Player update

Sense player input (chap. 5) Compute restrictions (chap. 22)

Update player state World update (chap. 6-9) Passive elements (chap. 4)

Pre-select active zone for engine use Logic-based elements

Sort according to relevanceExecute control mechanismUpdate state

AI Based elementsSort according to relevanceSense internal state and goalsSense restrictionsDecision engineUpdate world state

End

Game presentation World presentation (chap. 6-14,

17-21) Select visible subset (graphics)

Clip Cull

Occlude (Select resolution) Pack geometry Render world geometry

Select audible sound sources (sound) Pack audio data Send to audio Hardware

NPC presentation (chap. 15) Select visible subset (Select resolution) Animate Pack Render NPC data Player presentation (chap. 15) Animate

Pack Render NPC data

EndEnd

Page 20: Game Programming (Game Architecture)

Networked Game Architecture

■ Networked Game (chap. 10) From another player’s standpoint, your character is really just

an NPC Some minor changes

• Player update section every player update is followed by a broadcast message that

sends the newly computed position to other gamers

• AI system A special type of AI module

− Receive data from the communications channel− Reflects it to the logical gaming environment

Page 21: Game Programming (Game Architecture)

Networked Game Architecture

Game logic Player update

Sense player input Compute restrictions Update player state Broadcast player state World update Passive elements

Pre-select active zone for engine use Logic-based elements

Sort according to relevanceExecute control mechanismUpdate state

AI Based elementsSort according to relevanceSense internal state and goalsSense restrictionsDecision engine Automatic AI module

Special-case AI module (Receive data from N/W, Reflect it to the logic)

Update world stateEnd

Page 22: Game Programming (Game Architecture)

The Programming Process

■ The stages of game project Preproduction

• Working prototype of the game Help establish workflows, test the content and technology production pipeline Help build an accurate picture of the road ahead

− Budget, milestones, team structure This demo will also used to showcase the potential of the game to customers

and publisher Production (long process: 1-3 years)

• Divide into milestones (both monthly and trimonthly) Make sure the game development at the desired speed Show the publisher the rate of the process

• After the testing process(1-3 months), the final version of the game (Gold Master) is created

• The Gold Master is sent for replication, put in nice boxes and sent to stores (about 2 weeks)

Maintenance• Support must be provided

Patches, editing tools for the fan community, additional missions• Networked games have a long, sometimes indefinite, maintenance time

Page 23: Game Programming (Game Architecture)

Preproduction

■ Preproduction: Where Do Ideas Come From? A central idea of what the gameplay will be like

• Express in a single sentence that defines the genre and gameplay as well as your role in the story

• Start with a strong narrative description• Start with some unique and impressive technology

Page 24: Game Programming (Game Architecture)

Preproduction

Single sentence• Your initial sentence must be answer

Who is the player? | What are his goals? What’s the genre? | How does the game play?

• Ex) “The game is a first-person shooter, with some outdoors area and large monsters, where you are a warrior trying to save the princess”

Narrative description• Harder to code• Ex) “Your are a scientist in a military complex full of soldiers

who are trying to conquer the world” Technology (more dangerous game type)

• The majority of your audience isn’t interested in technology Technology does not sell game or make them fun

• Ex) “Let’s build a game with this brand new outdoors renderer”

The safest bet is working from a core gameplay idea and may be some narrative elements, and discussing the best technological choice to convey the game world

Page 25: Game Programming (Game Architecture)

Preproduction

■ Discussing Feature Sets Define a list of feature to be implemented into the game Expansion-contraction process

• Getting a reasonable feature set laid out on paper• Expansion phase

Every feature to be added to the game Put all your crazy ideas on a blank sheet of paper

• Contraction phase Review the list, merging those features that are similar Ex) “poisons” and “power-ups” “items that affect the life

level”

• Review the result of the session Choose which clusters to implement

− Large clusters, small clusters, single features

Page 26: Game Programming (Game Architecture)

Preproduction

Minimax matrix• A 2D matrix of cost versus benefit• Minimize disadvantages and maximize advantages

Advantages− User-perceived value − Generality

Disadvantage− Coding size− Coding difficulty

Page 27: Game Programming (Game Architecture)

Preproduction

Minmax matrix• Minimin

Features that are not important for the player but are easy to code They should be coded at the very end of the project Ex) birds flying by in a 3D advanture

• Maximin Features that offer little or no benefit in terms of the experience but are hard t

o code They should be dropped immediately Ex) car racing game see the driver inside the car

• Minimax Features that add a lot to the player‘s experience and are simple to code They should all be built into the game Ex) RPG game configure the character’s look

• Maximax Features that define the gameplay experience and are hard to code Ex) flight simulation game an outdoor renderer A Twofold analysis must be made

− Is there an easier implementation that convert a maximax feature into a minimax feature?

− Is your team capable of handling the feature? Select some features and forget about the rest

Page 28: Game Programming (Game Architecture)

Production

■ Production: Milestones Are King With all the core gameplay in place for your game prototype do’s and don’ts list

• More is not better “Emergency personnel” to help out

− Choose people who have all the information on the project beforehand

• “On time: is better than “more ambitious” Sold per year sell at Christmas (50-60%) Try not to add new ideas to it in middle of the project

• Surgical teams and key members are a risk A key member left in the middle of the production??

• Order of execution Distinction between the core features and the accessories Useful to display the components to code and their order of executio

n in a graph

Page 29: Game Programming (Game Architecture)

Production

Production graph

Page 30: Game Programming (Game Architecture)

Maintenance

■ Maintenance The goal of maintenance must be

• to maximize the enjoyment of the product by the consumer

• To make the life cycle as long as possible Some ideas taken from successful project

• Release new content for game Extra mission or characters

• Provide users with contents creation tools Make sure they are suitable for end users

− Using editor must be an enjoyable experience Ex) The Sims tools to allow user-creation contents

• MMOG Keep a living community with ongoing activities

A great time to organize, archive, and document