SlideShare ist ein Scribd-Unternehmen logo
1 von 46
Downloaden Sie, um offline zu lesen
Mohammad Shaker
mohammadshaker.com
@ZGTRShaker
2011, 2012, 2013, 2014
XNA Game Development
L06 – Input, Audio and Video Playback
Input
Keyboard, Mouse, Touch, Joystick, Sensors, etc.
Keyboard Input
Keyboard Input
• Why static?
KeyboardState state = Keyboard.GetState();
Keyboard Input
• Using Keyboard states
KeyboardState state = Keyboard.GetState();
if(state.IsKeyDown(Keys.Left))
{
// do something here
}
Keyboard Input
• Using Keyboard states
bool leftArrowKeyDown = state.IsKeyDown(Keys.Left);
if(state.IsKeyDown(Keys.Left))
{
// do something here
}
Keyboard Input
• Using Keyboard states
KeyboardState state = Keyboard.GetState();
if(state.IsKeyDown(Keys.Left))
{
// do something here
}
Keyboard Input
• Using Keyboard states
KeyboardState state = Keyboard.GetState();
if(state.IsKeyDown(Keys.Left))
{
// do something here
}
Keyboard Input - Checking for Key Presses
if(state.IsKeyDown(Keys.Left))
{
// do something here
}
Keyboard Input - Checking for Key Presses
if(state.IsKeyDown(Keys.Left))
{
// do something here
}
Keyboard Input - Checking for Key Presses
Keys[] pressedKeys = state.GetPressedKeys();
Keyboard Input - Key Modifiers
if(
(
state.IsKeyDown(Keys.LeftControl)|| state.IsKeyDown(Keys.RightControl)
)
&& state.IsKeyDown(Keys.C)
)
{
// Do something here when Ctrl-C is pressed
}
Mouse Input
Mouse Input - Showing the Mouse
this.IsMouseVisible = true;
Mouse Input - Mouse Input?
MouseState mouseState = Mouse.GetState();
if(mouseState.LeftButton == ButtonState.Pressed)
{
// Do whatever you want here
}
Mouse Input - Mouse Input?
• Mouse built-in methods
– LeftMouseButton
– MiddleMouseButton
– RightMouseButton
– XButton1
– XButton2
– X
– Y
– ScrollWheelValue
Mouse Input - Location
• Getting Location
int x = mouseState.X;
int y = mouseState.Y;
Mouse.SetPosition(xLocation, yLocation);
• Setting Location
Xbox(Or Other!) Controller Input
Controller Input
Controller Input
• GamePadState gamePadState = GamePad.GetState(PlayerIndex.One);
if(gamePadState.IsConnected)
{
// then it is connected, and we can do stuff here
}
if(gamePadState.Buttons.X == ButtonState.Pressed)
{
// do something
}
Controller Input
float maxSpeed = 0.1f;
float changeInAngle = gamePadState.Thumbsticks.Left.X * maxSpeed;
// this variable is defined elsewhere
angle += changeInAngle;
Controller Input – Vibration effect!
Controller Input – Vibration Cool effect!
GamePad.SetVibration(PlayerIndex.One, 1.0f, 1.0f);
Audio
Audio
• Audio in XNA
• Audio Suggestions for Games
• A Simple Way to Play Sound Effects in XNA
• A Simple Way to Play Background Music in XNA
• Using XACT
• Using XACT Projects in an XNA Game
• XACT Sound Loops
• 3D Audio Effects: Location
• 3D Audio Effects: Attenuation based on Distance
Audio in XNA
• The Concept
Audio Suggestions For Games
• Audio Suggestions For Games
– royalty free music in google.com
– http://www.incompetech.com/m/c/royalty-free/
– http://www.flashkit.com/
• Use sound in your game. It adds a lot to the game. Don't just ignore it. ( Not in
our uni :( )
Playing Sound Effects
• Adding Sound Effects to your Game
– Managing Content!
Playing Sound Effects
• WAV Audio File (.wav extension)
private SoundEffect effect;
effect = Content.Load<SoundEffect>("SoundFX/ExtraLife");
Playing Sound Effects
• WAV Audio File (.wav extension)
private SoundEffect effect;
effect = Content.Load<SoundEffect>("SoundFX/ExtraLife");
effect.Play();
float volume = 1.0f;
effect.Play(volume);
float volume = 1.0f;
float pitch = -1.0f;
float pan = -1.0f;
bool loop = true;
effect.Play(volume, pitch, pan, loop);
Playing Sound Effects
• SoundEffectInstances class
SoundEffectInstance effectInstance = effect1.Play();
effectInstance.Stop();
Playing Sound Effects
• SoundEffectInstances class
SoundEffectInstance effectInstance = effect1.Play();
effectInstance.Stop();
Playing Background Music
• Using the Song and MediaPlayer Classes to Play Audio
Song song = Content.Load<Song>("song_title");
// Put the name of your song here instead of "song_title"
MediaPlayer.Play(song);
MediaPlayer.IsRepeating = true;
Using XACT
• Cross-platform Audio Creation Tool
• The concept
• Using XACT
– Using XACT
– Using XACT Projects in an XNA Game
– XACT Sound Loops
– 3D Audio Effects: Location
– 3D Audio Effects: Attenuation based on Distance
Using XACT
• Small Tutorials
– http://rbwhitaker.wikidot.com/audio-tutorials
• http://rbwhitaker.wikidot.com/using-xact
• http://rbwhitaker.wikidot.com/playing-sound
• http://rbwhitaker.wikidot.com/xact-sound-loops
• http://rbwhitaker.wikidot.com/3d-audio-effects-location
– Books
• Microsoft Book
• Aaron Reed (O’Reilly)
Video Playback
Video Playback
• Loading the Video in XNA, Game1 Global Scope
Video video;
VideoPlayer player;
Video Playback
• Loading the Video in XNA, Game1 Global Scope
• LoadContent()
Video video;
VideoPlayer player;
video = Content.Load<Video>("AVideoToPlayback");
player = new VideoPlayer();
Video Playback
• Starting the Video
player.Play(video);
Video Playback
• Starting the Video
• Update()
player.Play(video);
if (player.State == MediaState.Stopped)
{
player.IsLooped = true;
player.Play(video);
}
Video Playback
• Looping
player.IsLooped = true;
Video Playback
• Drawing the Video, Draw()
Texture2D videoTexture = null;
if (player.State!= MediaState.Stopped)
videoTexture = player.GetTexture();
Video Playback
• Drawing the Video, Draw()
Texture2D videoTexture = null;
if (player.State!= MediaState.Stopped)
videoTexture = player.GetTexture();
Video Playback
• Drawing the Video, Draw()
Texture2D videoTexture = null;
if (player.State!= MediaState.Stopped)
videoTexture = player.GetTexture();
Video Playback
• Drawing the Video, Draw()
Texture2D videoTexture = null;
if (player.State!= MediaState.Stopped)
videoTexture = player.GetTexture();
Video Playback
• Drawing the Video, Draw()
Texture2D videoTexture = null;
if (player.State!= MediaState.Stopped)
videoTexture = player.GetTexture();
if (videoTexture!= null)
{
spriteBatch.Begin();
spriteBatch.Draw(videoTexture, new Rectangle(0, 0, 400, 300), Color.White);
spriteBatch.End();
}

Weitere ähnliche Inhalte

Was ist angesagt?

Core Audio in iOS 6 (CocoaConf DC, March 2013)
Core Audio in iOS 6 (CocoaConf DC, March 2013)Core Audio in iOS 6 (CocoaConf DC, March 2013)
Core Audio in iOS 6 (CocoaConf DC, March 2013)Chris Adamson
 
Audio Mixer in Unity5 - Andy Touch
Audio Mixer in Unity5 - Andy TouchAudio Mixer in Unity5 - Andy Touch
Audio Mixer in Unity5 - Andy TouchBeMyApp
 
Core Audio in iOS 6 (CocoaConf San Jose, April 2013)
Core Audio in iOS 6 (CocoaConf San Jose, April 2013) Core Audio in iOS 6 (CocoaConf San Jose, April 2013)
Core Audio in iOS 6 (CocoaConf San Jose, April 2013) Chris Adamson
 
Squidiverse Production Pipeline
Squidiverse Production PipelineSquidiverse Production Pipeline
Squidiverse Production PipelinePhoenix Smith
 
Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)
Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)
Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)Chris Adamson
 
Building your own arcade cabinet
Building your own arcade cabinetBuilding your own arcade cabinet
Building your own arcade cabinetphildenoncourt
 
Core MIDI and Friends
Core MIDI and FriendsCore MIDI and Friends
Core MIDI and FriendsChris Adamson
 
A Brief Guide to Game Engines
A Brief Guide to Game EnginesA Brief Guide to Game Engines
A Brief Guide to Game EnginesDavid Parsons
 
Readme i'm en pilotes
Readme i'm en pilotesReadme i'm en pilotes
Readme i'm en pilotesMUELOS
 
Absolutist: Porting to major platforms within a minute
Absolutist: Porting to major platforms within a minuteAbsolutist: Porting to major platforms within a minute
Absolutist: Porting to major platforms within a minuteDevGAMM Conference
 
Week Two - Game Platforms (Additional Material)
Week Two - Game Platforms (Additional Material)Week Two - Game Platforms (Additional Material)
Week Two - Game Platforms (Additional Material)chriswalton
 

Was ist angesagt? (18)

Core Audio in iOS 6 (CocoaConf DC, March 2013)
Core Audio in iOS 6 (CocoaConf DC, March 2013)Core Audio in iOS 6 (CocoaConf DC, March 2013)
Core Audio in iOS 6 (CocoaConf DC, March 2013)
 
Audio Mixer in Unity5 - Andy Touch
Audio Mixer in Unity5 - Andy TouchAudio Mixer in Unity5 - Andy Touch
Audio Mixer in Unity5 - Andy Touch
 
Core Audio in iOS 6 (CocoaConf San Jose, April 2013)
Core Audio in iOS 6 (CocoaConf San Jose, April 2013) Core Audio in iOS 6 (CocoaConf San Jose, April 2013)
Core Audio in iOS 6 (CocoaConf San Jose, April 2013)
 
Xbox 360
Xbox 360 Xbox 360
Xbox 360
 
Xbox one
Xbox oneXbox one
Xbox one
 
Sharing
SharingSharing
Sharing
 
Gamelog
GamelogGamelog
Gamelog
 
GoldWave
GoldWaveGoldWave
GoldWave
 
Squidiverse Production Pipeline
Squidiverse Production PipelineSquidiverse Production Pipeline
Squidiverse Production Pipeline
 
Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)
Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)
Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)
 
Building your own arcade cabinet
Building your own arcade cabinetBuilding your own arcade cabinet
Building your own arcade cabinet
 
Core MIDI and Friends
Core MIDI and FriendsCore MIDI and Friends
Core MIDI and Friends
 
A Brief Guide to Game Engines
A Brief Guide to Game EnginesA Brief Guide to Game Engines
A Brief Guide to Game Engines
 
See'n'Sound LE 2.0 promo
See'n'Sound LE 2.0 promoSee'n'Sound LE 2.0 promo
See'n'Sound LE 2.0 promo
 
Audio equalizer
Audio equalizerAudio equalizer
Audio equalizer
 
Readme i'm en pilotes
Readme i'm en pilotesReadme i'm en pilotes
Readme i'm en pilotes
 
Absolutist: Porting to major platforms within a minute
Absolutist: Porting to major platforms within a minuteAbsolutist: Porting to major platforms within a minute
Absolutist: Porting to major platforms within a minute
 
Week Two - Game Platforms (Additional Material)
Week Two - Game Platforms (Additional Material)Week Two - Game Platforms (Additional Material)
Week Two - Game Platforms (Additional Material)
 

Andere mochten auch

XNA L11–Shaders Part 2
XNA L11–Shaders Part 2XNA L11–Shaders Part 2
XNA L11–Shaders Part 2Mohammad Shaker
 
XNA L08–Amazing XNA Utilities
XNA L08–Amazing XNA UtilitiesXNA L08–Amazing XNA Utilities
XNA L08–Amazing XNA UtilitiesMohammad Shaker
 
XNA L04–Primitives, IndexBuffer and VertexBuffer
XNA L04–Primitives, IndexBuffer and VertexBufferXNA L04–Primitives, IndexBuffer and VertexBuffer
XNA L04–Primitives, IndexBuffer and VertexBufferMohammad Shaker
 
Ogdc 2013 2d artist the first steps
Ogdc 2013 2d artist the first stepsOgdc 2013 2d artist the first steps
Ogdc 2013 2d artist the first stepsSon Aris
 
XNA L10–Shaders Part 1
XNA L10–Shaders Part 1XNA L10–Shaders Part 1
XNA L10–Shaders Part 1Mohammad Shaker
 
XNA L07–Skybox and Terrain
XNA L07–Skybox and TerrainXNA L07–Skybox and Terrain
XNA L07–Skybox and TerrainMohammad Shaker
 

Andere mochten auch (7)

XNA L11–Shaders Part 2
XNA L11–Shaders Part 2XNA L11–Shaders Part 2
XNA L11–Shaders Part 2
 
XNA L01–Introduction
XNA L01–IntroductionXNA L01–Introduction
XNA L01–Introduction
 
XNA L08–Amazing XNA Utilities
XNA L08–Amazing XNA UtilitiesXNA L08–Amazing XNA Utilities
XNA L08–Amazing XNA Utilities
 
XNA L04–Primitives, IndexBuffer and VertexBuffer
XNA L04–Primitives, IndexBuffer and VertexBufferXNA L04–Primitives, IndexBuffer and VertexBuffer
XNA L04–Primitives, IndexBuffer and VertexBuffer
 
Ogdc 2013 2d artist the first steps
Ogdc 2013 2d artist the first stepsOgdc 2013 2d artist the first steps
Ogdc 2013 2d artist the first steps
 
XNA L10–Shaders Part 1
XNA L10–Shaders Part 1XNA L10–Shaders Part 1
XNA L10–Shaders Part 1
 
XNA L07–Skybox and Terrain
XNA L07–Skybox and TerrainXNA L07–Skybox and Terrain
XNA L07–Skybox and Terrain
 

Ähnlich wie XNA L06–Input, Audio and Video Playback

Web Audio Made Easy with Howler.js
Web Audio Made Easy with Howler.jsWeb Audio Made Easy with Howler.js
Web Audio Made Easy with Howler.jsJames Simpson
 
How Audio Objects Improve Spatial Accuracy / Mads Maretty Sønderup (Audiokine...
How Audio Objects Improve Spatial Accuracy / Mads Maretty Sønderup (Audiokine...How Audio Objects Improve Spatial Accuracy / Mads Maretty Sønderup (Audiokine...
How Audio Objects Improve Spatial Accuracy / Mads Maretty Sønderup (Audiokine...DevGAMM Conference
 
Modern Improvisation World
Modern Improvisation WorldModern Improvisation World
Modern Improvisation WorldWillow Cheng
 
Windows phone 7 xna
Windows phone 7 xnaWindows phone 7 xna
Windows phone 7 xnaGlen Gordon
 
Living the Dream: Make the Video Game You’ve Always Wanted and Get Paid For It!
Living the Dream: Make the Video Game You’ve Always Wanted and Get Paid For It!Living the Dream: Make the Video Game You’ve Always Wanted and Get Paid For It!
Living the Dream: Make the Video Game You’ve Always Wanted and Get Paid For It!David Isbitski
 
Introduction to Game programming with PyGame Part 1
Introduction to Game programming with PyGame Part 1Introduction to Game programming with PyGame Part 1
Introduction to Game programming with PyGame Part 1Abhishek Mishra
 
Prasentation Managed DirectX
Prasentation Managed DirectXPrasentation Managed DirectX
Prasentation Managed DirectXA. LE
 
XNA and Windows Phone
XNA and Windows PhoneXNA and Windows Phone
XNA and Windows PhoneGlen Gordon
 
Game Audio Post-Production
Game Audio Post-ProductionGame Audio Post-Production
Game Audio Post-ProductionKaren Collins
 
Game programming with Groovy
Game programming with GroovyGame programming with Groovy
Game programming with GroovyJames Williams
 
Wakka Monkey - Game Development
Wakka Monkey - Game DevelopmentWakka Monkey - Game Development
Wakka Monkey - Game DevelopmentWakka Monkey
 
The Online Tech of Titanfall
The Online Tech of TitanfallThe Online Tech of Titanfall
The Online Tech of Titanfallvtslothy
 
Confrontation Audio GDC 2009
Confrontation Audio GDC 2009Confrontation Audio GDC 2009
Confrontation Audio GDC 2009slantsixgames
 
Supersize your production pipe enjmin 2013 v1.1 hd
Supersize your production pipe    enjmin 2013 v1.1 hdSupersize your production pipe    enjmin 2013 v1.1 hd
Supersize your production pipe enjmin 2013 v1.1 hdslantsixgames
 
Beginning android games
Beginning android gamesBeginning android games
Beginning android gamesMario Zechner
 
Kinect for Windows Quickstart Series
Kinect for Windows Quickstart SeriesKinect for Windows Quickstart Series
Kinect for Windows Quickstart SeriesRoberto Reto
 
Drumwavy VST VST3 Audio Unit: Orchestral and Ethnic Percussion VST, VST3 and ...
Drumwavy VST VST3 Audio Unit: Orchestral and Ethnic Percussion VST, VST3 and ...Drumwavy VST VST3 Audio Unit: Orchestral and Ethnic Percussion VST, VST3 and ...
Drumwavy VST VST3 Audio Unit: Orchestral and Ethnic Percussion VST, VST3 and ...Syntheway Virtual Musical Instruments
 

Ähnlich wie XNA L06–Input, Audio and Video Playback (20)

Web Audio Made Easy with Howler.js
Web Audio Made Easy with Howler.jsWeb Audio Made Easy with Howler.js
Web Audio Made Easy with Howler.js
 
How Audio Objects Improve Spatial Accuracy / Mads Maretty Sønderup (Audiokine...
How Audio Objects Improve Spatial Accuracy / Mads Maretty Sønderup (Audiokine...How Audio Objects Improve Spatial Accuracy / Mads Maretty Sønderup (Audiokine...
How Audio Objects Improve Spatial Accuracy / Mads Maretty Sønderup (Audiokine...
 
Modern Improvisation World
Modern Improvisation WorldModern Improvisation World
Modern Improvisation World
 
Windows phone 7 xna
Windows phone 7 xnaWindows phone 7 xna
Windows phone 7 xna
 
Living the Dream: Make the Video Game You’ve Always Wanted and Get Paid For It!
Living the Dream: Make the Video Game You’ve Always Wanted and Get Paid For It!Living the Dream: Make the Video Game You’ve Always Wanted and Get Paid For It!
Living the Dream: Make the Video Game You’ve Always Wanted and Get Paid For It!
 
Unity
UnityUnity
Unity
 
Introduction to Game programming with PyGame Part 1
Introduction to Game programming with PyGame Part 1Introduction to Game programming with PyGame Part 1
Introduction to Game programming with PyGame Part 1
 
Prasentation Managed DirectX
Prasentation Managed DirectXPrasentation Managed DirectX
Prasentation Managed DirectX
 
XNA and Windows Phone
XNA and Windows PhoneXNA and Windows Phone
XNA and Windows Phone
 
God Of War : post mortem
God Of War : post mortemGod Of War : post mortem
God Of War : post mortem
 
Game Audio Post-Production
Game Audio Post-ProductionGame Audio Post-Production
Game Audio Post-Production
 
Game programming with Groovy
Game programming with GroovyGame programming with Groovy
Game programming with Groovy
 
Wakka Monkey - Game Development
Wakka Monkey - Game DevelopmentWakka Monkey - Game Development
Wakka Monkey - Game Development
 
The Online Tech of Titanfall
The Online Tech of TitanfallThe Online Tech of Titanfall
The Online Tech of Titanfall
 
Confrontation Audio GDC 2009
Confrontation Audio GDC 2009Confrontation Audio GDC 2009
Confrontation Audio GDC 2009
 
Supersize your production pipe enjmin 2013 v1.1 hd
Supersize your production pipe    enjmin 2013 v1.1 hdSupersize your production pipe    enjmin 2013 v1.1 hd
Supersize your production pipe enjmin 2013 v1.1 hd
 
Readme
ReadmeReadme
Readme
 
Beginning android games
Beginning android gamesBeginning android games
Beginning android games
 
Kinect for Windows Quickstart Series
Kinect for Windows Quickstart SeriesKinect for Windows Quickstart Series
Kinect for Windows Quickstart Series
 
Drumwavy VST VST3 Audio Unit: Orchestral and Ethnic Percussion VST, VST3 and ...
Drumwavy VST VST3 Audio Unit: Orchestral and Ethnic Percussion VST, VST3 and ...Drumwavy VST VST3 Audio Unit: Orchestral and Ethnic Percussion VST, VST3 and ...
Drumwavy VST VST3 Audio Unit: Orchestral and Ethnic Percussion VST, VST3 and ...
 

Mehr von Mohammad Shaker

12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian GraduateMohammad Shaker
 
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]Mohammad Shaker
 
Interaction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyInteraction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyMohammad Shaker
 
Short, Matters, Love - Passioneers Event 2015
Short, Matters, Love -  Passioneers Event 2015Short, Matters, Love -  Passioneers Event 2015
Short, Matters, Love - Passioneers Event 2015Mohammad Shaker
 
Unity L01 - Game Development
Unity L01 - Game DevelopmentUnity L01 - Game Development
Unity L01 - Game DevelopmentMohammad Shaker
 
Android L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesAndroid L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesMohammad Shaker
 
Interaction Design L03 - Color
Interaction Design L03 - ColorInteraction Design L03 - Color
Interaction Design L03 - ColorMohammad Shaker
 
Interaction Design L05 - Typography
Interaction Design L05 - TypographyInteraction Design L05 - Typography
Interaction Design L05 - TypographyMohammad Shaker
 
Interaction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingInteraction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingMohammad Shaker
 
Android L04 - Notifications and Threading
Android L04 - Notifications and ThreadingAndroid L04 - Notifications and Threading
Android L04 - Notifications and ThreadingMohammad Shaker
 
Android L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSAndroid L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSMohammad Shaker
 
Interaction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsInteraction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsMohammad Shaker
 
Interaction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsInteraction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsMohammad Shaker
 
Android L10 - Stores and Gaming
Android L10 - Stores and GamingAndroid L10 - Stores and Gaming
Android L10 - Stores and GamingMohammad Shaker
 
Android L06 - Cloud / Parse
Android L06 - Cloud / ParseAndroid L06 - Cloud / Parse
Android L06 - Cloud / ParseMohammad Shaker
 
Android L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesAndroid L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesMohammad Shaker
 
Android L03 - Styles and Themes
Android L03 - Styles and Themes Android L03 - Styles and Themes
Android L03 - Styles and Themes Mohammad Shaker
 
Android L02 - Activities and Adapters
Android L02 - Activities and AdaptersAndroid L02 - Activities and Adapters
Android L02 - Activities and AdaptersMohammad Shaker
 

Mehr von Mohammad Shaker (20)

12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate
 
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
 
Interaction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyInteraction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with Psychology
 
Short, Matters, Love - Passioneers Event 2015
Short, Matters, Love -  Passioneers Event 2015Short, Matters, Love -  Passioneers Event 2015
Short, Matters, Love - Passioneers Event 2015
 
Unity L01 - Game Development
Unity L01 - Game DevelopmentUnity L01 - Game Development
Unity L01 - Game Development
 
Android L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesAndroid L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and Wearables
 
Interaction Design L03 - Color
Interaction Design L03 - ColorInteraction Design L03 - Color
Interaction Design L03 - Color
 
Interaction Design L05 - Typography
Interaction Design L05 - TypographyInteraction Design L05 - Typography
Interaction Design L05 - Typography
 
Interaction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingInteraction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and Coupling
 
Android L05 - Storage
Android L05 - StorageAndroid L05 - Storage
Android L05 - Storage
 
Android L04 - Notifications and Threading
Android L04 - Notifications and ThreadingAndroid L04 - Notifications and Threading
Android L04 - Notifications and Threading
 
Android L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSAndroid L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOS
 
Interaction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsInteraction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile Constraints
 
Interaction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsInteraction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and Grids
 
Android L10 - Stores and Gaming
Android L10 - Stores and GamingAndroid L10 - Stores and Gaming
Android L10 - Stores and Gaming
 
Android L06 - Cloud / Parse
Android L06 - Cloud / ParseAndroid L06 - Cloud / Parse
Android L06 - Cloud / Parse
 
Android L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesAndroid L08 - Google Maps and Utilities
Android L08 - Google Maps and Utilities
 
Android L03 - Styles and Themes
Android L03 - Styles and Themes Android L03 - Styles and Themes
Android L03 - Styles and Themes
 
Android L02 - Activities and Adapters
Android L02 - Activities and AdaptersAndroid L02 - Activities and Adapters
Android L02 - Activities and Adapters
 
Android L01 - Warm Up
Android L01 - Warm UpAndroid L01 - Warm Up
Android L01 - Warm Up
 

Kürzlich hochgeladen

Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 

Kürzlich hochgeladen (20)

Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 

XNA L06–Input, Audio and Video Playback

  • 1. Mohammad Shaker mohammadshaker.com @ZGTRShaker 2011, 2012, 2013, 2014 XNA Game Development L06 – Input, Audio and Video Playback
  • 2. Input Keyboard, Mouse, Touch, Joystick, Sensors, etc.
  • 4. Keyboard Input • Why static? KeyboardState state = Keyboard.GetState();
  • 5. Keyboard Input • Using Keyboard states KeyboardState state = Keyboard.GetState(); if(state.IsKeyDown(Keys.Left)) { // do something here }
  • 6. Keyboard Input • Using Keyboard states bool leftArrowKeyDown = state.IsKeyDown(Keys.Left); if(state.IsKeyDown(Keys.Left)) { // do something here }
  • 7. Keyboard Input • Using Keyboard states KeyboardState state = Keyboard.GetState(); if(state.IsKeyDown(Keys.Left)) { // do something here }
  • 8. Keyboard Input • Using Keyboard states KeyboardState state = Keyboard.GetState(); if(state.IsKeyDown(Keys.Left)) { // do something here }
  • 9. Keyboard Input - Checking for Key Presses if(state.IsKeyDown(Keys.Left)) { // do something here }
  • 10. Keyboard Input - Checking for Key Presses if(state.IsKeyDown(Keys.Left)) { // do something here }
  • 11. Keyboard Input - Checking for Key Presses Keys[] pressedKeys = state.GetPressedKeys();
  • 12. Keyboard Input - Key Modifiers if( ( state.IsKeyDown(Keys.LeftControl)|| state.IsKeyDown(Keys.RightControl) ) && state.IsKeyDown(Keys.C) ) { // Do something here when Ctrl-C is pressed }
  • 14. Mouse Input - Showing the Mouse this.IsMouseVisible = true;
  • 15. Mouse Input - Mouse Input? MouseState mouseState = Mouse.GetState(); if(mouseState.LeftButton == ButtonState.Pressed) { // Do whatever you want here }
  • 16. Mouse Input - Mouse Input? • Mouse built-in methods – LeftMouseButton – MiddleMouseButton – RightMouseButton – XButton1 – XButton2 – X – Y – ScrollWheelValue
  • 17. Mouse Input - Location • Getting Location int x = mouseState.X; int y = mouseState.Y; Mouse.SetPosition(xLocation, yLocation); • Setting Location
  • 20. Controller Input • GamePadState gamePadState = GamePad.GetState(PlayerIndex.One); if(gamePadState.IsConnected) { // then it is connected, and we can do stuff here } if(gamePadState.Buttons.X == ButtonState.Pressed) { // do something }
  • 21. Controller Input float maxSpeed = 0.1f; float changeInAngle = gamePadState.Thumbsticks.Left.X * maxSpeed; // this variable is defined elsewhere angle += changeInAngle;
  • 22. Controller Input – Vibration effect!
  • 23. Controller Input – Vibration Cool effect! GamePad.SetVibration(PlayerIndex.One, 1.0f, 1.0f);
  • 24. Audio
  • 25. Audio • Audio in XNA • Audio Suggestions for Games • A Simple Way to Play Sound Effects in XNA • A Simple Way to Play Background Music in XNA • Using XACT • Using XACT Projects in an XNA Game • XACT Sound Loops • 3D Audio Effects: Location • 3D Audio Effects: Attenuation based on Distance
  • 26. Audio in XNA • The Concept
  • 27. Audio Suggestions For Games • Audio Suggestions For Games – royalty free music in google.com – http://www.incompetech.com/m/c/royalty-free/ – http://www.flashkit.com/ • Use sound in your game. It adds a lot to the game. Don't just ignore it. ( Not in our uni :( )
  • 28. Playing Sound Effects • Adding Sound Effects to your Game – Managing Content!
  • 29. Playing Sound Effects • WAV Audio File (.wav extension) private SoundEffect effect; effect = Content.Load<SoundEffect>("SoundFX/ExtraLife");
  • 30. Playing Sound Effects • WAV Audio File (.wav extension) private SoundEffect effect; effect = Content.Load<SoundEffect>("SoundFX/ExtraLife"); effect.Play(); float volume = 1.0f; effect.Play(volume); float volume = 1.0f; float pitch = -1.0f; float pan = -1.0f; bool loop = true; effect.Play(volume, pitch, pan, loop);
  • 31. Playing Sound Effects • SoundEffectInstances class SoundEffectInstance effectInstance = effect1.Play(); effectInstance.Stop();
  • 32. Playing Sound Effects • SoundEffectInstances class SoundEffectInstance effectInstance = effect1.Play(); effectInstance.Stop();
  • 33. Playing Background Music • Using the Song and MediaPlayer Classes to Play Audio Song song = Content.Load<Song>("song_title"); // Put the name of your song here instead of "song_title" MediaPlayer.Play(song); MediaPlayer.IsRepeating = true;
  • 34. Using XACT • Cross-platform Audio Creation Tool • The concept • Using XACT – Using XACT – Using XACT Projects in an XNA Game – XACT Sound Loops – 3D Audio Effects: Location – 3D Audio Effects: Attenuation based on Distance
  • 35. Using XACT • Small Tutorials – http://rbwhitaker.wikidot.com/audio-tutorials • http://rbwhitaker.wikidot.com/using-xact • http://rbwhitaker.wikidot.com/playing-sound • http://rbwhitaker.wikidot.com/xact-sound-loops • http://rbwhitaker.wikidot.com/3d-audio-effects-location – Books • Microsoft Book • Aaron Reed (O’Reilly)
  • 37. Video Playback • Loading the Video in XNA, Game1 Global Scope Video video; VideoPlayer player;
  • 38. Video Playback • Loading the Video in XNA, Game1 Global Scope • LoadContent() Video video; VideoPlayer player; video = Content.Load<Video>("AVideoToPlayback"); player = new VideoPlayer();
  • 39. Video Playback • Starting the Video player.Play(video);
  • 40. Video Playback • Starting the Video • Update() player.Play(video); if (player.State == MediaState.Stopped) { player.IsLooped = true; player.Play(video); }
  • 42. Video Playback • Drawing the Video, Draw() Texture2D videoTexture = null; if (player.State!= MediaState.Stopped) videoTexture = player.GetTexture();
  • 43. Video Playback • Drawing the Video, Draw() Texture2D videoTexture = null; if (player.State!= MediaState.Stopped) videoTexture = player.GetTexture();
  • 44. Video Playback • Drawing the Video, Draw() Texture2D videoTexture = null; if (player.State!= MediaState.Stopped) videoTexture = player.GetTexture();
  • 45. Video Playback • Drawing the Video, Draw() Texture2D videoTexture = null; if (player.State!= MediaState.Stopped) videoTexture = player.GetTexture();
  • 46. Video Playback • Drawing the Video, Draw() Texture2D videoTexture = null; if (player.State!= MediaState.Stopped) videoTexture = player.GetTexture(); if (videoTexture!= null) { spriteBatch.Begin(); spriteBatch.Draw(videoTexture, new Rectangle(0, 0, 400, 300), Color.White); spriteBatch.End(); }