Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm trying to get my head around scrolling a 2D map that uses a physics engine. If I was to launch a projectile, would I actually be applying the physics to the background images rather than the projectile itself? I'd like to keep the projectile at the center of the 'camera', but I'm not sure how to do this in Silverlight. I thought of using a translate transform to constantly scroll the parent canvas's position, but is this the best way of doing this in Silverlight?

Edit - I'm using Farseer Physics with the Physics Helper library.

*Edit 2 - Solution *

It turns out the MSI installer of the Physics Helper installs an older version that had a broken camera. I downloaded and recompiled the latest source version and it now works!

share|improve this question
1  
What physics engine are you using? Did you write your own, or are you trying to decide which one to use? –  Nate Apr 2 '11 at 18:12
    
I'm using Farseer. –  Skoder Apr 2 '11 at 18:20
    
With the Physics Helper library. physicshelper.codeplex.com) –  Skoder Apr 2 '11 at 18:36
add comment

2 Answers

I would suggest you go with a 2D engine that can help you do this. I use FlatRedBall personally, and initially it did have the capability to focus the camera on a single object regardless of that object's velocity or acceleration. (I believe it still does, but I haven't tried this recently.)

Applying forces to all background sprites is not a good idea; you should mimic the natural approach, which is to apply physics on the bullet.

I'm also making a 2D map game in Silverlight, but I haven't reached this point yet due to other constraints. It shouldn't be hard, given a good engine. FRB is good because it handles both graphics and physics simultaneously.

share|improve this answer
    
I'm using Farseer with the Physics Helper. Not sure if you've had much experience with it, but I'm trying to use its camera class (just found out about it). However, I'm having trouble keeping the target element in the center as it just moves off screen whilst the camera only moves very very slightly in the right direction (but doesn't keep up). –  Skoder Apr 2 '11 at 18:21
    
I've heard of Farseer. It interoperates with FRB. Can't say I've used it though; sorry. –  ashes999 Apr 2 '11 at 21:39
    
No problem. I should've mentioned the physics engine in my original question. –  Skoder Apr 2 '11 at 22:06
    
Awesome. If you're not 100% locked in, I would say give FRB a try. It's pretty good; but the tools are mediocre in my estimation. –  ashes999 Apr 2 '11 at 23:08
add comment
up vote 0 down vote accepted

Whoops! Turns out the MSI installer installs an older version that had a broken camera. I downloaded and recompiled the latest source version and it now works!

share|improve this answer
    
You should add this as a comment to your original post. –  ashes999 Apr 4 '11 at 1:04
    
Done :). I have to wait a few hours before I can accept this as the answer. –  Skoder Apr 4 '11 at 1:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.