Skip to content

Instantly share code, notes, and snippets.

@zfogg
Created July 15, 2011 01:06
Show Gist options
  • Save zfogg/1083832 to your computer and use it in GitHub Desktop.
Save zfogg/1083832 to your computer and use it in GitHub Desktop.
Framing
public static List<Body> CreateFraming(World world, int width)
{
List<Body> bodyList = new List<Body>();
float x = WindowSize.X;
float y = WindowSize.Y;
for (float i = 0f; i <= x; i += x)
{
for (float j = 0f; j <= y; j += y)
{
Body newBody = BodyFactory.CreateRectangle(world,
i == 0 ? x : width,
i == 0 ? width : y,
1f);
Vector2 position = new Vector2(
i == 0 ? x / 2 : (i + (j == 0 ? width / 2 : -i + (-width / 2))),
j == 0 ? (i == 0 ? -width / 2 : y / 2) : (i == 0 ? j + width / 2 : j / 2));
newBody.Position = position;
bodyList.Add(newBody);
}
}
return bodyList;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment