public TestControlManager(Node parent)
     : base(parent, "TestControlManager")
 {
     _upkey = new DoubleInput(this, "UpKey", Keys.Up, Buttons.DPadUp, PlayerIndex.One);
     _downkey = new DoubleInput(this, "DownKey", Keys.Down, Buttons.DPadDown, PlayerIndex.One);
     _leftkey = new DoubleInput(this, "LeftKey", Keys.Left, Buttons.DPadLeft, PlayerIndex.One);
     _rightkey = new DoubleInput(this, "RightKey", Keys.Right, Buttons.DPadRight, PlayerIndex.One);
     _selectkey = new DoubleInput(this, "SelectKey", Keys.Enter, Buttons.A, PlayerIndex.One);
 }
            public CameraController(State stateref, string name)
                : base(stateref, name)
            {
                _up = new DoubleInput(this, "Up", Keys.Up, Buttons.DPadUp, PlayerIndex.One);
                _down = new DoubleInput(this, "Down", Keys.Down, Buttons.DPadDown, PlayerIndex.One);
                _left = new DoubleInput(this, "Left", Keys.Left, Buttons.DPadLeft, PlayerIndex.One);
                _right = new DoubleInput(this, "Right", Keys.Right, Buttons.DPadRight, PlayerIndex.One);
                _zoomIn = new DoubleInput(this, "ZoomIn", Keys.W, Buttons.LeftShoulder, PlayerIndex.One);
                _zoomOut = new DoubleInput(this, "ZoomOut", Keys.S, Buttons.LeftTrigger, PlayerIndex.One);
                _rotateLeft = new DoubleInput(this, "RotateLeft", Keys.A, Buttons.LeftShoulder, PlayerIndex.One);
                _rotateRight = new DoubleInput(this, "RotateRight", Keys.D, Buttons.RightShoulder, PlayerIndex.One);

                _camera = new Camera(this, "Camera");
                _camera.View();
            }
        public PlayerShip(Node parent, string name)
            : base(parent, name)
        {
            Body.X = EntityGame.Viewport.Width / 2f;
            Body.Y = EntityGame.Viewport.Height / 2f;

            Physics.Drag = 0.97f;
            Physics.AngularDrag = 0.9f;

            Render = new ImageRender(this, "Render");
            Render.SetTexture(GetRoot<State>().GetService<AssetCollector>().GetAsset<Texture2D>("ship"));
            Render.Layer = .01f;
            Render.Scale = new Vector2(.128f);
            Render.LinkDependency(ImageRender.DEPENDENCY_BODY, Body);

            Body.Bounds = Render.Bounds;
            Body.Origin = new Vector2(Render.Texture.Width / 2f, Render.Texture.Height / 2f);

            Gun = new SimpleGun(this, "SimpleGun");
            Gun.LinkDependency(SimpleGun.DEPENDENCY_BODY, Body);
            Gun.LinkDependency(SimpleGun.DEPENDENCY_PHYSICS, Physics);
            Shape = new Circle(this, "Circle", Body.Width * .8f);
            Shape.Offset = new Vector2(Body.Width / 2, Body.Height / 2);
            Shape.Debug = true;
            Shape.LinkDependency(Circle.DEPENDENCY_BODY, Body);

            Collision.Group.AddMask(0);
            Collision.Pair.AddMask(2);
            Collision.CollideEvent += OnCollide;
            Collision.Immovable = true;
            Collision.LinkDependency(Collision.DEPENDENCY_SHAPE, Shape);
            Shape.LinkDependency(Circle.DEPENDENCY_COLLISION, Collision);

            //Control
            UpButton = new DoubleInput(this, "UpButton", Keys.W, Buttons.DPadUp, PlayerIndex.One);
            DownButton = new DoubleInput(this, "DownButton", Keys.S, Buttons.DPadDown, PlayerIndex.One);
            LeftButton = new DoubleInput(this, "LeftButton", Keys.A, Buttons.DPadLeft, PlayerIndex.One);
            RightButton = new DoubleInput(this, "RightButton", Keys.D, Buttons.DPadRight, PlayerIndex.One);
            FireButton = new DoubleInput(this, "FireButton", Keys.Space, Buttons.A, PlayerIndex.One);
            ThrustTrigger = new GamePadTrigger(this, "ThrustTrigger", Triggers.Right, PlayerIndex.One);
            //GravityTrigger = new GamePadTrigger(this, "GravityTrigger", Triggers.Left, PlayerIndex.One);

            LookAnalog = new GamePadAnalog(this, "LookAnalog", Sticks.Left, PlayerIndex.One);
        }
        public override void Initialize()
        {
            base.Initialize();

            EntityGame.ShowDebugInfo = true;
            EntityGame.BackgroundColor = Color.Gray;

            //Service init
            new MouseService(this);

            _upkey = new DoubleInput(this, "UpKey", Keys.Up, Buttons.DPadUp, PlayerIndex.One);
            _downkey = new DoubleInput(this, "DownKey", Keys.Down, Buttons.DPadDown, PlayerIndex.One);
            _leftkey = new DoubleInput(this, "LeftKey", Keys.Left, Buttons.DPadLeft, PlayerIndex.One);
            _rightkey = new DoubleInput(this, "RightKey", Keys.Right, Buttons.DPadRight, PlayerIndex.One);
            _selectkey = new DoubleInput(this, "SelectKey", Keys.Space, Buttons.A, PlayerIndex.One);

            _page = new Page(this, "Page");
            _page.Show();

            AddMenuItem("Game of Life", () => (new GameOfLifeState()).Show());
            AddMenuItem("Color Game of Life", () => (new ColorGameOfLifeState()).Show());
            AddMenuItem("Asteroids Game", () => (new AsteroidsGame()).Show());
            AddMenuItem("Tower Defence", () => (new TowerDefenceMenu()).Show());
            AddMenuItem("Particle Test State", () => (new ParticleTestState()).Show());
            AddMenuItem("Camera Test State", () => (new CameraTestState()).Show());
            AddMenuItem("Control Test State", () => (new ControlTestState()).Show());
            AddMenuItem("Spawn Test State", () => (new SpawnerTestState()).Show());
            AddMenuItem("Fancy Spawn Test State", () => (new FancySpawnerTestState()).Show());
            AddMenuItem("Collision Test State", () => (new CollisionTestState()).Show());
            AddMenuItem("Collision Tester State", () => (new CollisionResolutionTest()).Show());
            AddMenuItem("Resolution Test State", () => (new ResolutionTestState()).Show());
            AddMenuItem("Color Test State", () => (new ColorTestState()).Show());
            AddMenuItem("Render Test State", () => (new RenderTestState()).Show());
            AddMenuItem("Primitives Test State", () => (new PrimitiveTestState()).Show());
            _page.ProcessControls();
        }
 protected TestBedState(string name)
     : base(name)
 {
     _backkey = new DoubleInput(this, "BackKey", Keys.Back, Buttons.Back, PlayerIndex.One);
 }
 public ColorTestManager(Node parent, string name)
     : base(parent, name)
 {
     NextTestKey = new DoubleInput(this, "NextTestKey", Keys.Space, Buttons.A, PlayerIndex.One);
 }
        public override void Initialize()
        {
            base.Initialize();

            _currentTest = new CircleTest1(this, "CircleTest1");
            _currentTest.Initialize();

            _beginTest = new DoubleInput(this, "BeginTest", Keys.Space, Buttons.Start, PlayerIndex.One);
            _nextTest = new DoubleInput(this, "NextTest", Keys.Right, Buttons.RightShoulder, PlayerIndex.One);
            _lastTest = new DoubleInput(this, "LastTest", Keys.Left, Buttons.LeftShoulder, PlayerIndex.One);
            _resetTest = new DoubleInput(this, "ResetLink", Keys.Q, Buttons.X, PlayerIndex.One);

            Page p = new Page(this, "Page");
            p.Show();

            _titleLabel = new Label(p, "TitleLabel", new Point(0, 0));
            _titleLabel.Text = _currentTest.Title;
            _titleLabel.Body.Position = new Vector2(2, 2);

            _descriptionLabel = new Label(p, "DescriptionLabel", new Point(0, 1));
            _descriptionLabel.Text = _currentTest.Description;
            _descriptionLabel.Body.Position = new Vector2(2, EntityGame.Viewport.Height - _descriptionLabel.Render.Bounds.Y - 2);

            //Init tests
            _tests.Add(_currentTest);
            _tests.Add(new CircleTest2(this, "CircleTest2"));
            _tests.Add(new CircleTest3(this, "CircleTest3"));
            _tests.Add(new CircleTest4(this, "CircleTest4"));
            _tests.Add(new CircleTest5(this, "CirlceTest5"));
            _tests.Add(new CircleTest6(this, "CirlceTest6"));
            _tests.Add(new CircleTest7(this, "CirlceTest7"));
            _tests.Add(new CircleTest8(this, "CirlceTest8"));
            _tests.Add(new CircleTest9(this, "CirlceTest9"));
            _tests.Add(new CircleTest10(this, "CirlceTest10"));

            _tests.Add(new AABBTest1(this, "AABBTest1"));
            _tests.Add(new AABBTest2(this, "AABBTest2"));
            _tests.Add(new AABBTest3(this, "AABBTest3"));
            _tests.Add(new AABBTest4(this, "AABBTest4"));
        }