public override void SetPosition(float x, float y) { base.SetPosition(x, y); Depth = (int)(Y + Height); sprite.SetPosition(X + Width / 2, Y + Height / 2); debugBounds.SetPosition(X, Y); debugBounds.ApplyChanges(); }
public Test(string name) : base(name) { Tables = new List <Table>(); entities = new List <RelatusObject>(); Player = new Player(200, 0); entities.Add(Player); quad = new Quad(0, 0, WindowManager.PixelWidth * 2, WindowManager.PixelHeight * 2) { Color = Color.Gray }; quad.ApplyChanges(); for (int y = 0; y < WindowManager.PixelHeight * 2 / 41; y++) { for (int x = 0; x < WindowManager.PixelWidth * 2 / 139; x++) { if (x % 2 == 0 && y % 3 == 0) { Tables.Add(new Table(139 * x, 41 * y, Tables.Count)); } } } TableQuadtree = new Quadtree <Table>(new RectangleF(0, 0, WindowManager.PixelWidth * 2, WindowManager.PixelHeight * 2), 256); foreach (Table t in Tables) { TableQuadtree.Insert(t); entities.Add(t); } entities.Add(new Worker(0, 0, true, true)); }
public Player(float x, float y) : base(x, y, 64, 48) { sprite = new Sprite(x, y, "player"); sprite.RotationOffset = new Vector2(sprite.Width / 2, sprite.Height / 2); InputProfile iprofile = new InputProfile("player") .RegisterMapping(new InputMapping("Up") { Keys = new Keys[] { Keys.W, Keys.Up }, GamepadButtons = new Buttons[] { Buttons.DPadUp, Buttons.LeftThumbstickUp, Buttons.RightThumbstickUp } }) .RegisterMapping(new InputMapping("Down") { Keys = new Keys[] { Keys.S, Keys.Down }, GamepadButtons = new Buttons[] { Buttons.DPadDown, Buttons.LeftThumbstickDown, Buttons.RightThumbstickDown } }) .RegisterMapping(new InputMapping("Left") { Keys = new Keys[] { Keys.A, Keys.Left }, GamepadButtons = new Buttons[] { Buttons.DPadLeft, Buttons.LeftThumbstickLeft, Buttons.RightThumbstickLeft } }) .RegisterMapping(new InputMapping("Right") { Keys = new Keys[] { Keys.D, Keys.Right }, GamepadButtons = new Buttons[] { Buttons.DPadRight, Buttons.LeftThumbstickRight, Buttons.RightThumbstickRight } }) .RegisterMapping(new InputMapping("Air") { Keys = new Keys[] { Keys.LeftShift }, GamepadButtons = new Buttons[] { Buttons.LeftTrigger, Buttons.RightTrigger } }); input = new InputHandler(PlayerIndex.One); input.LoadProfile(iprofile); Farts = new List <Gas>(); stepSoundTracker = new Timer(400); canStep = true; fartSoundTracker = new Timer(200); CanFart = true; airCooldown = new Timer(1000); airTimer = new Timer(500); airCooldown.Start(); airTimer.Start(); fartTimer = new Timer(2500); fartTimer.Start(); debugBounds = new Quad(X, Y, Width, Height) { LineWidth = 2 }; debugBounds.ApplyChanges(); DebugManager.RegisterDebugEntry(new DebugEntry("playerPos", "X:{0}, Y:{1}")); SetPosition(X, Y); }