本文整理汇总了C#中FarseerGames.FarseerPhysics.PhysicsSimulator类的典型用法代码示例。如果您正苦于以下问题:C# PhysicsSimulator类的具体用法?C# PhysicsSimulator怎么用?C# PhysicsSimulator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PhysicsSimulator类属于FarseerGames.FarseerPhysics命名空间,在下文中一共展示了PhysicsSimulator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Round
public Round(PhysicsSimulator simulator, Game game, object initializationData)
{
this.game = game;
this.simulator = simulator;
this.initializationData = initializationData;
this.Construct();
}
示例2: Initialize
public override void Initialize()
{
ClearCanvas();
physicsSimulator = new PhysicsSimulator(new Vector2(0, 100));
physicsSimulator.BiasFactor = .4f;
int borderWidth = (int) (ScreenManager.ScreenHeight*.05f);
_border = new Border(ScreenManager.ScreenWidth + borderWidth*2, ScreenManager.ScreenHeight + borderWidth*2,
borderWidth, ScreenManager.ScreenCenter);
_border.Load(this, physicsSimulator);
_rectangleBody = BodyFactory.Instance.CreateRectangleBody(physicsSimulator, 32, 32, 1f);
_rectangleGeom = GeomFactory.Instance.CreateRectangleGeom(physicsSimulator, _rectangleBody, 32, 32);
_rectangleGeom.FrictionCoefficient = .4f;
_rectangleGeom.RestitutionCoefficient = 0f;
//create the pyramid near the bottom of the screen.
_pyramid = new Pyramid(_rectangleBody, _rectangleGeom, 32f/3f, 32f/3f, 32, 32, _pyramidBaseBodyCount,
new Vector2(ScreenManager.ScreenCenter.X - _pyramidBaseBodyCount*.5f*(32 + 32/3),
ScreenManager.ScreenHeight - 125));
_pyramid.Load(this, physicsSimulator);
_floor = new Floor(ScreenManager.ScreenWidth, 100,
new Vector2(ScreenManager.ScreenCenter.X, ScreenManager.ScreenHeight - 50));
_floor.Load(this, physicsSimulator);
_agent = new Agent(ScreenManager.ScreenCenter - new Vector2(320, 300));
_agent.Load(this, physicsSimulator);
controlledBody = _agent.Body;
base.Initialize();
}
示例3: Load
public void Load(TangramWindow window, PhysicsSimulator physicsSimulator)
{
//use the body factory to create the physics body
this._borderBody = BodyFactory.Instance.CreateRectangleBody(physicsSimulator, this._width, this._height, 1);
this._borderBody.IsStatic = true;
this._borderBody.Position = _position;
LoadBorderGeom(physicsSimulator);
float left = (_position.X - this._width / 2f);
float right = (_position.X + this._width / 2f);
float top = (_position.Y - this._height / 2f);
float bottom = (_position.Y + this._height / 2f);
// rectangle's position should be the point left and top most
Rectangle leftBorder = window.AddRectangleToCanvas(null, Color.FromArgb(128, 255, 255, 255), new Vector2(this._borderWidth, this._height));
TangramWindow.PositionTopLeft(leftBorder, new Vector2(left, top));
Rectangle rightBorder = window.AddRectangleToCanvas(null, Color.FromArgb(128, 255, 255, 255), new Vector2(this._borderWidth, this._height));
TangramWindow.PositionTopLeft(rightBorder, new Vector2(right - _borderWidth, top));
Rectangle topBorder = window.AddRectangleToCanvas(null, Color.FromArgb(128, 255, 255, 255), new Vector2(this._width, this._borderWidth));
TangramWindow.PositionTopLeft(topBorder, new Vector2(left, top));
Rectangle bottomBorder = window.AddRectangleToCanvas(null, Color.FromArgb(128, 255, 255, 255), new Vector2(this._width, this._borderWidth));
TangramWindow.PositionTopLeft(bottomBorder, new Vector2(left, bottom - _borderWidth));
}
示例4: LoadBorderGeom
public void LoadBorderGeom(PhysicsSimulator physicsSimulator)
{
this._borderGeom = new Geom[4];
//left border
Vector2 geometryOffset = new Vector2(-(_width * 0.5f - this._borderWidth * 0.5f), 0);
_borderGeom[0] = GeomFactory.Instance.CreateRectangleGeom(physicsSimulator, this._borderBody,
this._borderWidth, this._height, geometryOffset, 0);
this._borderGeom[0].RestitutionCoefficient = .2f;
this._borderGeom[0].FrictionCoefficient = .5f;
this._borderGeom[0].CollisionGroup = 100;
//right border
geometryOffset = new Vector2((this._width * 0.5f - this._borderWidth * 0.5f), 0);
_borderGeom[1] = GeomFactory.Instance.CreateGeom(physicsSimulator, this._borderBody, this._borderGeom[0],
geometryOffset, 0);
//top border
geometryOffset = new Vector2(0, -(_height*0.5f - this._borderWidth*0.5f));
this._borderGeom[2] = GeomFactory.Instance.CreateRectangleGeom(physicsSimulator, this._borderBody,
this._width, this._borderWidth,
geometryOffset, 0);
this._borderGeom[2].FrictionCoefficient = this._borderGeom[2].RestitutionCoefficient = .2f;
this._borderGeom[2].CollisionGroup = 100;
//bottom border
geometryOffset = new Vector2(0, _height * 0.5f - this._borderWidth * 0.5f);
this._borderGeom[3] = GeomFactory.Instance.CreateGeom(physicsSimulator, this._borderBody,
this._borderGeom[2], geometryOffset, 0);
}
示例5: Load
public void Load(Demo demo, PhysicsSimulator physicsSimulator)
{
//use the body factory to create the physics body
borderBody = BodyFactory.Instance.CreateRectangleBody(physicsSimulator, width, height, 1);
borderBody.IsStatic = true;
borderBody.Position = position;
LoadBorderGeom(physicsSimulator);
float left = (position.X - width / 2f);
float top = (position.Y - height / 2f);
float right = (position.X + width / 2f);
float bottom = (position.Y + height / 2f);
Rectangle leftBorder = demo.AddRectangleToCanvas(null, Color.FromArgb(128, 255, 255, 255),
new Vector2(borderWidth, height));
Demo.PositionTopLeft(leftBorder, new Vector2(left, top));
Rectangle rightBorder = demo.AddRectangleToCanvas(null, Color.FromArgb(128, 255, 255, 255),
new Vector2(borderWidth, height));
Demo.PositionTopLeft(rightBorder, new Vector2(right-borderWidth, top));
Rectangle topBorder = demo.AddRectangleToCanvas(null, Color.FromArgb(128, 255, 255, 255),
new Vector2(width, borderWidth));
Demo.PositionTopLeft(topBorder, new Vector2(left, top));
Rectangle bottomBorder = demo.AddRectangleToCanvas(null, Color.FromArgb(128, 255, 255, 255),
new Vector2(width, borderWidth));
Demo.PositionTopLeft(bottomBorder, new Vector2(left, bottom - borderWidth));
}
示例6: Load
public void Load(Demo demo, PhysicsSimulator physicsSimulator)
{
_circleBody = new Body[_count];
_circleGeom = new Geom[_count];
_circleBody[0] = BodyFactory.Instance.CreateCircleBody(physicsSimulator, _radius, .1f);
_circleBody[0].Position = _startPosition;
demo.AddCircleToCanvas(_circleBody[0], _color, _radius);
for (int i = 1; i < _count; i++)
{
_circleBody[i] = BodyFactory.Instance.CreateBody(physicsSimulator, _circleBody[0]);
_circleBody[i].Position = Vector2.Lerp(_startPosition, _endPosition, i / (float)(_count - 1));
demo.AddCircleToCanvas(_circleBody[i], _color, _radius);
}
_circleGeom[0] = GeomFactory.Instance.CreateCircleGeom(physicsSimulator, _circleBody[0], _radius, 10);
_circleGeom[0].RestitutionCoefficient = .7f;
_circleGeom[0].FrictionCoefficient = .2f;
_circleGeom[0].CollisionCategories = _collisionCategories;
_circleGeom[0].CollidesWith = _collidesWith;
for (int j = 1; j < _count; j++)
{
_circleGeom[j] = GeomFactory.Instance.CreateGeom(physicsSimulator, _circleBody[j], _circleGeom[0]);
}
}
示例7: MenuScreen
//Constructor
public MenuScreen(Game game)
: base(game)
{
screenRect = new Rectangle(0, 0, 800, 600);
shadeTexture = Game.Content.Load<Texture2D>("Media\\GUI\\Shade");
physicsSim = new PhysicsSimulator(new Vector2(0.0f, 2.2f));
//Load Menu screen content
RigidEntity menuBottom = new RigidEntity("MenuBottom", Game.Content.Load<Texture2D>("Media\\Menus\\MainMenuBottom"), ref physicsSim, GeomType.Polygon);
menuBottom.body.IsStatic = true;
menuBottom.body.Position = new Vector2(menuBottom.Origin.X, 200+menuBottom.Origin.Y);
RigidEntity EditorButton = new RigidEntity("BTN_Editor", Game.Content.Load<Texture2D>("Media\\Menus\\EditorButton"), ref physicsSim, GeomType.Circle);
RigidEntity quitButton = new RigidEntity("BTN_Quit", Game.Content.Load<Texture2D>("Media\\Menus\\QuitButton"), ref physicsSim, GeomType.Circle);
RigidEntity w1 = new RigidEntity("WALL1", ref physicsSim, new Vector2(-2.5f,300f), 5, 600);
RigidEntity w2 = new RigidEntity("WALL2", ref physicsSim, new Vector2(802.5f, 300f), 5, 600);
EditorButton.body.Position = new Vector2(200.0f, -220.0f);
EditorButton.Friction = 1.0f;
EditorButton.Restitution = 0.8f;
menuBottom.Restitution = 0.3f;
menuBottom.Friction = 0.8f;
quitButton.body.Position = new Vector2(400.0f,-250.0f);
quitButton.Friction = 1.0f;
quitButton.Restitution = 0.4f;
entityManager = new EntityManager();
entityManager.Add(menuBottom);
entityManager.Add(EditorButton);
entityManager.Add(quitButton);
entityManager.Add(w1);
entityManager.Add(w2);
shadeOpacity = 0;
}
示例8: Initialize
protected override void Initialize(PhysicsSimulator simulator)
{
base.Initialize(simulator);
this.Wind.RefreshRate = 2600;
this.Wind.MaxXScale = 200;
this.Wind.MaxYScale = 200;
}
示例9: CreateMap
protected override MapDefinition CreateMap(PhysicsSimulator simulator)
{
int random = Randomizer.Random.Next(2, 9);
switch (random)
{
case 2:
this.map = new MapBDefinition(simulator);
break;
case 3:
this.map = new MapCDefinition(simulator);
break;
case 4:
this.map = new MapDDefinition(simulator);
break;
case 5:
this.map = new MapEDefinition(simulator);
break;
case 6:
this.map = new MapFDefinition(simulator);
break;
case 7:
this.map = new MapGDefinition(simulator);
break;
case 8:
this.map = new MapHDefinition(simulator);
break;
default:
throw new Exception("Unknown random map index.");
}
return this.map;
}
示例10: Wall
public Wall(PhysicsSimulator simulator)
: base(simulator)
{
this.simulator = simulator;
this.Size = new Vector2(20, Screen.Height);
this.Initialize();
}
示例11: FieldPong
public FieldPong()
{
graphics = new GraphicsDeviceManager(this);
content = new ContentManager(Services);
graphics.PreferredBackBufferWidth = 1024;
graphics.PreferredBackBufferHeight = 768;
graphics.MinimumPixelShaderProfile = ShaderProfile.PS_2_0;
graphics.SynchronizeWithVerticalRetrace = true;
physicsSimulator = new PhysicsSimulator(new Vector2(0));
physicsSimulator.AllowedPenetration = 0.3f;
physicsSimulator.BiasFactor = 1.0f;
Services.AddService(typeof(PhysicsSimulator), physicsSimulator);
screenManager = new ScreenManager(this);
Components.Add(screenManager);
bloomProcessor = new BloomPostProcessor(this);
Components.Add(bloomProcessor);
// Uncomment this to monitor the FPS:
//fpsCounter = new FrameRateCounter(this);
//Components.Add(fpsCounter);
audioEngine = new AudioEngine("Content\\Audio\\FieldPongAudio.xgs");
waveBank = new WaveBank(audioEngine, "Content\\Audio\\Wave Bank.xwb");
soundBank = new SoundBank(audioEngine, "Content\\Audio\\Sound Bank.xsb");
backgroundMusic = soundBank.GetCue("GameSong0010 16 Bit");
backgroundMusic.Play();
}
示例12: Platform
//, int width)
public Platform(string path, PhysicsSimulator pS)
{
bytes=File.ReadAllBytes(path+".bmp");
int width = bytes[18];
int heigth = bytes[22];
for (int i = 0; i < width*heigth; i++)
if (bytes[bytes.Length-1-i]==0)
{
createRectangle(pS, i, width);
}
else if (bytes[bytes.Length - 1 - i] == 1)
{
createTriangle(pS, i, width, Triangles.LeftRightDown);
}
else if (bytes[bytes.Length - 1 - i] == 2)
{
createTriangle(pS, i, width, Triangles.RightLeftDown);
}
else if (bytes[bytes.Length - 1 - i] == 3)
{
createTriangle(pS, i, width, Triangles.RightLeftUp);
}
else if (bytes[bytes.Length - 1 - i] == 4)
{
createTriangle(pS, i, width, Triangles.LeftRightUp);
}
rBodies = new RecBody(path, pS);
}
示例13: Initialize
public override void Initialize()
{
PhysicsSimulator = new PhysicsSimulator(new Vector2(0, 100));
PhysicsSimulatorView = new PhysicsSimulatorView(PhysicsSimulator);
base.Initialize();
}
示例14: Game
public Game(PhysicsSimulator simulator)
{
this.player = new Player(simulator);
this.computer = new Player(simulator);
this.simulator = simulator;
this.rounds = new List<Round>();
}
示例15: Load
public void Load(PhysicsSimulator physicsSimulator, GraphicsDevice device)
{
Random rand = new Random();
physicsSimulator.Add(_topBody);
physicsSimulator.Add(_rightLegBody);
physicsSimulator.Add(_leftLegBody);
physicsSimulator.Add(_topGeom);
physicsSimulator.Add(_rightLegGeom);
physicsSimulator.Add(_leftLegGeom);
_leftWeldJoint = new WeldJoint(_leftLegBody, _topBody, _leftLegBody.Position - new Vector2(-5, _height / 2));
_leftWeldJoint.Breakpoint = (float)rand.NextDouble() * 3f + 1f;
_leftWeldJoint.Broke += _leftWeldJoint_Broke;
physicsSimulator.Add(_leftWeldJoint);
_rightWeldJoint = new WeldJoint(_rightLegBody, _topBody, _rightLegBody.Position - new Vector2(5, _height / 2));
_rightWeldJoint.Breakpoint = (float)rand.NextDouble() * 3f + 1f;
_rightWeldJoint.Broke += _rightWeldJoint_Broke;
physicsSimulator.Add(_rightWeldJoint);
_topBrush = new PolygonBrush(_topGeom.LocalVertices, Color.BurlyWood, Color.Black, 1.0f, 0.5f);
_leftBrush = new PolygonBrush(_leftLegGeom.LocalVertices, Color.BurlyWood, Color.Black, 1.0f, 0.5f);
_rightBrush = new PolygonBrush(_rightLegGeom.LocalVertices, Color.BurlyWood, Color.Black, 1.0f, 0.5f);
_topBrush.Load(device);
_leftBrush.Load(device);
_rightBrush.Load(device);
}