/// <summary> /// /// </summary> /// <param name="game"></param> /// <param name="world"></param> /// <param name="position">The top left corner</param> /// <param name="width">The width of the container</param> /// <param name="height">The height of a container</param> public Water(Game game, SpriteBatch spriteBatch, World world, Vector2 position, float width, float height) { sprite = new LoopSpriteAnimator(game, spriteBatch, game.Content.Load<Texture2D>("Images/Sprites/gb"), 200, 6, 1, 6); position = new Vector2(position.X + width/2,position.Y + height/2); texture = new TexturedGameEntity(game, position,0,"Images/water",0.3f); var container = new AABB(ConvertUnits.ToSimUnits(position),ConvertUnits.ToSimUnits(width),ConvertUnits.ToSimUnits(height)); var buoyancy = new BuoyancyController(container, 1.1f, 2, 1, world.Gravity); world.AddController(buoyancy); }
public Water(World w, int index, Vector2 pos, string width, string height) : base() { this.world = w; this.Index = index; this.width = float.Parse(width); this.height = float.Parse(height); this.Position = pos; this.Container = new AABB((pos - new Vector2(this.width / 2, this.height / 2)) * MainGame.PIXEL_TO_METER, (pos + new Vector2(this.width / 2, this.height / 2)) * MainGame.PIXEL_TO_METER); BuoyancyController buoyancy = new BuoyancyController(Container, 1.0f, 0.3f, 0.3f, w.Gravity); buoyancy.AddDisabledCategory(Category.Cat1); w.AddController(buoyancy); this.texture = MainGame.blank; }
public WheelSet(World world, Car car, Vector2 position, float orientation) { Matrix rotation = Matrix.CreateRotationZ(orientation); LeftFront = new RevoluteWheel(world, car, position + Vector2.Transform(Car.WHEEL_POS_LF, rotation), orientation); RightFront = new RevoluteWheel(world, car, position + Vector2.Transform(Car.WHEEL_POS_RF, rotation), orientation); LeftRear = new FixedWheel(world, car, position + Vector2.Transform(Car.WHEEL_POS_LR, rotation), Car.WHEEL_POS_LR, orientation); RightRear = new FixedWheel(world, car, position + Vector2.Transform(Car.WHEEL_POS_RR, rotation), Car.WHEEL_POS_RR, orientation); Controller = new TensorDampingController(); Controller.SetAxisAligned(0, 100); Controller.AddBody(LeftFront.Body); Controller.AddBody(RightFront.Body); Controller.AddBody(LeftRear.Body); Controller.AddBody(RightRear.Body); world.AddController(Controller); }
/// <summary> /// Perform any initialization necessary before running the game. This /// includes both (preliminary) model and view creation. /// </summary> protected override void Initialize() { canvas.Initialize(this); canvas.Scale = scale * Vector2.One; world = new World(new Vector2(0,GRAVITY)); world.ContactManager.BeginContact += ContactStarted; world.ContactManager.EndContact += ContactEnded; canvas.LoadContent(content); ribbon_segment = canvas.GetTexture("ribbon_segment"); /*List<Vector2> path = new List<Vector2>(); path.Add(new Vector2(100, 100)); path.Add(new Vector2(500, 100));*/ //ribbon = new RibbonObject(world, ribbon_segment, new Vector2(100,100), ribbon_segment.Width, path); seamstress = new SeamstressObject(); seamstressController = new SeamstressForceController(seamstress); world.AddController(seamstressController); /*ribbonController = new RibbonForceController(ribbon); world.AddController(ribbonController);*/ objects = new List<Object>(); //objects.Add(ribbon); objects.Add(seamstress); base.Initialize(); }