SlideShare a Scribd company logo
1 of 30
Developing the Game User Interface (UI)
Lesson 5
Exam Objective Matrix
Skills/Concepts MTA Exam Objectives
Managing the UI Assets Plan for game state (3.2)
Design the user interface (1.4)
Capture user data (1.6)
Work with XNA (1.7)
Programming the UI Game
States
Design the user interface (1.4)
Work with XNA (1.7)
Programming the UI Access
Mechanisms
Design the user interface (1.4)
Work with XNA (1.7)
Managing the UI Assets
• UI is a collective term used to refer to the
onscreen elements through which a player
interacts with the game.
– The UI helps the player access information
about the game world and the status of his or
her character.
• The UI assets designed previously—such as
menu, sprites, and GUI controls—need to be
created or loaded in the XNA Framework before
you can add code to make them functional in
your game.
Loading UI Assets
• To access game assets at run time for
immediate use, XNA Framework 4.0
provides you with the content pipeline.
– The content pipeline allows you to include
the necessary game assets in the form of
managed code object in the game’s
executable.
– To make your game assets available to the
content pipeline, you need to load the
required asset to the game content project.
Using Solution Explorer to Add Assets
Loading Assets Into the Game
• Load assets into the game code by
overriding the LoadContent method.
protected override void LoadContent()
{
/* the Content.Load method loads a game asset
that has been processed by the content
pipeline */
Texture2D backgroundScreen =
Content.Load<Texture2D>(@”Background”);
Base.LoadContent();
}
Configuring Audio
• Playing a loaded audio file when a menu is
displayed.
protected override void LoadContent()
{
/* Create a new SpriteBatch, which can be used to
draw textures.*/
spriteBatch = new SpriteBatch(GraphicsDevice);
soundOnMenuDisplay =
Content.Load<SoundEffect>(@”your sound file
name”);
/;
}
Configuring Video
• First create an object of Video class to
represent the file.
/*Define an object for video player and video .*/
Microsoft.Xna.Framework.Media.VideoPlayer
videoPlayer;
Microsoft.Xna.Framework.Media.Video videoObject;
Configuring Video
• Next, create a VideoPlayer object to
provide the player controls.
/*.Initialize video player in Game.Initialize()*/
videoPlayer = new
Microsoft.Xna.Framework.Media.VideoPlayer();
/*Load the media file you want to play in video
player in Game.LoadContent()*/
videoObject=
content.Load<Microsoft.Xna.Framework.Media.Video>(
@”your video file path”);
Configuring Player Inputs
• You can retrieve user inputs from the respective
input device such as a mouse or a keyboard to
map the captured data to the desired UI asset.
• XNA 4.0 includes all the functionalities required
to capture the current state of the input devices,
such as the keyboard, mouse, and joystick.
– You simply need to access the specific classes
and structures provided in the
Microsoft.Xna.Framework.Input
namespace.
Input Namespace Structures
• GamePadButtons
– Identifies whether buttons on the Xbox controller are pressed or
released
• GamePadCapabilities
– Identifies the capabilities and type of Xbox controller
• GamePadState
– Describes the current state of Xbox controller
• GamePadThumbSticks
– Represents the position of left and right sticks
• MouseState
– Represents the current state of the mouse
• Keyboardstate
– Represents the state of keystrokes recorded by a keyboard
Detecting State of Keys
1. Declare instances of KeyboardState class to hold the
last and current state value of the keyboard
(LastKeyBoardState, CurrentKeyBoardState).
2. Assign a value to LastKeyboardState in the game
constructor.
3. Call the GetState method to hold the current
keyboard state.
4. Compare the values of the two keyboard states.
5. Update the LastKeyboardState to hold the current
keyboard state.
Play a Sound on Keyboard Key Press
/* declare an object of SoundEffect and an object of
KeyboardHandler in your Game class in the
XNAKeyboardHandler project */
SoundEffect soundOnKeyPressA;
KeyboardHandler keyHandler;
/* modify the LoadContent method as shown below */
protected override void LoadContent()
{
/* create a new SpriteBatch, which can be used to draw
textures */
spriteBatch = new SpriteBatch(GraphicsDevice);
soundOnKeyPressA = Content.Load<SoundEffect>(@”your
sound file name”);
}
Detecting Mouse Position
1. Call Mouse.GetState to get the current
state of the mouse.
2. Use MouseState.X and
MouseState.Y to get the position of the
mouse in pixels.
Detecting Xbox 360 Controller State
1. Use GetState to determine the current
state of the Xbox.
2. Verify whether the Xbox is connected
using the IsConnected property.
3. Get the values of the buttons you want to
check if pressed currently. For any
button, if the value is Pressed, it means
the button is currently pressed by the
player.
Get Gamepad State
public XNAGamePad()
{
/ To get the state of GamePad you need PlayerIndex that
specifies which GamePad’s state is queried. XBOX supports
multiple GamePads at same time */
currentGamepadState = GamePad.GetState(PlayerIndex.One);
}
public void update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One) != currentGamepadState)
{
previousGamepadState = currentGamepadState;
currentGamepadState = GamePad.GetState(PlayerIndex.One);
}
}
Check For Specific Button Press
/* Check for specific button press */
public bool isButtonPressed(Buttons btn )
{
currentGamepadState = GamePad.GetState(PlayerIndex.One);
if (currentGamepadState.IsConnected &&
currentGamepadState.IsButtonDown(btn))
{
return true;
}
return false;
}
Creating Menus
• You can use menus to provide players
with a list of options.
– You can use menus as part of the game
story or the game space.
– You can also use menus as a nondiegetic
component on a welcome or opening
screen, where players can select the
activity they want to perform.
Menus as Drawable Game Components
• You can create menus as drawable game
components and then add them to your game’s
content solution to access it in the code.
– This provides a modular approach to adding graphics
content to your game.
– Register the component with your game class by
passing the component to the
Game.Components.Add method.
– Use the Game.Initialize, Game.Draw and
Game.Update methods for updates.
Creating a Custom Menu
1. Create a MenuItem class to hold each menu item.
2. Create the structure to hold the menu items in the
MenuComponent class item.
3. In the MenuComponent class, add the addMenuItem
and CheckKey methods. Also add the update and
draw methods.
4. Declare an object of MenuComponent.
MenuComponent menuSystem.
5. Load the required sprite font using LoadContent and
add the menu items.
6. Use the Game.Update method to add an Exit event.
7. Override the Draw method to include the sprite
batches.
Creating the Custom Menu
• The sample code in the textbook creates a class named
MenuItem to hold the information of each of the menu
item, such as the item name and its position on the
screen.
• The code then creates a DrawableGameComponent
class type called MenuComponent.
• This MenuComponent class performs the following
tasks:
– Creates the list of menu items
– Tracks the key press generated from the keyboard
and accordingly selects a particular menu
– Draws each menu item and displays the selected
menu item in a different color
Examining a Custom Menu
Managing Save-Load
• Managing save-load involves providing the
player with an option for saving and
loading the game from a specific point or
level.
– Allows the player can replay the current
level with a new inventory.
– Allows the player can use to save and/or
load the game from a specific point or
level.
Sample Save-Load Screen
Defining UI Behavior Using States
• Defining the various valid states for your
UI objects helps your game to decide what
action to perform when in that state.
– You can declare a variable to store the
value of the game state at any point in the
game.
– The game state variable can assume
Boolean values or custom-enumerated
values.
– The game state variable is instrumental in
managing the game states.
Programming the UI Access Mechanisms
• Programming UI access mechanisms
involve creating the required GUI controls
for your game.
– For example, a player can save or load a
game with the click of a button or select the
required tools for his inventory by selecting
the options given in a check box.
– GUI controls have become an integral part
of game programming.
GUI Controls and Event Handlers
GUI Controls
• Button
• Label
• Textbox
• Check box
• Radio button
• Picture box
• Form
Event Handlers
• Mouse click
• Mouse enter
• Mouse leave
• Mouse move
• Mouse down
• Toggle
• Close
• Button press
• Key press
Example: Creating a Check Box
• Steps required:
– Create a check box control.
– Create the method that contains the code
to be executed when the check box is
selected.
– Create an OnClick event handler that
maps the check box control with its
corresponding method.
Sample Checkbox Control
Recap
• Managing the UI Assets
• Loading UI Assets
• Using Solution Explorer to Add
Assets
• Loading Assets Into the Game
• Configuring Audio
• Configuring Video
• Configuring Player Inputs
• Input namespace structures
• Detecting State of Keys
• Play a Sound on Keyboard Key
Press
• Detecting Mouse Position
• Detecting Xbox 360 Controller
State
• Get Gamepad State
• Check For Specific Button Press
• Creating Menus
• Menus as Drawable Game
Components
• Creating a Custom Menu
• Managing Save-Load
• Defining UI Behavior Using
States
• Programming the UI Access
Mechanisms

More Related Content

What's hot

Power point lesson 08
Power point lesson 08Power point lesson 08
Power point lesson 08heidirobison
 
Chapt 1 (part 2) installing the sdk and exploring the workspace
Chapt 1 (part 2)   installing the sdk and exploring the workspaceChapt 1 (part 2)   installing the sdk and exploring the workspace
Chapt 1 (part 2) installing the sdk and exploring the workspaceMuhd Basheer
 
Chapt 2 storyboarding techniques
Chapt 2   storyboarding techniquesChapt 2   storyboarding techniques
Chapt 2 storyboarding techniquesMuhd Basheer
 
Galactic Wars XNA Game
Galactic Wars XNA GameGalactic Wars XNA Game
Galactic Wars XNA GameSohil Gupta
 
cpbricks project document
cpbricks project documentcpbricks project document
cpbricks project documenti i
 
Analog game gdd_revised
Analog game gdd_revisedAnalog game gdd_revised
Analog game gdd_revisedjowyn
 
Cmd unity withc
Cmd unity withcCmd unity withc
Cmd unity withcumairnoora
 
Introduction to Game Programming: Using C# and Unity 3D - Chapter 3 (Preview)
Introduction to Game Programming: Using C# and Unity 3D - Chapter 3 (Preview)Introduction to Game Programming: Using C# and Unity 3D - Chapter 3 (Preview)
Introduction to Game Programming: Using C# and Unity 3D - Chapter 3 (Preview)noorcon
 
Chapt 1 (part 1) mobile apps framework and platforms
Chapt 1 (part 1)   mobile apps framework and platformsChapt 1 (part 1)   mobile apps framework and platforms
Chapt 1 (part 1) mobile apps framework and platformsMuhd Basheer
 
Run and jump tutorial (part 1) actors
Run and jump tutorial (part 1)   actorsRun and jump tutorial (part 1)   actors
Run and jump tutorial (part 1) actorsMuhd Basheer
 
Introduction to Microsoft Windows
Introduction to Microsoft WindowsIntroduction to Microsoft Windows
Introduction to Microsoft WindowsTimesRide
 
Game Design - Monetization
Game Design - MonetizationGame Design - Monetization
Game Design - MonetizationErez Yerushalmi
 
Game Programming I - Introduction
Game Programming I - IntroductionGame Programming I - Introduction
Game Programming I - IntroductionFrancis Seriña
 
Run and jump tutorial (part 2) scenes
Run and jump tutorial (part 2)   scenesRun and jump tutorial (part 2)   scenes
Run and jump tutorial (part 2) scenesMuhd Basheer
 

What's hot (20)

Power point lesson 08
Power point lesson 08Power point lesson 08
Power point lesson 08
 
Chapt 1 (part 2) installing the sdk and exploring the workspace
Chapt 1 (part 2)   installing the sdk and exploring the workspaceChapt 1 (part 2)   installing the sdk and exploring the workspace
Chapt 1 (part 2) installing the sdk and exploring the workspace
 
Chapt 2 storyboarding techniques
Chapt 2   storyboarding techniquesChapt 2   storyboarding techniques
Chapt 2 storyboarding techniques
 
Galactic Wars XNA Game
Galactic Wars XNA GameGalactic Wars XNA Game
Galactic Wars XNA Game
 
cpbricks project document
cpbricks project documentcpbricks project document
cpbricks project document
 
unity basics
unity basicsunity basics
unity basics
 
Analog game gdd_revised
Analog game gdd_revisedAnalog game gdd_revised
Analog game gdd_revised
 
Cmd unity withc
Cmd unity withcCmd unity withc
Cmd unity withc
 
Game design document
Game design document Game design document
Game design document
 
Glow_rapport
Glow_rapportGlow_rapport
Glow_rapport
 
Introduction to Game Programming: Using C# and Unity 3D - Chapter 3 (Preview)
Introduction to Game Programming: Using C# and Unity 3D - Chapter 3 (Preview)Introduction to Game Programming: Using C# and Unity 3D - Chapter 3 (Preview)
Introduction to Game Programming: Using C# and Unity 3D - Chapter 3 (Preview)
 
Presentación Unity
Presentación UnityPresentación Unity
Presentación Unity
 
Kodu game design
Kodu game designKodu game design
Kodu game design
 
Chapt 1 (part 1) mobile apps framework and platforms
Chapt 1 (part 1)   mobile apps framework and platformsChapt 1 (part 1)   mobile apps framework and platforms
Chapt 1 (part 1) mobile apps framework and platforms
 
Run and jump tutorial (part 1) actors
Run and jump tutorial (part 1)   actorsRun and jump tutorial (part 1)   actors
Run and jump tutorial (part 1) actors
 
Mini Project- Game Hardware Development
Mini Project- Game Hardware DevelopmentMini Project- Game Hardware Development
Mini Project- Game Hardware Development
 
Introduction to Microsoft Windows
Introduction to Microsoft WindowsIntroduction to Microsoft Windows
Introduction to Microsoft Windows
 
Game Design - Monetization
Game Design - MonetizationGame Design - Monetization
Game Design - Monetization
 
Game Programming I - Introduction
Game Programming I - IntroductionGame Programming I - Introduction
Game Programming I - Introduction
 
Run and jump tutorial (part 2) scenes
Run and jump tutorial (part 2)   scenesRun and jump tutorial (part 2)   scenes
Run and jump tutorial (part 2) scenes
 

Viewers also liked

The career search project word
The career search project wordThe career search project word
The career search project wordTracie King
 
Roles and Responsibilities: Developing the Team
Roles and Responsibilities: Developing the TeamRoles and Responsibilities: Developing the Team
Roles and Responsibilities: Developing the TeamTracie King
 
Chapter 5 balance
Chapter 5 balanceChapter 5 balance
Chapter 5 balanceTracie King
 
98 374 Lesson 02-slides
98 374 Lesson 02-slides98 374 Lesson 02-slides
98 374 Lesson 02-slidesTracie King
 
Chapter 13 color
Chapter 13 colorChapter 13 color
Chapter 13 colorTracie King
 
98 374 Lesson 01-slides
98 374 Lesson 01-slides98 374 Lesson 01-slides
98 374 Lesson 01-slidesTracie King
 
98 374 Lesson 06-slides
98 374 Lesson 06-slides98 374 Lesson 06-slides
98 374 Lesson 06-slidesTracie King
 
The career search project
The career search projectThe career search project
The career search projectTracie King
 
Chapter 5 balance
Chapter 5 balanceChapter 5 balance
Chapter 5 balanceTracie King
 
Computer Literacy Lesson 1: Computer and Operating Systems
Computer Literacy Lesson 1: Computer and Operating SystemsComputer Literacy Lesson 1: Computer and Operating Systems
Computer Literacy Lesson 1: Computer and Operating Systemscpashke
 

Viewers also liked (13)

The career search project word
The career search project wordThe career search project word
The career search project word
 
Roles and Responsibilities: Developing the Team
Roles and Responsibilities: Developing the TeamRoles and Responsibilities: Developing the Team
Roles and Responsibilities: Developing the Team
 
Max2015 ch01
Max2015 ch01Max2015 ch01
Max2015 ch01
 
Chapter 5 balance
Chapter 5 balanceChapter 5 balance
Chapter 5 balance
 
98 374 Lesson 02-slides
98 374 Lesson 02-slides98 374 Lesson 02-slides
98 374 Lesson 02-slides
 
Lesson 11
Lesson 11Lesson 11
Lesson 11
 
Chapter 13 color
Chapter 13 colorChapter 13 color
Chapter 13 color
 
98 374 Lesson 01-slides
98 374 Lesson 01-slides98 374 Lesson 01-slides
98 374 Lesson 01-slides
 
98 374 Lesson 06-slides
98 374 Lesson 06-slides98 374 Lesson 06-slides
98 374 Lesson 06-slides
 
Ic3 gs4exam1
Ic3 gs4exam1Ic3 gs4exam1
Ic3 gs4exam1
 
The career search project
The career search projectThe career search project
The career search project
 
Chapter 5 balance
Chapter 5 balanceChapter 5 balance
Chapter 5 balance
 
Computer Literacy Lesson 1: Computer and Operating Systems
Computer Literacy Lesson 1: Computer and Operating SystemsComputer Literacy Lesson 1: Computer and Operating Systems
Computer Literacy Lesson 1: Computer and Operating Systems
 

Similar to 98 374 Lesson 05-slides

WP7 HUB_XNA overview
WP7 HUB_XNA overviewWP7 HUB_XNA overview
WP7 HUB_XNA overviewMICTT Palma
 
Let's make a game unity
Let's make a game   unityLet's make a game   unity
Let's make a game unitySaija Ketola
 
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2Kobkrit Viriyayudhakorn
 
Unity3d scripting tutorial
Unity3d scripting tutorialUnity3d scripting tutorial
Unity3d scripting tutorialhungnttg
 
Custom Editor Unity
Custom Editor UnityCustom Editor Unity
Custom Editor UnityDat Pham
 
Sephy engine development document
Sephy engine development documentSephy engine development document
Sephy engine development documentJaejun Kim
 
Developing VR Experiences with Unity
Developing VR Experiences with UnityDeveloping VR Experiences with Unity
Developing VR Experiences with UnityMark Billinghurst
 
Programming Without Coding Technology (PWCT) - Play Flash Movie
Programming Without Coding Technology (PWCT) - Play Flash MovieProgramming Without Coding Technology (PWCT) - Play Flash Movie
Programming Without Coding Technology (PWCT) - Play Flash MovieMahmoud Samir Fayed
 
Unity 3D
Unity 3DUnity 3D
Unity 3Dgema123
 
Titanium Appcelerator - Beginners
Titanium Appcelerator - BeginnersTitanium Appcelerator - Beginners
Titanium Appcelerator - BeginnersAmbarish Hazarnis
 
Automatic Code Generator 2.pptx_20240306_140049_0000.pptx
Automatic Code Generator 2.pptx_20240306_140049_0000.pptxAutomatic Code Generator 2.pptx_20240306_140049_0000.pptx
Automatic Code Generator 2.pptx_20240306_140049_0000.pptxvashishtajadhav44
 
Cross platform game development
Cross platform game developmentCross platform game development
Cross platform game developmentJerel Hass
 
How to add InLife to your game
How to add InLife to your gameHow to add InLife to your game
How to add InLife to your gameinlifeproject
 
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろうUnity Technologies Japan K.K.
 

Similar to 98 374 Lesson 05-slides (20)

WP7 HUB_XNA
WP7 HUB_XNAWP7 HUB_XNA
WP7 HUB_XNA
 
WP7 HUB_XNA overview
WP7 HUB_XNA overviewWP7 HUB_XNA overview
WP7 HUB_XNA overview
 
Let's make a game unity
Let's make a game   unityLet's make a game   unity
Let's make a game unity
 
Unity workshop
Unity workshopUnity workshop
Unity workshop
 
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2
 
Unity3d scripting tutorial
Unity3d scripting tutorialUnity3d scripting tutorial
Unity3d scripting tutorial
 
Custom Editor Unity
Custom Editor UnityCustom Editor Unity
Custom Editor Unity
 
Sephy engine development document
Sephy engine development documentSephy engine development document
Sephy engine development document
 
Developing VR Experiences with Unity
Developing VR Experiences with UnityDeveloping VR Experiences with Unity
Developing VR Experiences with Unity
 
Unity tutorial
Unity tutorialUnity tutorial
Unity tutorial
 
Programming Without Coding Technology (PWCT) - Play Flash Movie
Programming Without Coding Technology (PWCT) - Play Flash MovieProgramming Without Coding Technology (PWCT) - Play Flash Movie
Programming Without Coding Technology (PWCT) - Play Flash Movie
 
Unity 3D
Unity 3DUnity 3D
Unity 3D
 
GUI -THESIS123
GUI -THESIS123GUI -THESIS123
GUI -THESIS123
 
Presentation 8.pptx
Presentation 8.pptxPresentation 8.pptx
Presentation 8.pptx
 
Titanium Appcelerator - Beginners
Titanium Appcelerator - BeginnersTitanium Appcelerator - Beginners
Titanium Appcelerator - Beginners
 
Automatic Code Generator 2.pptx_20240306_140049_0000.pptx
Automatic Code Generator 2.pptx_20240306_140049_0000.pptxAutomatic Code Generator 2.pptx_20240306_140049_0000.pptx
Automatic Code Generator 2.pptx_20240306_140049_0000.pptx
 
08graphics
08graphics08graphics
08graphics
 
Cross platform game development
Cross platform game developmentCross platform game development
Cross platform game development
 
How to add InLife to your game
How to add InLife to your gameHow to add InLife to your game
How to add InLife to your game
 
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
 

More from Tracie King

Interface: Creating the connection
Interface: Creating the connectionInterface: Creating the connection
Interface: Creating the connectionTracie King
 
Gameplay: Creating the Experience
Gameplay:  Creating the ExperienceGameplay:  Creating the Experience
Gameplay: Creating the ExperienceTracie King
 
Game Story and Character Development
Game Story and Character DevelopmentGame Story and Character Development
Game Story and Character DevelopmentTracie King
 
Production and Management: Developing the Process
Production and Management: Developing the ProcessProduction and Management: Developing the Process
Production and Management: Developing the ProcessTracie King
 
Chapter1 design process
Chapter1 design processChapter1 design process
Chapter1 design processTracie King
 

More from Tracie King (19)

Interface: Creating the connection
Interface: Creating the connectionInterface: Creating the connection
Interface: Creating the connection
 
Gameplay: Creating the Experience
Gameplay:  Creating the ExperienceGameplay:  Creating the Experience
Gameplay: Creating the Experience
 
Game Story and Character Development
Game Story and Character DevelopmentGame Story and Character Development
Game Story and Character Development
 
Production and Management: Developing the Process
Production and Management: Developing the ProcessProduction and Management: Developing the Process
Production and Management: Developing the Process
 
Max2015 ch03
Max2015 ch03Max2015 ch03
Max2015 ch03
 
Max2015 ch02
Max2015 ch02Max2015 ch02
Max2015 ch02
 
Max2015 ch05
Max2015 ch05Max2015 ch05
Max2015 ch05
 
Max2015 ch04
Max2015 ch04Max2015 ch04
Max2015 ch04
 
Max2015 ch06
Max2015 ch06Max2015 ch06
Max2015 ch06
 
Max2015 ch07
Max2015 ch07Max2015 ch07
Max2015 ch07
 
Max2015 ch08
Max2015 ch08Max2015 ch08
Max2015 ch08
 
Max2015 ch09
Max2015 ch09Max2015 ch09
Max2015 ch09
 
Max2015 ch10
Max2015 ch10Max2015 ch10
Max2015 ch10
 
Max2015 ch11
Max2015 ch11Max2015 ch11
Max2015 ch11
 
Max2015 ch12
Max2015 ch12Max2015 ch12
Max2015 ch12
 
Max2015 ch13
Max2015 ch13Max2015 ch13
Max2015 ch13
 
Max2015 ch14
Max2015 ch14Max2015 ch14
Max2015 ch14
 
Max2015 ch15
Max2015 ch15Max2015 ch15
Max2015 ch15
 
Chapter1 design process
Chapter1 design processChapter1 design process
Chapter1 design process
 

Recently uploaded

Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 

Recently uploaded (20)

Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 

98 374 Lesson 05-slides

  • 1. Developing the Game User Interface (UI) Lesson 5
  • 2. Exam Objective Matrix Skills/Concepts MTA Exam Objectives Managing the UI Assets Plan for game state (3.2) Design the user interface (1.4) Capture user data (1.6) Work with XNA (1.7) Programming the UI Game States Design the user interface (1.4) Work with XNA (1.7) Programming the UI Access Mechanisms Design the user interface (1.4) Work with XNA (1.7)
  • 3. Managing the UI Assets • UI is a collective term used to refer to the onscreen elements through which a player interacts with the game. – The UI helps the player access information about the game world and the status of his or her character. • The UI assets designed previously—such as menu, sprites, and GUI controls—need to be created or loaded in the XNA Framework before you can add code to make them functional in your game.
  • 4. Loading UI Assets • To access game assets at run time for immediate use, XNA Framework 4.0 provides you with the content pipeline. – The content pipeline allows you to include the necessary game assets in the form of managed code object in the game’s executable. – To make your game assets available to the content pipeline, you need to load the required asset to the game content project.
  • 5. Using Solution Explorer to Add Assets
  • 6. Loading Assets Into the Game • Load assets into the game code by overriding the LoadContent method. protected override void LoadContent() { /* the Content.Load method loads a game asset that has been processed by the content pipeline */ Texture2D backgroundScreen = Content.Load<Texture2D>(@”Background”); Base.LoadContent(); }
  • 7. Configuring Audio • Playing a loaded audio file when a menu is displayed. protected override void LoadContent() { /* Create a new SpriteBatch, which can be used to draw textures.*/ spriteBatch = new SpriteBatch(GraphicsDevice); soundOnMenuDisplay = Content.Load<SoundEffect>(@”your sound file name”); /; }
  • 8. Configuring Video • First create an object of Video class to represent the file. /*Define an object for video player and video .*/ Microsoft.Xna.Framework.Media.VideoPlayer videoPlayer; Microsoft.Xna.Framework.Media.Video videoObject;
  • 9. Configuring Video • Next, create a VideoPlayer object to provide the player controls. /*.Initialize video player in Game.Initialize()*/ videoPlayer = new Microsoft.Xna.Framework.Media.VideoPlayer(); /*Load the media file you want to play in video player in Game.LoadContent()*/ videoObject= content.Load<Microsoft.Xna.Framework.Media.Video>( @”your video file path”);
  • 10. Configuring Player Inputs • You can retrieve user inputs from the respective input device such as a mouse or a keyboard to map the captured data to the desired UI asset. • XNA 4.0 includes all the functionalities required to capture the current state of the input devices, such as the keyboard, mouse, and joystick. – You simply need to access the specific classes and structures provided in the Microsoft.Xna.Framework.Input namespace.
  • 11. Input Namespace Structures • GamePadButtons – Identifies whether buttons on the Xbox controller are pressed or released • GamePadCapabilities – Identifies the capabilities and type of Xbox controller • GamePadState – Describes the current state of Xbox controller • GamePadThumbSticks – Represents the position of left and right sticks • MouseState – Represents the current state of the mouse • Keyboardstate – Represents the state of keystrokes recorded by a keyboard
  • 12. Detecting State of Keys 1. Declare instances of KeyboardState class to hold the last and current state value of the keyboard (LastKeyBoardState, CurrentKeyBoardState). 2. Assign a value to LastKeyboardState in the game constructor. 3. Call the GetState method to hold the current keyboard state. 4. Compare the values of the two keyboard states. 5. Update the LastKeyboardState to hold the current keyboard state.
  • 13. Play a Sound on Keyboard Key Press /* declare an object of SoundEffect and an object of KeyboardHandler in your Game class in the XNAKeyboardHandler project */ SoundEffect soundOnKeyPressA; KeyboardHandler keyHandler; /* modify the LoadContent method as shown below */ protected override void LoadContent() { /* create a new SpriteBatch, which can be used to draw textures */ spriteBatch = new SpriteBatch(GraphicsDevice); soundOnKeyPressA = Content.Load<SoundEffect>(@”your sound file name”); }
  • 14. Detecting Mouse Position 1. Call Mouse.GetState to get the current state of the mouse. 2. Use MouseState.X and MouseState.Y to get the position of the mouse in pixels.
  • 15. Detecting Xbox 360 Controller State 1. Use GetState to determine the current state of the Xbox. 2. Verify whether the Xbox is connected using the IsConnected property. 3. Get the values of the buttons you want to check if pressed currently. For any button, if the value is Pressed, it means the button is currently pressed by the player.
  • 16. Get Gamepad State public XNAGamePad() { / To get the state of GamePad you need PlayerIndex that specifies which GamePad’s state is queried. XBOX supports multiple GamePads at same time */ currentGamepadState = GamePad.GetState(PlayerIndex.One); } public void update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One) != currentGamepadState) { previousGamepadState = currentGamepadState; currentGamepadState = GamePad.GetState(PlayerIndex.One); } }
  • 17. Check For Specific Button Press /* Check for specific button press */ public bool isButtonPressed(Buttons btn ) { currentGamepadState = GamePad.GetState(PlayerIndex.One); if (currentGamepadState.IsConnected && currentGamepadState.IsButtonDown(btn)) { return true; } return false; }
  • 18. Creating Menus • You can use menus to provide players with a list of options. – You can use menus as part of the game story or the game space. – You can also use menus as a nondiegetic component on a welcome or opening screen, where players can select the activity they want to perform.
  • 19. Menus as Drawable Game Components • You can create menus as drawable game components and then add them to your game’s content solution to access it in the code. – This provides a modular approach to adding graphics content to your game. – Register the component with your game class by passing the component to the Game.Components.Add method. – Use the Game.Initialize, Game.Draw and Game.Update methods for updates.
  • 20. Creating a Custom Menu 1. Create a MenuItem class to hold each menu item. 2. Create the structure to hold the menu items in the MenuComponent class item. 3. In the MenuComponent class, add the addMenuItem and CheckKey methods. Also add the update and draw methods. 4. Declare an object of MenuComponent. MenuComponent menuSystem. 5. Load the required sprite font using LoadContent and add the menu items. 6. Use the Game.Update method to add an Exit event. 7. Override the Draw method to include the sprite batches.
  • 21. Creating the Custom Menu • The sample code in the textbook creates a class named MenuItem to hold the information of each of the menu item, such as the item name and its position on the screen. • The code then creates a DrawableGameComponent class type called MenuComponent. • This MenuComponent class performs the following tasks: – Creates the list of menu items – Tracks the key press generated from the keyboard and accordingly selects a particular menu – Draws each menu item and displays the selected menu item in a different color
  • 23. Managing Save-Load • Managing save-load involves providing the player with an option for saving and loading the game from a specific point or level. – Allows the player can replay the current level with a new inventory. – Allows the player can use to save and/or load the game from a specific point or level.
  • 25. Defining UI Behavior Using States • Defining the various valid states for your UI objects helps your game to decide what action to perform when in that state. – You can declare a variable to store the value of the game state at any point in the game. – The game state variable can assume Boolean values or custom-enumerated values. – The game state variable is instrumental in managing the game states.
  • 26. Programming the UI Access Mechanisms • Programming UI access mechanisms involve creating the required GUI controls for your game. – For example, a player can save or load a game with the click of a button or select the required tools for his inventory by selecting the options given in a check box. – GUI controls have become an integral part of game programming.
  • 27. GUI Controls and Event Handlers GUI Controls • Button • Label • Textbox • Check box • Radio button • Picture box • Form Event Handlers • Mouse click • Mouse enter • Mouse leave • Mouse move • Mouse down • Toggle • Close • Button press • Key press
  • 28. Example: Creating a Check Box • Steps required: – Create a check box control. – Create the method that contains the code to be executed when the check box is selected. – Create an OnClick event handler that maps the check box control with its corresponding method.
  • 30. Recap • Managing the UI Assets • Loading UI Assets • Using Solution Explorer to Add Assets • Loading Assets Into the Game • Configuring Audio • Configuring Video • Configuring Player Inputs • Input namespace structures • Detecting State of Keys • Play a Sound on Keyboard Key Press • Detecting Mouse Position • Detecting Xbox 360 Controller State • Get Gamepad State • Check For Specific Button Press • Creating Menus • Menus as Drawable Game Components • Creating a Custom Menu • Managing Save-Load • Defining UI Behavior Using States • Programming the UI Access Mechanisms

Editor's Notes

  1. Tip: Add your own speaker notes here.
  2. Tip: Add your own speaker notes here.
  3. Tip: Add your own speaker notes here.
  4. Tip: Add your own speaker notes here.
  5. Tip: Add your own speaker notes here.
  6. Tip: Add your own speaker notes here.
  7. Tip: Add your own speaker notes here.
  8. Tip: Add your own speaker notes here.
  9. Tip: Add your own speaker notes here.
  10. Tip: Add your own speaker notes here.
  11. Tip: Add your own speaker notes here.
  12. Tip: Add your own speaker notes here.
  13. Tip: Add your own speaker notes here.
  14. Tip: Add your own speaker notes here.
  15. Tip: Add your own speaker notes here.
  16. Tip: Add your own speaker notes here.
  17. Tip: Add your own speaker notes here.
  18. Tip: Add your own speaker notes here.
  19. Tip: Add your own speaker notes here.
  20. Tip: Add your own speaker notes here.
  21. Tip: Add your own speaker notes here.
  22. Tip: Add your own speaker notes here.
  23. Tip: Add your own speaker notes here.
  24. Tip: Add your own speaker notes here.
  25. Tip: Add your own speaker notes here.
  26. Tip: Add your own speaker notes here.
  27. Tip: Add your own speaker notes here.