This project has moved and is read-only. For the latest updates, please go here.

collision with window boundaries

Topics: User Forum
May 20, 2010 at 12:58 PM


I started playing around with the Farseer engine and I created a small program, with two boxes that can be maneuvered around with the keyboard.

There are some more things I would like to add to my program:

-1. my boxes do not detect the borders of the simulated view, they can left the screen. What should I add to my code, so that they collide with the window boundaries?

-2. in some of the Demos you can use the mouse to throw the boxes around. But I didn’t find a mouse function inside of the Demo code. How can this be accomplished?

-3. I would like to use textures instead of the boxes. Is there a newbie proofed tutorial for this around?



May 20, 2010 at 1:11 PM
Edited May 20, 2010 at 1:12 PM

1: This would depend, if you want your box to 'bounce' of the wall, or just not being able to move through it? If you just want it to stop, you can just edit the method that does the moving; If the position is outside the boundary don't move it anymore. (set the velocity to zero). 

It you want it to bounce, the best way I can think of right now is to make four new geoms, that are placed along the sides og the window.


3: Are you familiar with the XNA-way of drawing textures? If so, you just use the drawcall that takes a position, offset origin and rotation. Get these from the body. If not, i suggest you do some of the tutorials at =)