SpriteHand
Module Border
  Physics Behaviors for Silverlight 3!
Module Border
Location: BlogsAndy's Blog    
Posted by: host 7/15/2009 7:21 PM


Today I released an initial version of “Physics Helper 3” to Codeplex. This includes a collection of new Behaviors for Expression Blend which makes it very quick to create physics games and simulations in Silverlight using the Farseer Physics Engine. This release requires Silverlight 3 and Expression Blend 3, which you can get here.

DOWNLOAD PHYSICS HELPER 3

Demos

There are four new demos using Behaviors, plus the original demos depending on the older User Control model. Note that version 3 still supports the User Control model, but I would recommend checking out the new Behaviors model as there is nice design time support in Blend.

VIEW ALL DEMOS

Demo Behaviors 1
Falling Astronaut
Demo Behaviors 2
Rag Doll
Demo Behaviors 3
Truck w/Camera
Demo Behaviors 4
Flying Astronaut

Getting Started Videos

I have a couple of quick (10 min) screen casts which show how to use the new Physics Behaviors:

VIDEO ON "THE BASICS": VIEW | DOWNLOAD

VIDEO ON "JOINTS + PROGRAMMING": VIEW | DOWNLOAD

Enhancing Behaviors with Code

Behaviors are great, but I can't imagine creating a full game using only canned behaviors. So at some point, you will need to add code to do AI, control levels and game state, and other tasks. Here are some pointers to get started with that:

Once you drop a PhysicsController Behavior onto your main Canvas, you can later get a reference to that Physics Controller (the object that contains the simulation context) in code. Suppose your main Canvas is named "LayoutRoot" then you can get a reference as follows:

PhysicsControllerMain _physicsController = LayoutRoot.GetValue(PhysicsControllerMain.PhysicsControllerProperty) as PhysicsControllerMain;

After you have a reference to the PhysicsController, you can modify any of the Farseer Physics Geometry or Body objects by getting a reference throught the PhysicsObjects dictionary:

_physicsController.PhysicsObjects["ball"].GeometryObject.RestitutionCoefficient = 1.3F;

... and you can also get a reference to the oringal XAML UI Element using the uiElement property of the Physics Object:

Ellipse ball = _physicsController.PhysicsObjects["ball"].uiElement as Ellipse;
ball.Fill = new SolidColorBrush(Colors.Red);

Feedback and Issues

This is an initial release and my first swing at Behaviors, so I'm sure there will be issues and suggestions. Please let them fly on the Codeplex Forum, and I hope you have fun! 

Permalink |  Trackback

Comments (8)   Add Comment
Re: Physics Behaviors for Silverlight 3!    By Anonymous on 7/17/2009 8:18 PM
Way cool Andy!!! Congrats.

- Rodrigo Díaz Concha http://rdiazconcha.com

Re: Physics Behaviors for Silverlight 3!    By Anonymous on 7/20/2009 10:35 AM
You are the man. Thank you for doing this. Abstractions (making hard stuff easy like this ) is the highest form of Programming mastery.

Re: Physics Behaviors for Silverlight 3!    By Anonymous on 7/28/2009 9:12 AM
Immense work :)

Re: Physics Behaviors for Silverlight 3!    By Anonymous on 8/11/2009 10:17 PM
Hi,
I have been playing around with the idea of behaviors in my Silverlight games (http://bit.ly/7Ract). I will definitely try out your Physics behaviors. They look really interesting and useful.

I am interested in your comment though that not everything can be done using behaviors. I had all my game code done as part of behaviors. Though it is not neatest at the moment I can still think of an elegant way of doing it all in behaviors.

For AI I was just thinking to have a NPC behavior which would control a Image/XAML control. Controlling levels and states could be done using States and Navigation. I could have a Game Over trigger which gets fired when the Player had died enough number of times which would trigger the action to show the Replay dialog.

For me behaviors has been really useful in separating the Developer and Game Designer in me and allowed me to focus better on the task at hand.

Let me know what you think.

Re: Physics Behaviors for Silverlight 3!    By Anonymous on 8/12/2009 6:26 AM
Yeah, I guess I should rephrase what I said :)

For working on a specific solution (like a single game or class of games), then it's certainly possible to do everything in Behaviors.

But for a generic library of Behaviors like the Physics Behaviors, it would be hard to cover everything needed like AI, scoring, level control, etc.

So I suppose that you could start with the Physics Behaviors, and then add in your own behaviors on top of it if you want to entirely separate the Designer/Developer process.

-Andy

Re: Physics Behaviors for Silverlight 3!    By Anonymous on 8/18/2009 12:08 PM
Cool deal. I'll show this in my Blend 3 session today.

Re: Physics Behaviors for Silverlight 3!    By Anonymous on 8/22/2009 4:44 PM
Hi Andy,
This is such great stuff! I cannot stop playing with this and I have turned your Truck w/Camera demo into my MINI Clubman Physics demo http://bit.ly/tSa5L

Re: Physics Behaviors for Silverlight 3!    By Anonymous on 6/4/2010 1:59 AM
There is a game on FaceBook created using this library http://apps.facebook.com/ittiGator. Friend of mine and i coded this in very short time.


Title:
Comment:
Add Comment   Cancel 
Module Border Module Border
Module Border
  Subscribe
Module Border
RSS   Twitter
Module Border Module Border
Module Border
  Diversions
Module Border

TALKING RAGDOLL
This Windows Phone 7 App was created using Silverlight, the  Physics Helper Library,  and the Farseer Physics Engine. It gets interesting when you import your friends photos and have your way with them!

MORE INFO



DROPPYPOP
This Windows Phone 7 game was created using Silverlight, the  Physics Helper Library,  and the Farseer Physics Engine.
DEMO

MORE INFO



BOSS LAUNCH
This physics game won first place in the Server Quest Contest. Created using Silverlight 2, the Physics Helper Library,  and the Farseer Physics Engine.
PLAY IT

MORE INFO



DESTROY ALL INVADERS
A scrolling shooter game where the objective is to destroy the invading UFO's flying over a neighborhood of your choosing. Imagery provided by Microsoft Virtual Earth. Created using Silverlight 2.
PLAY IT

INFO AND CODE



PHYSICS HELPER DEMOS
These demos were created for the Physics Helper Library, which makes it easy to create physics games and simulations using Expression Blend, Silverlight, and the Farseer Physics Engine.
PLAY IT

INFO AND CODE



HOOK SHOT
This little basketball game took first place in the TeamZoneSports Silverlight Contest. Created using Silverlight 2 and the Farseer Physics engine.
PLAY IT

MORE INFO



SORT THE FOOBARS
A game where you need to sort the good foobars from the bad ones. Created using Silverlight 2 and the Farseer Physics engine.
PLAY IT

MORE INFO



POLYGON PHYSICS DEMO
A demo showing polygon physics where the user draws physics objects with the mouse. Created using Silverlight 2 and the Farseer Physics engine.
PLAY IT

MORE INFO



SILVERLIGHT ROCKS!
Destroy the asteroids before they destroy your ship! Created using Silverlight 2.
PLAY IT

INFO AND CODE



FISH GAME
A simple game of harpoon-the-fish. Written using the AJAX Sprite Toolkit.
PLAY IT

INFO AND CODE

Module Border Module Border
Module Border
  Search_Blog
Module Border
Module Border Module Border
Module Border
  Blog_Archive
Module Border
Module Border Module Border
Copyright (c) 2013 andy.beaulieu.com - Login