Software Expressions

.Net / Software / Visual Studio / TFS / other ramblings
 

Goto

Categories

 

Archive for the 'Silverlight' Category

07 19th, 2007

Rigid Body Collisions

Author: Troy

I try not to make a habit of including links on my blog, but this is really impressive. Physics are integral to almost any kind of game development. This site, myphysicslab.com provides excellent math for rubber-bands, springs, gravity, rigid body collision, impulse and inertia. What would be nice is to integrate this math into a base sprite class.

07 18th, 2007

It appears as if there is no timer available for Silverlight. I noticed two options that were utilized; one was using the Storyboard as a timer and another was using System.Windows.Browser.HtmlTimer. Although this causes an obsolete warning, it does work in Silverlight Alpha 1.1, and from some comments on a CodeProject page it looks as if some other timer will become available in the future. So for now I’m going to be using the HtmlTimer to provide the heartbeat for sprites.

   1:  using System.Windows.Browser;
   2:   
   3:  public class WorldBase
   4:  {
   5:      private HtmlTimer _heartBeat = new HtmlTimer();
   6:      private int _beatsPerSecond;
   7:      private DateTime _lastBeat;
   8:   
   9:      public WorldBase()
  10:      {
  11:          _lastBeat = DateTime.Now;
  12:          _heartBeat.Interval = 50;
  13:          _heartBeat.Tick += new EventHandler(_heartBeat_Tick);
  14:          _beatsPerSecond = 50;
  15:          _heartBeat.Enabled = true;
  16:      }
  17:   
  18:      void _heartBeat_Tick(object sender, EventArgs e)
  19:      {
  20:          //Update the BeatsPerSecond
  21:          _beatsPerSecond = 1 / (DateTime.Now - _lastBeat).Seconds;
  22:          //Provide a hearbeat for the world of sprites
  23:          ...
  24:      }
  25:  }
07 12th, 2007

Installing Silverlight

Author: Troy