SlideShare a Scribd company logo
1 of 37
Cross-platform physics
games
Using MonoGame and
Farseer Physics
Rune Andreas Grimstad @runegri
Capgemini Norge
What to expect
• Lots of code!
• Intoduction to MonoGame and Farseer
• Playable demos
• Code on GitHub for you to play with :-)
What NOT to expect
• Deep dive into the features
• That would take days...
• 3D games
• Visit Richard Garside’s talk tomorrow at 11:40
• A complete game
Who am I?
• Rune Andreas Grimstad
• Lives in Trondheim
• Works for Cagemini
• Focus on .Net and anything mobile
• Programming since I was 8 years old...
Why games programming?
• Not my job!
• Fun
• Learning
• Becoming a billionaire after creating the next Angry
Birds Flappy Bird!
MonoGame
• Open Source implementation of XNA 4
• Runs everywhere
• C# / .Net
• Xamarin
Fez
Bastion
Draw a Stickman Epic
Transistor
MonoGame – getting it
• Download from monogame.net
• Clone from GitHub
• NuGet
MonoGame – features
• Supports all features of XNA4 (more or less)
• 2D
• 3D
• Content pipeline
• Input
• Sound and music
• Networking
• It’s a bare-bones framework…
Enough background!
How MonoGame works
- The Game Loop
Initialize and load
content
Update
game state
Draw
everything
Unload content
How MonoGame works
- Creating content
• Most file types are supported
• Either use an XNA content project
• Requires XNA Game Studio, so Windows only
• Create a MonoGame Content project
• Or use the MonoGame Content Builder
• Runs everywhere
• Not 100% done yet, but getting close
How MonoGame works
- Loading content
• Using the ContentManager.Load method
• Usually Content.Load<Texture2D>("spaceship");
• You can also load other resources this way
• SpriteFont, SoundEffect, Song, and so on
• Store the files in the Content folder in your project
• Build Action – Content
• Copy to Output Directory – Copy if newer
How MonoGame works
- Drawing stuff
• Use the SpriteBatch class
• Start with SpriteBatch.Begin
• Do your SpriteBatch.Draw calls
• End with SpriteBatch.End
• Try to limit how many SpriteBatches you use
Demo 1
• The basics
• Draw a sprite on screen
• Content
• Animation
• Camera, pan & zoom
• Input
Demo 1 – What did we learn?
• Game loop
• Content
• SpriteBatch
• Texture atlas
• Camera
• Input
All that from this little guy!
But there is more
Farseer physics
Farseer Physics Engine is a
collision detection system
with realistic physics
responses.
Farseer physics
• 2D Physics simulation
• Collision detection
• Objects with any shape
• Friction and restitution
• Joints
• Gravity
... and more
Farseer physics – getting it
• NuGet
• Download from
https://farseerphysics.codeplex.com/
• Build from sources
• The easiest way to combine with MonoGame?
One thing to be aware of
• Farseer uses the KMS system (Kilo, Meters,
Seconds)
• Use the ConvertUnits class
• Init with SetDisplayUnitToSimUnitRatio
• Use ToDisplayUnits and ToSimUnits
Your screen
Display coordinates: 1920 x 1080 pixels
Farseer coordinates: 19.2 x 10.8 meters
Demo 2 – more Bubble Bobble!
• A simple platformer
• Simulates a world
• Sprites are bodies in the world
• Collision detection
• Movement
Bubbles!
Demo 2 – what did we learn?
• Using Farseer!
• Worlds
• Bodies
• World and display coordinates
More features of Farseer Physics
• Polygon shapes
• Turning an image into a polygon in the game world
• Complex objects
• Combining many shapes into a single object
• Joints
• Attaching bodies to each other
Demo 3 – Exploring the cave
• Stupid game with lots of physics
• Polygon objects
• Complex objects
• Disabling gravity
• Attaching objects
Polygon shapes
Turn this... ... into this
MAGIC!
Polygon shapes
Complex objects
• Add many shapes to one body
Complex objects
• Join bodies using joints
• Revolute joints can be used to create a chain or rope
• Use the RopeJoint to set the length of the rope
• The possibilities are endless!
Finally
• There is much more to MonoGame!
• 3D – Richard Garside will talk about this tomorrow!
• Pixel shaders and effects
• Sound and music
• Use the SoundEffect and Song classes
• Input beyond the keyboard
• Mouse
• Touch
• Joystick
Finally finally
• Find my code samples on GitHub
• github.com/runegri
• And my slides on SlideShare
• slideshare.net/runegri
Get in touch
• I’m here for the rest of the conference
• Twitter: @runegri
• Email: rag@rag.no

More Related Content

Viewers also liked

Road to Success (July 1st) - Mobile Game Development Alternatives - Andrew Bu...
Road to Success (July 1st) - Mobile Game Development Alternatives - Andrew Bu...Road to Success (July 1st) - Mobile Game Development Alternatives - Andrew Bu...
Road to Success (July 1st) - Mobile Game Development Alternatives - Andrew Bu...SanaChoudary
 
EastBay.NET - Introduction to MonoTouch
EastBay.NET - Introduction to MonoTouchEastBay.NET - Introduction to MonoTouch
EastBay.NET - Introduction to MonoTouchmobiweave
 
Introduction to CocosSharp
Introduction to CocosSharpIntroduction to CocosSharp
Introduction to CocosSharpJames Montemagno
 
Generative Art Hands On with F#
Generative Art Hands On with F#Generative Art Hands On with F#
Generative Art Hands On with F#Phillip Trelford
 
Monogame and xna
Monogame and xnaMonogame and xna
Monogame and xnaLee Stott
 
Intro to Gaming- MonoGame/CocosSharp/UrhoSharp
Intro to Gaming- MonoGame/CocosSharp/UrhoSharpIntro to Gaming- MonoGame/CocosSharp/UrhoSharp
Intro to Gaming- MonoGame/CocosSharp/UrhoSharpVidyasagar Machupalli
 
Tips & Tricks that every game developer should know
Tips & Tricks that every game developer should knowTips & Tricks that every game developer should know
Tips & Tricks that every game developer should knowGorm Lai
 
Flappy bird game in c#
Flappy bird game in c#Flappy bird game in c#
Flappy bird game in c#Comstas
 
Ready, steady, cross platform games - ProgNet 2015
Ready, steady, cross platform games - ProgNet 2015Ready, steady, cross platform games - ProgNet 2015
Ready, steady, cross platform games - ProgNet 2015Phillip Trelford
 
UniteKorea2014 - Making flappy bird workshop
UniteKorea2014 - Making flappy bird workshopUniteKorea2014 - Making flappy bird workshop
UniteKorea2014 - Making flappy bird workshopGukHwan Ji
 
Smyowl - desenvolvimento games win8
Smyowl - desenvolvimento games win8Smyowl - desenvolvimento games win8
Smyowl - desenvolvimento games win8Mauricio Alegretti
 
Desenvolvendo Jogos 2D em HTML5 - Cocos2d-x
Desenvolvendo Jogos 2D em HTML5 - Cocos2d-xDesenvolvendo Jogos 2D em HTML5 - Cocos2d-x
Desenvolvendo Jogos 2D em HTML5 - Cocos2d-xPedro Kayatt
 
Final project report of a game
Final project report of a gameFinal project report of a game
Final project report of a gameNadia Nahar
 

Viewers also liked (17)

Road to Success (July 1st) - Mobile Game Development Alternatives - Andrew Bu...
Road to Success (July 1st) - Mobile Game Development Alternatives - Andrew Bu...Road to Success (July 1st) - Mobile Game Development Alternatives - Andrew Bu...
Road to Success (July 1st) - Mobile Game Development Alternatives - Andrew Bu...
 
EastBay.NET - Introduction to MonoTouch
EastBay.NET - Introduction to MonoTouchEastBay.NET - Introduction to MonoTouch
EastBay.NET - Introduction to MonoTouch
 
Introduction to CocosSharp
Introduction to CocosSharpIntroduction to CocosSharp
Introduction to CocosSharp
 
Gaming in Csharp
Gaming in CsharpGaming in Csharp
Gaming in Csharp
 
Generative Art Hands On with F#
Generative Art Hands On with F#Generative Art Hands On with F#
Generative Art Hands On with F#
 
Monogame and xna
Monogame and xnaMonogame and xna
Monogame and xna
 
Intro to Gaming- MonoGame/CocosSharp/UrhoSharp
Intro to Gaming- MonoGame/CocosSharp/UrhoSharpIntro to Gaming- MonoGame/CocosSharp/UrhoSharp
Intro to Gaming- MonoGame/CocosSharp/UrhoSharp
 
Tips & Tricks that every game developer should know
Tips & Tricks that every game developer should knowTips & Tricks that every game developer should know
Tips & Tricks that every game developer should know
 
Flappy bird game in c#
Flappy bird game in c#Flappy bird game in c#
Flappy bird game in c#
 
Ready, steady, cross platform games - ProgNet 2015
Ready, steady, cross platform games - ProgNet 2015Ready, steady, cross platform games - ProgNet 2015
Ready, steady, cross platform games - ProgNet 2015
 
Building a game in a day
Building a game in a dayBuilding a game in a day
Building a game in a day
 
Mobile F#un
Mobile F#unMobile F#un
Mobile F#un
 
UniteKorea2014 - Making flappy bird workshop
UniteKorea2014 - Making flappy bird workshopUniteKorea2014 - Making flappy bird workshop
UniteKorea2014 - Making flappy bird workshop
 
Smyowl - desenvolvimento games win8
Smyowl - desenvolvimento games win8Smyowl - desenvolvimento games win8
Smyowl - desenvolvimento games win8
 
Desenvolvendo Jogos 2D em HTML5 - Cocos2d-x
Desenvolvendo Jogos 2D em HTML5 - Cocos2d-xDesenvolvendo Jogos 2D em HTML5 - Cocos2d-x
Desenvolvendo Jogos 2D em HTML5 - Cocos2d-x
 
Final project report of a game
Final project report of a gameFinal project report of a game
Final project report of a game
 
Snake game
Snake gameSnake game
Snake game
 

Similar to Cross platform physics games - NDC 2014

So You Finally Got Your Job at GameDev. What's next?
So You Finally Got Your Job at GameDev. What's next?So You Finally Got Your Job at GameDev. What's next?
So You Finally Got Your Job at GameDev. What's next?Taras Leskiv
 
Eating Fruit - Combining Robots & Apps
Eating Fruit - Combining Robots & AppsEating Fruit - Combining Robots & Apps
Eating Fruit - Combining Robots & AppsRobotGrrl
 
Super Gun Kids: The Making Of by Iain Lobb
Super Gun Kids: The Making Of by Iain LobbSuper Gun Kids: The Making Of by Iain Lobb
Super Gun Kids: The Making Of by Iain Lobbmochimedia
 
Enabling Creativity: Software that encourages creation and exploration
Enabling Creativity: Software that encourages creation and explorationEnabling Creativity: Software that encourages creation and exploration
Enabling Creativity: Software that encourages creation and explorationKevin Lawver
 
nunuStudio Geometrix 2017
nunuStudio Geometrix 2017nunuStudio Geometrix 2017
nunuStudio Geometrix 2017José Ferrão
 
The raspberry pi – building an internet radio
The raspberry pi – building an internet radioThe raspberry pi – building an internet radio
The raspberry pi – building an internet radioGibraltar Software
 
Building an Internet Radio on the RaspberryPI
Building an Internet Radio on the RaspberryPIBuilding an Internet Radio on the RaspberryPI
Building an Internet Radio on the RaspberryPIGary Short
 
Game tech using kodu adarsha
Game tech using kodu adarshaGame tech using kodu adarsha
Game tech using kodu adarshaAdarsha Datta
 
A Brief Game Jam Survival Guide
A Brief Game Jam Survival GuideA Brief Game Jam Survival Guide
A Brief Game Jam Survival GuideLuca Galli
 
Best Practices for Fast Game Design in Unity
Best Practices for Fast Game Design in UnityBest Practices for Fast Game Design in Unity
Best Practices for Fast Game Design in UnityUnity Technologies
 
TiConf 2014 Game Dev with Titanium and Platino 5/10/14
TiConf 2014 Game Dev with Titanium and Platino 5/10/14TiConf 2014 Game Dev with Titanium and Platino 5/10/14
TiConf 2014 Game Dev with Titanium and Platino 5/10/14gouldjw13
 
Making HTML5 Games with Phaser
Making HTML5 Games with PhaserMaking HTML5 Games with Phaser
Making HTML5 Games with PhaserIndieOutpost
 
Horizon Zero Dawn: The Early Days
Horizon Zero Dawn: The Early DaysHorizon Zero Dawn: The Early Days
Horizon Zero Dawn: The Early DaysDevGAMM Conference
 
Gamemaker - Intro and Core Objects
Gamemaker - Intro and Core ObjectsGamemaker - Intro and Core Objects
Gamemaker - Intro and Core ObjectsJoe Healy
 
Development and Optimization of GearVR games using Unreal Engine
Development and Optimization of GearVR games using Unreal EngineDevelopment and Optimization of GearVR games using Unreal Engine
Development and Optimization of GearVR games using Unreal EngineVinicius Vecchi
 
Casual and Social Games with Unity
Casual and Social Games with UnityCasual and Social Games with Unity
Casual and Social Games with UnityTadej Gregorcic
 

Similar to Cross platform physics games - NDC 2014 (20)

So You Finally Got Your Job at GameDev. What's next?
So You Finally Got Your Job at GameDev. What's next?So You Finally Got Your Job at GameDev. What's next?
So You Finally Got Your Job at GameDev. What's next?
 
Eating Fruit - Combining Robots & Apps
Eating Fruit - Combining Robots & AppsEating Fruit - Combining Robots & Apps
Eating Fruit - Combining Robots & Apps
 
Super Gun Kids: The Making Of by Iain Lobb
Super Gun Kids: The Making Of by Iain LobbSuper Gun Kids: The Making Of by Iain Lobb
Super Gun Kids: The Making Of by Iain Lobb
 
Enabling Creativity: Software that encourages creation and exploration
Enabling Creativity: Software that encourages creation and explorationEnabling Creativity: Software that encourages creation and exploration
Enabling Creativity: Software that encourages creation and exploration
 
nunuStudio Geometrix 2017
nunuStudio Geometrix 2017nunuStudio Geometrix 2017
nunuStudio Geometrix 2017
 
Games withflare3d
Games withflare3dGames withflare3d
Games withflare3d
 
The raspberry pi – building an internet radio
The raspberry pi – building an internet radioThe raspberry pi – building an internet radio
The raspberry pi – building an internet radio
 
Building an Internet Radio on the RaspberryPI
Building an Internet Radio on the RaspberryPIBuilding an Internet Radio on the RaspberryPI
Building an Internet Radio on the RaspberryPI
 
Game tech using kodu adarsha
Game tech using kodu adarshaGame tech using kodu adarsha
Game tech using kodu adarsha
 
A Brief Game Jam Survival Guide
A Brief Game Jam Survival GuideA Brief Game Jam Survival Guide
A Brief Game Jam Survival Guide
 
Best Practices for Fast Game Design in Unity
Best Practices for Fast Game Design in UnityBest Practices for Fast Game Design in Unity
Best Practices for Fast Game Design in Unity
 
Python Introduction
Python IntroductionPython Introduction
Python Introduction
 
TiConf 2014 Game Dev with Titanium and Platino 5/10/14
TiConf 2014 Game Dev with Titanium and Platino 5/10/14TiConf 2014 Game Dev with Titanium and Platino 5/10/14
TiConf 2014 Game Dev with Titanium and Platino 5/10/14
 
XNA in a Day
XNA in a DayXNA in a Day
XNA in a Day
 
From Web to Mobile with Stage 3D
From Web to Mobile with Stage 3DFrom Web to Mobile with Stage 3D
From Web to Mobile with Stage 3D
 
Making HTML5 Games with Phaser
Making HTML5 Games with PhaserMaking HTML5 Games with Phaser
Making HTML5 Games with Phaser
 
Horizon Zero Dawn: The Early Days
Horizon Zero Dawn: The Early DaysHorizon Zero Dawn: The Early Days
Horizon Zero Dawn: The Early Days
 
Gamemaker - Intro and Core Objects
Gamemaker - Intro and Core ObjectsGamemaker - Intro and Core Objects
Gamemaker - Intro and Core Objects
 
Development and Optimization of GearVR games using Unreal Engine
Development and Optimization of GearVR games using Unreal EngineDevelopment and Optimization of GearVR games using Unreal Engine
Development and Optimization of GearVR games using Unreal Engine
 
Casual and Social Games with Unity
Casual and Social Games with UnityCasual and Social Games with Unity
Casual and Social Games with Unity
 

Recently uploaded

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
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
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
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
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 

Recently uploaded (20)

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
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...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
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 ...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
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
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 

Cross platform physics games - NDC 2014

  • 1. Cross-platform physics games Using MonoGame and Farseer Physics Rune Andreas Grimstad @runegri Capgemini Norge
  • 2. What to expect • Lots of code! • Intoduction to MonoGame and Farseer • Playable demos • Code on GitHub for you to play with :-)
  • 3. What NOT to expect • Deep dive into the features • That would take days... • 3D games • Visit Richard Garside’s talk tomorrow at 11:40 • A complete game
  • 4. Who am I? • Rune Andreas Grimstad • Lives in Trondheim • Works for Cagemini • Focus on .Net and anything mobile • Programming since I was 8 years old...
  • 5. Why games programming? • Not my job! • Fun • Learning • Becoming a billionaire after creating the next Angry Birds Flappy Bird!
  • 6.
  • 7. MonoGame • Open Source implementation of XNA 4 • Runs everywhere • C# / .Net • Xamarin
  • 8. Fez
  • 12. MonoGame – getting it • Download from monogame.net • Clone from GitHub • NuGet
  • 13. MonoGame – features • Supports all features of XNA4 (more or less) • 2D • 3D • Content pipeline • Input • Sound and music • Networking • It’s a bare-bones framework…
  • 15. How MonoGame works - The Game Loop Initialize and load content Update game state Draw everything Unload content
  • 16. How MonoGame works - Creating content • Most file types are supported • Either use an XNA content project • Requires XNA Game Studio, so Windows only • Create a MonoGame Content project • Or use the MonoGame Content Builder • Runs everywhere • Not 100% done yet, but getting close
  • 17. How MonoGame works - Loading content • Using the ContentManager.Load method • Usually Content.Load<Texture2D>("spaceship"); • You can also load other resources this way • SpriteFont, SoundEffect, Song, and so on • Store the files in the Content folder in your project • Build Action – Content • Copy to Output Directory – Copy if newer
  • 18. How MonoGame works - Drawing stuff • Use the SpriteBatch class • Start with SpriteBatch.Begin • Do your SpriteBatch.Draw calls • End with SpriteBatch.End • Try to limit how many SpriteBatches you use
  • 19. Demo 1 • The basics • Draw a sprite on screen • Content • Animation • Camera, pan & zoom • Input
  • 20. Demo 1 – What did we learn? • Game loop • Content • SpriteBatch • Texture atlas • Camera • Input
  • 21. All that from this little guy!
  • 22. But there is more
  • 23. Farseer physics Farseer Physics Engine is a collision detection system with realistic physics responses.
  • 24. Farseer physics • 2D Physics simulation • Collision detection • Objects with any shape • Friction and restitution • Joints • Gravity ... and more
  • 25. Farseer physics – getting it • NuGet • Download from https://farseerphysics.codeplex.com/ • Build from sources • The easiest way to combine with MonoGame?
  • 26. One thing to be aware of • Farseer uses the KMS system (Kilo, Meters, Seconds) • Use the ConvertUnits class • Init with SetDisplayUnitToSimUnitRatio • Use ToDisplayUnits and ToSimUnits Your screen Display coordinates: 1920 x 1080 pixels Farseer coordinates: 19.2 x 10.8 meters
  • 27. Demo 2 – more Bubble Bobble! • A simple platformer • Simulates a world • Sprites are bodies in the world • Collision detection • Movement Bubbles!
  • 28. Demo 2 – what did we learn? • Using Farseer! • Worlds • Bodies • World and display coordinates
  • 29. More features of Farseer Physics • Polygon shapes • Turning an image into a polygon in the game world • Complex objects • Combining many shapes into a single object • Joints • Attaching bodies to each other
  • 30. Demo 3 – Exploring the cave • Stupid game with lots of physics • Polygon objects • Complex objects • Disabling gravity • Attaching objects
  • 31. Polygon shapes Turn this... ... into this MAGIC!
  • 33. Complex objects • Add many shapes to one body
  • 34. Complex objects • Join bodies using joints • Revolute joints can be used to create a chain or rope • Use the RopeJoint to set the length of the rope • The possibilities are endless!
  • 35. Finally • There is much more to MonoGame! • 3D – Richard Garside will talk about this tomorrow! • Pixel shaders and effects • Sound and music • Use the SoundEffect and Song classes • Input beyond the keyboard • Mouse • Touch • Joystick
  • 36. Finally finally • Find my code samples on GitHub • github.com/runegri • And my slides on SlideShare • slideshare.net/runegri
  • 37. Get in touch • I’m here for the rest of the conference • Twitter: @runegri • Email: rag@rag.no