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
 
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
 
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
 
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
 
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
 
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
 
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

unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 

Recently uploaded (20)

unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 

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