public TankGame(TankLevel level) : base(800, 600, GraphicsMode.Default, "Tank") { cameraSpinRotation = 0; cameraSpinRotationControl = new TrinaryFloatControl(Key.Left, Key.Right, 1f, -45, 45); cameraOverheadRotation = 0; cameraOverheadRotationControl = new TrinaryFloatControl(Key.Down, Key.Up, 1f, 0, 80); // // Render Components // ArenaUtils.windowWidth = ClientRectangle.Width; ArenaUtils.windowHeight = ClientRectangle.Height; ArenaUtils.arenaWidth = level.width; ArenaUtils.arenaHeight = level.height; ArenaUtils.glOrthoHalfWidth = (float)ArenaUtils.windowWidth / 2f; ArenaUtils.glOrthoHalfHeight = (float)ArenaUtils.windowHeight / 2f; ArenaUtils.glOrthoWidth = ArenaUtils.windowWidth; ArenaUtils.glOrthoHeight = ArenaUtils.windowHeight; ArenaUtils.glArenaHalfWidth = ArenaUtils.glOrthoWidth * .45f; ArenaUtils.glArenaHalfHeight = ArenaUtils.glOrthoHeight * .45f; ArenaUtils.glArenaWidth = ArenaUtils.glOrthoWidth * .9f; ArenaUtils.glArenaHeight = ArenaUtils.glOrthoHeight * .9f; arenaRenderer = new ArenaGLRenderer(this); }
public AISimulator( SquareBoundedPhysicalEntity[] squareBoundedEntities, CircleBoundedPhysicalEntity[] circleBoundedEntities ) : base(800, 600, GraphicsMode.Default, "AI Simulator") { // // Camera Controls // cameraSpinRotation = 0; cameraSpinRotationControl = new TrinaryFloatControl(Key.Left, Key.Right, 1f, -45, 45); cameraOverheadRotation = 0; cameraOverheadRotationControl = new TrinaryFloatControl(Key.Down, Key.Up, 1f, 0, 80); // // Entities // this.squareBoundedEntities = squareBoundedEntities; this.circleBoundedEntities = circleBoundedEntities; }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); Viewport viewport = GraphicsDevice.Viewport; Int32 viewWidth = viewport.Width; Int32 viewHeight = viewport.Height; // // Load World Grid // this.worldGrid = new Grid(this); // // Load Fonts // this.miramonte18Font = Content.Load <SpriteFont>("Miramonte18"); // // Load Textures // // // Load Primitives // VertexPositionColor[] floorVertices = new VertexPositionColor[] { new VertexPositionColor(Vector3.UnitY, Color.Red), new VertexPositionColor(new Vector3(.5f, 0, 0), Color.Green), new VertexPositionColor(new Vector3(-.5f, 0, 0), Color.Blue), }; floorVertexBuffer = new VertexBuffer(GraphicsDevice, typeof(VertexPositionColor), floorVertices.Length, BufferUsage.WriteOnly); floorVertexBuffer.SetData <VertexPositionColor>(floorVertices); floorTriangleCount = floorVertices.Length / 3; floorBasicEffect = new BasicEffect(GraphicsDevice); //floorBasicEffect.EnableDefaultLighting(); floorWorld = Matrix.CreateTranslation(new Vector3(0, 1.5f, 0)); VertexPositionColor[] octahedronVertices = new VertexPositionColor[] { new VertexPositionColor(new Vector3(1f, 0, 0), Color.Red), new VertexPositionColor(new Vector3(0, -1, 0), Color.Blue), new VertexPositionColor(new Vector3(0, 0, 1), Color.Green), new VertexPositionColor(new Vector3(1, 0, 0), Color.Blue), new VertexPositionColor(new Vector3(0, 1, 0), Color.Red), new VertexPositionColor(new Vector3(0, 0, -1), Color.Green), new VertexPositionColor(new Vector3(-1, 0, 0), Color.Red), new VertexPositionColor(new Vector3(0, 1, 0), Color.Blue), new VertexPositionColor(new Vector3(0, 0, 1), Color.Green), new VertexPositionColor(new Vector3(-1, 0, 0), Color.Blue), new VertexPositionColor(new Vector3(0, -1, 0), Color.Red), new VertexPositionColor(new Vector3(0, 0, -1), Color.Blue), new VertexPositionColor(new Vector3(0, 1, 0), Color.Green), new VertexPositionColor(new Vector3(1, 0, 0), Color.Blue), new VertexPositionColor(new Vector3(0, 0, 1), Color.Red), new VertexPositionColor(new Vector3(0, 1, 0), Color.Blue), new VertexPositionColor(new Vector3(-1, 0, 0), Color.Green), new VertexPositionColor(new Vector3(0, 0, -1), Color.Blue), new VertexPositionColor(new Vector3(0, -1, 0), Color.Red), new VertexPositionColor(new Vector3(-1, 0, 0), Color.Blue), new VertexPositionColor(new Vector3(0, 0, 1), Color.Green), new VertexPositionColor(new Vector3(0, -1, 0), Color.Blue), new VertexPositionColor(new Vector3(1, 0, 0), Color.Red), new VertexPositionColor(new Vector3(0, 0, -1), Color.Blue), }; octahedronVertexBuffer = new VertexBuffer(GraphicsDevice, typeof(VertexPositionColor), octahedronVertices.Length, BufferUsage.WriteOnly); octahedronVertexBuffer.SetData <VertexPositionColor>(octahedronVertices); octahedronTriangleCount = octahedronVertices.Length / 3; octahedronBasicEffect = new BasicEffect(GraphicsDevice); //octahedronrBasicEffect.EnableDefaultLighting(); octahedronWorld = Matrix.CreateTranslation(new Vector3(0, 0, 0)); VertexPositionColor[] icosahedronVertices = new VertexPositionColor[] { new VertexPositionColor(new Vector3(-0.26286500f, 0.0000000f, 0.42532500f), Color.Red), new VertexPositionColor(new Vector3(0.26286500f, 0.0000000f, 0.42532500f), Color.Orange), new VertexPositionColor(new Vector3(-0.26286500f, 0.0000000f, -0.42532500f), Color.Yellow), new VertexPositionColor(new Vector3(0.26286500f, 0.0000000f, -0.42532500f), Color.Green), new VertexPositionColor(new Vector3(0.0000000f, 0.42532500f, 0.26286500f), Color.Blue), new VertexPositionColor(new Vector3(0.0000000f, 0.42532500f, -0.26286500f), Color.Indigo), new VertexPositionColor(new Vector3(0.0000000f, -0.42532500f, 0.26286500f), Color.Purple), new VertexPositionColor(new Vector3(0.0000000f, -0.42532500f, -0.26286500f), Color.White), new VertexPositionColor(new Vector3(0.42532500f, 0.26286500f, 0.0000000f), Color.Cyan), new VertexPositionColor(new Vector3(-0.42532500f, 0.26286500f, 0.0000000f), Color.Black), new VertexPositionColor(new Vector3(0.42532500f, -0.26286500f, 0.0000000f), Color.DodgerBlue), new VertexPositionColor(new Vector3(-0.42532500f, -0.26286500f, 0.0000000f), Color.Crimson), }; icosahedronVertexBuffer = new VertexBuffer(GraphicsDevice, typeof(VertexPositionColor), icosahedronVertices.Length, BufferUsage.WriteOnly); icosahedronVertexBuffer.SetData <VertexPositionColor>(icosahedronVertices); icosahedronVertexCount = icosahedronVertices.Length; UInt16[] icosahedronIndices = new UInt16[] { 0, 6, 1, 0, 11, 6, 1, 4, 0, 1, 8, 4, 1, 10, 8, 2, 5, 3, 2, 9, 5, 2, 11, 9, 3, 7, 2, 3, 10, 7, 4, 8, 5, 4, 9, 0, 5, 8, 3, 5, 9, 4, 6, 10, 1, 6, 11, 7, 7, 10, 6, 7, 11, 2, 8, 10, 3, 9, 11, 0, }; icosahedronIndexBuffer = new IndexBuffer(GraphicsDevice, typeof(UInt16), icosahedronIndices.Length, BufferUsage.WriteOnly); icosahedronIndexBuffer.SetData(icosahedronIndices); icosahedronTriangleCount = icosahedronVertices.Length / 3; icosahedronBasicEffect = new BasicEffect(GraphicsDevice); icosahedronWorldPosition = Matrix.CreateTranslation(new Vector3(-1, -1, 5)); icosahedronWorldRotation = Matrix.Identity; // // Load Models // this.spaceShip = Content.Load <Model>("SpaceShip"); this.spaceShipPosition = new Vector3(0, 0, 0); this.helicopterModel = Content.Load <Model>("Helicopter"); this.leftRightControl = new TrinaryFloatControl(Keys.A, Keys.D, .2f, -100f, 100f); this.forwardBackwardControl = new TrinaryFloatControl(Keys.W, Keys.S, .2f, -100f, 100f); this.upDownControl = new TrinaryFloatControl(Keys.Down, Keys.Up, .2f, -100f, 100f); }