11 games and content session 4.1. session overview show how games are made up of program code and...
TRANSCRIPT
Session Overview
Show how games are made up of program code and content
Find out about the content management system in XNA
Discover how content is integrated with XNA Game Studio and an XNA program
Add some content to an XNA Game Studio project
Chapter 4.1: Games and Content 2
Games and Content
The first programs were nothing but code
They simply worked with text and numbers
The increasing power of computers made them capable of manipulating images and sounds
This ability was quickly incorporated into the software development process
Users now expect programs to have graphical icons to describe the way they are used
Such assets form a huge part of the gameplay
Chapter 4.1: Games and Content 3
Content Management in XNA
Content is such an important part of games that the XNA Framework provides a set of tools to manage it These are often referred to as the “assets” of a game
Resources are managed by the XNA “Content Pipeline”
Raw resources go in at one end and appropriately formatted assets are produced for use by the game program during gameplay
When the game runs the Content Manager component of XNA it fetches content the game needs
Chapter 4.1: Games and Content 4
Assets and the Content Pipeline
The Content Pipeline is there to process game content:
1. Artists create the raw content
2. This is given an asset identifier and stored in the Content Management framework
3. The game program loads the game asset and the Content Manager provides it during gameplay
4. The assets are encoded for storage as part of the game distributable
Chapter 4.1: Games and Content 5
XNA Content Manager
All content (sound, images, etc.) is treated the same way
Filters are provided to import the content into the game program
There are also filters to encode the content for storage as part of the game distributable
As an XNA programmer, you don’t have to worry about any of this
Chapter 4.1: Games and Content 6
Displaying a Picture
We are going to display a picture of Jake
The picture was taken with a digital camera and is in the .jpg format
We will consider other formats later
I adjusted the image size to suit the XNA display (800 x 600 pixels)
Chapter 4.1: Games and Content 7
Game Content and the Visual Studio Project
Visual Studio organizes all the files that make up a program project
This includes the actual program code and also the files containing any resources that the project needs
When a program is built, content of the project is prepared for use by the program when it runs
Content that is added to an XNA game is held within the Visual Studio Project for that game
Chapter 4.1: Games and Content 8
1. Investigating an Empty Project
Chapter 4.1: Games and Content 9
Visual Studio creates and manages a number of folders which all hold parts of the game project
This includes a folder that contains the content for the game
Solutions and Projects
A project is a list of the things that are required to build that project
A solution is a list of projects that are required to build a particular program
Chapter 4.1: Games and Content 10
The Visual Studio Solution Explorer
Visual Studio provides an explorer interface that lets you see the contents of solutions and projects
The Solution Explorer is normally in the top, right- hand corner of the Visual Studio display
There is an entry here for each of the project items
Chapter 4.1: Games and Content 11
Adding Resources to an XNA Game Project
Content can be added using the Context Menu in the Solution Explorer
Visual Studio can create new content or add existing content items
Chapter 4.1: Games and Content 12
Browsing for Content Resources
You can browse for content the same way as for items in other programs
Selected resources are added to the project when you click Add
You can select multiple items by holding down the CTRL key
Chapter 4.1: Games and Content 13
Sharing a Content Resource
If you want several games to share the same resources you can add a link to a resource
In this case the resource is not copied into the solution, instead the project file contains a link to the resource item
Chapter 4.1: Games and Content 14
Added Content
When content is added the selected files are copied into the solution and the project is updated to refer to these items
Visual Studio maintains a content folder in the project which holds the content for the project
Chapter 4.1: Games and Content 15
Content Properties
Visual Studio holds property information about items it is managing
For content items, the property information includes the type of the content and where it is stored
Chapter 4.1: Games and Content 16
2. Adding an Image Resource
Chapter 4.1: Games and Content 17
It is easy to add content to a project
The content is transferred to the target system when the game project is built
What Just Happened?
When we built the project, Visual Studio used the Content Manager to fetch the image resources and add them to the files that make up the program
These resources were then sent to the target device so that the XNA game can find them when it runs
At the moment the game does not draw anything however, because we have to add the code to do this
Chapter 4.1: Games and Content 18
Summary
An application is made up of much more than just a C# program
Visual Studio uses solutions and projects to manage all the items that make up an application
XNA Game Studio provides a Content Manager to import game content and prepare it for use in games
Game content is referred to by a Visual Studio project and can be held inside the project folders or a project can link to an external resource
Chapter 4.1: Games and Content 19
True/False Revision Quiz
Games are entirely made up of program code.
Visual Studio contains a Content Manager.
Images are processed by the Content Manager when they are added to a game.
Visual Studio projects contain solutions.
Image resources are held inside the project file in a game.
A game can only contain a single image resource.
Chapter 4.1: Games and Content 20
True/False Revision Quiz
Games are entirely made up of program code.
Visual Studio contains a Content Manager.
Images are processed by the Content Manager when they are added to a game.
Visual Studio projects contain solutions.
Image resources are held inside the project file in a game.
A game can only contain a single image resource.
Chapter 4.1: Games and Content 21
True/False Revision Quiz
Games are entirely made up of program code.
Visual Studio contains a Content Manager.
Images are processed by the Content Manager when they are added to a game.
Visual Studio projects contain solutions.
Image resources are held inside the project file in a game.
A game can only contain a single image resource.
Chapter 4.1: Games and Content 22
True/False Revision Quiz
Games are entirely made up of program code.
Visual Studio contains a Content Manager.
Images are processed by the Content Manager when they are added to a game.
Visual Studio projects contain solutions.
Image resources are held inside the project file in a game.
A game can only contain a single image resource.
Chapter 4.1: Games and Content 23
True/False Revision Quiz
Games are entirely made up of program code.
Visual Studio contains a Content Manager.
Images are processed by the Content Manager when they are added to a game.
Visual Studio projects contain solutions.
Image resources are held inside the project file in a game.
A game can only contain a single image resource.
Chapter 4.1: Games and Content 24
True/False Revision Quiz
Games are entirely made up of program code.
Visual Studio contains a Content Manager.
Images are processed by the Content Manager when they are added to a game.
Visual Studio projects contain solutions.
Image resources are held inside the project file in a game.
A game can only contain a single image resource.
Chapter 4.1: Games and Content 25
True/False Revision Quiz
Games are entirely made up of program code.
Visual Studio contains a Content Manager.
Images are processed by the Content Manager when they are added to a game.
Visual Studio projects contain solutions.
Image resources are held inside the project file in a game.
A game can only contain a single image resource.
Chapter 4.1: Games and Content 26