52
Video Game Development: Game Architecture A. Babadi 1 of 52 In The Name Of God Video Game Development Amin Babadi Department of Electrical and Computer Engineering Isfahan University of Technology Spring 2015 Game Architecture

06. Game Architecture

Embed Size (px)

Citation preview

Page 1: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 1 of 52

In The Name Of God

Video Game Development

Amin Babadi

Department of Electrical and Computer Engineering

Isfahan University of Technology

Spring 2015

Game Architecture

Page 2: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 2 of 52

Outline

Real-time applications

Game loop o Updating

o Rendering

Updating the player and the world

Rendering and level of detail

Game loop in networked games

Preproduction

Production

Maintenance o What is a mod?

Page 3: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 3 of 52

Real-Time Software

Video games are real-time software applications.

The arrival of input information is highly unpredictable.

The application must process and respond to the input accordingly.

This time-dependent information must then be displayed on a screen.

Page 4: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 4 of 52

An Example

Consider a software application designed to aid in air traffic control.

Internals of this system consist of o A data acquisition module,

o A display/computation module, and

o An interaction module.

Air traffic controller

Page 5: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 5 of 52

All real-time interactive applications consist of 3 tasks running concurrently.

Real-Time Loops

World Simulation

User Input Resulting State Presentation

Page 6: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 6 of 52

Game Loop

In a game, both the world simulation and the user input can be considered tasks belonging to the same global behavior, which is "updating" the world.

Updating Rendering

Page 7: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 7 of 52

Game Loop

𝑙𝑜𝑛𝑔 𝑙𝑎𝑠𝑡𝑇𝑖𝑚𝑒 = 𝐺𝑒𝑡𝑇𝑖𝑚𝑒(); 𝑤𝑕𝑖𝑙𝑒 (! 𝑒𝑛𝑑) *

𝑖𝑓 ((𝐺𝑒𝑡𝑇𝑖𝑚𝑒() − 𝑙𝑎𝑠𝑡𝑇𝑖𝑚𝑒) > 1000/𝑓𝑟𝑒𝑞𝑢𝑒𝑛𝑐𝑦)

*

𝑔𝑎𝑚𝑒_𝑙𝑜𝑔𝑖𝑐();

𝑙𝑎𝑠𝑡𝑇𝑖𝑚𝑒 = 𝐺𝑒𝑡𝑇𝑖𝑚𝑒();

+

𝑝𝑟𝑒𝑠𝑒𝑛𝑡𝑎𝑡𝑖𝑜𝑛(); +

Page 8: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 8 of 52

Game Loop

Game loop should at least be executed 25 times per second.

What if frames-per-second (FPS) rate varies?

Are there any alternatives?

Page 9: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 9 of 52

1. Updating

We can divide updating block into 2 main blocks.

Updating the Player

Updating the World

Page 10: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 10 of 52

1.1. Updating the Player

We need an updated snapshot of the player state in each frame.

Getting the Input from Player

Restricting Player Interactions

Player Update

Page 11: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 11 of 52

1.1. Updating the Player

How do the input devices work?

What factors usually restrict the player interactions?

Which step is the hardest one?

Page 12: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 12 of 52

1.1. Updating the Player

How do the input devices work? o Abstract device controllers (more in the next lectures)

What factors usually restrict the player interactions?

Which step is the hardest one?

Page 13: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 13 of 52

1.1. Updating the Player

How do the input devices work? o Abstract device controllers (more in the next lectures)

What factors usually restrict the player interactions? o Geometric and logical restrictions

Which step is the hardest one?

Page 14: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 14 of 52

1.1. Updating the Player

How do the input devices work? o Abstract device controllers (more in the next lectures)

What factors usually restrict the player interactions? o Geometric and logical restrictions

Which step is the hardest one? o Restricting player interactions is usually the hardest step.

Page 15: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 15 of 52

1.1. Updating the Player

How do the input devices work? o Abstract device controllers (more in the next lectures)

What factors usually restrict the player interactions? o Geometric and logical restrictions

Which step is the hardest one? o Restricting player interactions is usually the hardest step.

Can we apply these rules to games like Tetris?

Page 16: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 16 of 52

1.2. Updating the World

In addition to the player's action, the world keeps its own agenda.

Which one is more important? The player or the world?

How can we process the whole world?

Page 17: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 17 of 52

1.2. Updating the World

How can we subcategorize active and passive elements?

Game World Entities

Active Entities Passive Entities

Page 18: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 18 of 52

1.2. Updating the World

How can we deal with these entities?

Game World Entities

Active Entities

Logical Entities AI Entities

Passive Entities

Page 19: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 19 of 52

Passive Entities

These items play a key role in the player restriction section, but are not very important for the sake of world updating!

In games with large worlds, we can pre-select a subset of passive entities so that player restriction portion can only focus on those entities.

But the majority of time in the world update section is spent checking the other type of entities.

Page 20: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 20 of 52

Active Entities

Sort According to Relevance

Update State

Sort According to Relevance

Sense Internal State and Goals

Sense Restrictions

Decision Engine

Update State

Logical entities

AI entities

Page 21: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 21 of 52

2. Rendering

Usually any world-rendering pipeline will consist of 2 parts.

Selecting the Relevant Subset

Actual Rendering

We’ve already covered this subject in “The Rendering Pipeline” lecture.

Page 22: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 22 of 52

2.1. Selection

We only want to draw parts of the game world that are visible from the player’s viewpoint.

Sometimes level of detail (LOD) technique is used too.

What are the differences between the player character and other objects in the rendering step?

Page 23: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 23 of 52

Level of Detail (LOD)

Page 24: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 24 of 52

Getting the Input from

Player

Restricting Player

Interactions Player Update

Sort According to Relevance

Update State Sort According to Relevance

Sense Internal State and

Goals

Sense Restrictions

Decision Engine

Update State Selecting the

Relevant Subset

Actual Rendering

A Quick Overview

Page 25: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 25 of 52

Game Loop in Networked Games

So far, we’ve only focused on single-player games.

Is the described model suitable for networked games too?

How are player and non-playable characters defined in a networked game?

Page 26: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 26 of 52

Game Loop in Networked Games

The player update section must change to make sure every player update is followed by a broadcast message that sends the newly computed position to other gamers through the network.

AI section needs a special-case AI module that receives data from the communications channel and reflects it to the local gaming environment.

Page 27: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 27 of 52

The Programming Process

We will now focus on today's production techniques and how programming must be planned to ensure timely and complete delivery.

Any modern game requires hundreds or thousands of source files and several hundred thousand lines of code.

Game programming is a very complex task!

Page 28: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 28 of 52

Development Stages

All game projects consist of three basic stages.

Preproduction

Production

Maintenance

Page 29: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 29 of 52

1. Preproduction

The concept of the game is agreed upon.

Different technologies and solutions are evaluated.

Gameplay formulae are tested.

Some early concept art is created.

The result is a working prototype of the game.

The game design should be final.

Page 30: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 30 of 52

1. Preproduction

It’s the only phase where a game company should be allowed to experiment. o It is a highly experimental phase!

The role of preproduction is, then, to analyze alternatives and finally create a detailed plan. o Technology is always seen as a potential risk!

Technology prototypes usually focus more on showcasing the key elements of the gameplay. o The presentation layer is kept in a very early and crude form.

Page 31: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 31 of 52

Where Do Ideas Come From?

Most promising game projects start with a raw game design.

This is usually expressed in a single sentence that defines the genre and gameplay as well as your role in the story.

"The game is a first-person shooter, with some outdoors areas and large monsters, where you are a warrior trying to save the princess."

Page 32: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 32 of 52

Where Do Ideas Come From?

Your initial sentence must answer: o Who is the player?

o What are his goals?

o What's the genre?

o How does the game play?

Page 33: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 33 of 52

Alternative Paths

Sometimes, games start with a strong narrative description. o "You are a scientist in a military complex full of soldiers who are trying

to conquer the world.“

Another game type is started because of some unique and impressive technology. o "let's build a game with this brand new outdoors renderer.“

Starting with the gameplay is a much safer bet.

Page 34: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 34 of 52

Discussing Feature Sets

Lead programmer should at first define a list of features to be implemented into the game, e.g. o How many characters should be displayed?

o Will the user be able to pick objects?

This list should be crafted as a team effort between the design and the coding team.

A good way of getting a reasonable feature set laid out on paper is to use an expansion-contraction process.

Page 35: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 35 of 52

Expansion-Contraction Process

Create an Exhaustive List

Clustering Features

Choosing Best Features

Page 36: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 36 of 52

Minimax Method

A good, objective way to choose which clusters to implement is to use the classic minimax method.

Minimax tries to minimize disadvantages and maximize advantages.

This is usually depicted in a 2D matrix of cost versus benefit.

Page 37: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 37 of 52

Minimax Matrix

Worst Solution

Best Solution

Cost

Importance

Page 38: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 38 of 52

Minimin Features

Cost

Importance

• Mainly decorative elements • Should be coded at the very

end of the project if time allows.

• A good example is birds flying by in a 3D adventure.

Page 39: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 39 of 52

Maximin Features

Cost

Importance

• These features should be dropped immediately.

• As an example, imagine a car racing game where you can see the driver inside the car.

Page 40: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 40 of 52

Minimax Features

Cost

Importance

• Obviously, these should all be built into the game, assuming time allows for them.

• Being able to configure your character's look in a role-playing game and AI communication are two good examples.

Page 41: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 41 of 52

Maximax Features

Cost

Importance

• An outdoors renderer for a flight simulator is a good example.

• Is there an easier implementation?

• Is your team capable of handling the feature?

• Select some maximax features and forget about the rest.

Page 42: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 42 of 52

2. Production

After completing preproduction and securing funding for the game, production begins.

It’s the longest part of the process and usually takes between one and three years to complete.

Production is often divided into milestones.

Page 43: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 43 of 52

2. Production

The game takes shape following the planning that has been laid out during preproduction.

The technology prototype built during preproduction will also mutate to implement all the final features the game needs.

Production is usually where all the eye candy is put in place, and games show their full technological complexity.

Art assets are created in a factory-like fashion, game levels are crafted, and so on.

Page 44: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 44 of 52

2. Production

At the end of this iterative process, a final version of the game must be delivered to the publisher.

This process ensures that the game is virtually bug-free and also reaches the desired quality standard.

In the case of console games, this process is a bit more complex than for a PC title!

Page 45: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 45 of 52

Agile Methodology

One method employed for game development is agile development.

Page 46: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 46 of 52

Milestones Are King

More is not better!

"On time" is better than "more ambitious.“

Surgical teams and key members are a risk.

Don’t forget the order of execution!

Page 47: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 47 of 52

3. Maintenance

Games usually have a relatively short shelf life.

Support must be provided: patches, editing tools for the fan community, and additional missions.

Maintenance is the moment when relationships with consumers are at their highest point.

Games with good maintenance have longer shelf lives.

What about massively networked games?

Page 48: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 48 of 52

Some Ideas

Release new content for the game. o Extra missions or characters are easy to do.

o These contents can be placed on web sites for easy deployment.

o Remember that a good data-driven design is the key to success.

Provide users with content creation tools. o A mod community can be started.

o Content sharing should not be seen as a potential problem but as an opportunity to increase your user base.

o Many teams have hired personnel directly from the mod community because they were the most talented users of the editing toolset.

Page 49: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 49 of 52

Mod

A mod or modification is the alteration of the a video game in order to make it operate in a manner different to its original version.

An example of game modification in GTA: Vice City (2002)

Page 50: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 50 of 52

Maintenance of Massively Multiplayer Games

Massively multiplayer games are a completely different business when it comes to maintenance (or should we say product development?!).

These games are actually created in the maintenance phase!

Because they are pay-per-play titles, keeping new content pouring in is the best (and only) way to make the game profitable.

Page 51: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 51 of 52

There Is More Maintenance!

The maintenance phase is a great time to organize, archive, and document.

Developers forget good coding practices during lengthy crunch times.

Some maintenance time should go into revising your code, and storing and documenting the reusable modules.

There's no deadline pressure on the maintenance phase.

Page 52: 06. Game Architecture

Video Game Development: Game Architecture A. Babadi 52 of 52

References

Sanchez-Crespo’s textbook,

Wikipedia, and

Some other sources on the Internet.