public Rectangle(Renderer renderer, Vector2I screenSize, Vector2I position, Vector2I size, Vector4 color, float depth = 0.0f) { _shader = renderer.ColorShader; Position = position; ScreenSize = screenSize; Size = size; _color = color; _changed = true; Depth = depth; int vertexCount = 4; _indexCount = 6; _vertices = new VertexDefinition.PositionColor[vertexCount]; UInt32[] indices = { 0, 1, 2, 0, 3, 1 }; _vertexBuffer = Buffer.Create(renderer.DirectX.Device, _vertices, new BufferDescription { Usage = ResourceUsage.Dynamic, SizeInBytes = Utilities.SizeOf<VertexDefinition.PositionColor>() * vertexCount, BindFlags = BindFlags.VertexBuffer, CpuAccessFlags = CpuAccessFlags.Write, OptionFlags = ResourceOptionFlags.None, StructureByteStride = 0 }); _indexBuffer = Buffer.Create(renderer.DirectX.Device, BindFlags.IndexBuffer, indices); }
public static Airplane Create(World world, Game game, Renderer renderer, bool isPlayer = false, Airplane playerPlane = null) { if(random == null) random = new Random(); State state; if (isPlayer) state = new State(510, 200); else state = new State(200 + random.Next(-1000,2000), random.Next(-1500,1500), 500 + random.Next(0, 1000), 200+ random.Next(0,100), random.Next(-15,15)); Airplane plane = new Airplane(world, state, game, renderer, isPlayer, playerPlane, "F-14", "Plane " + i++); plane.PhysicalModel.Tanks.Add(new Tank(100, 500)); plane.PhysicalModel.Tanks.Add(new Tank(100, 500)); plane.PhysicalModel.Thrusters.Add(new Thruster()); plane.CurrentState.Position = new Vector3D(plane.CurrentState.Position.X - 2500, plane.CurrentState.Position.Y, plane.CurrentState.Position.Z); return plane; }
public Game() { _gameComponents = new List<GameComponent>(); _timer = new Timer(); _renderer = new Renderer(); Input = new Input(this, _renderer.Form.Handle); Register(Input); _world = new World(this, _renderer); Register(_world); _playerPlane = AirplaneFactory.Create(_world, this, _renderer, true); Register(_playerPlane); for (int i = 0; i < 5; i++) Register(AirplaneFactory.Create(_world, this, _renderer, false, _playerPlane)); Camera camera = new Camera(this, _playerPlane); Register(camera); _renderer.Camera = camera; Register(new MonitoringHeader(this, _renderer)); Register(new FlightRecorder(this, _timer, _playerPlane)); }
public AirplaneOverlay(Game game, Renderer renderer, Airplane airplane, Airplane playerAirplane) : base(game, renderer, airplane.UpdateOrder+1, false, true) { _airplane = airplane; _playerAirplane = playerAirplane; _shader = Renderer.FontShader; _overlay = new Bitmap(Renderer.DirectX.Device, Renderer.TextureManager.Create("Circle.png").TextureResource, Renderer.ScreenSize, new Vector2I(100, 100)) { Position = new Vector2I(0,0), Size = new Vector2I(40, 40) }; _color = new Vector4(0.2f, 0, 0, 0.4f); _distanceText = Renderer.TextManager.Create("Courrier", 14, 8, _color); _distanceText.Position = new Vector2I(0,0); _nameText = Renderer.TextManager.Create("Courrier", 14, 20, _color); _nameText.Position = new Vector2I(0,0); _nameText.Content = airplane.Name; _modelNameText = Renderer.TextManager.Create("Courrier", 14, 20, _color); _modelNameText.Position = new Vector2I(0, 0); _modelNameText.Content = airplane.ModelName; }
public World(Game game, Renderer renderer) : base(game, renderer, 0) { _terrain = new Terrain(renderer.DirectX.Device, "Heightmap.png", 100, Renderer); }