void DrawBrushes() { GridPosition brushSelector = new GridPosition(17, 0); Vector2 pos = brushSelector.ToVector(); for (int i = 0; i < 11; i++) { gameAtlas.Draw(i, pos); pos.Y += GridPosition.CELL_SIZE; if (brush == i) { GridPosition cursor = new GridPosition(16, i); editorAtlas.Draw(14, cursor.ToVector()); } } }
private void DrawHUD(SpriteBatch spriteBatch) { string levelString = string.Format("Level: {0}", Constants.CurrentLevel); spriteBatch.DrawString(defaultFont, levelString, new Vector2(35, (Constants.ELEMENT_IMAGE_SIZE * Constants.ELEMENT_IMAGE_SCALE) + 35), Color.White); string scoreString = string.Format("Score: {0}", score); spriteBatch.DrawString(defaultFont, scoreString, new Vector2(35, (Constants.ELEMENT_IMAGE_SIZE * Constants.ELEMENT_IMAGE_SCALE) + 55), Color.White); string totalScoreString = string.Format("Total Score: {0}", Constants.TotalScore); spriteBatch.DrawString(defaultFont, totalScoreString, new Vector2(35, (Constants.ELEMENT_IMAGE_SIZE * Constants.ELEMENT_IMAGE_SCALE) + 75), Color.White); elementSheet.Draw((int)currentElement, new Vector2(20, 30), Constants.ELEMENT_IMAGE_SCALE, spriteBatch); }
public override void Draw() { if (!_model.ShowInfo) { _spriteBatch.DrawString(_gameFont, "New Game".ToUpper(), _model.NewGamePosition, Color.Yellow); _spriteBatch.DrawString(_gameFont, "Info".ToUpper(), _model.InfoPosition, Color.Yellow); _spriteBatch.DrawString(_gameFont, "Exit".ToUpper(), _model.ExitGamePosition, Color.Yellow); _ships.Draw(_model.ShipPosition, _model.Frame, Color.White); } else { _spriteBatch.DrawString(_gameFont, "New Game".ToUpper(), _model.NewGamePosition - _model.InfoXOffset, Color.Yellow); _spriteBatch.DrawString(_gameFont, "Hide info".ToUpper(), _model.InfoPosition - _model.InfoXOffset, Color.Yellow); _spriteBatch.DrawString(_gameFont, "Exit".ToUpper(), _model.ExitGamePosition - _model.InfoXOffset, Color.Yellow); _ships.Draw(_model.ShipPosition - _model.InfoXOffset, _model.Frame, Color.White); _spriteBatch.DrawString(_gameFont, "Use arrow keys to move and space to shoot.", _model.NewGamePosition, Color.White); _spriteBatch.DrawString(_gameFont, "Kill all the enemies to advance to the next level.", _model.NewGamePosition + _model.InfoYOffset, Color.White); _spriteBatch.DrawString(_gameFont, "Enemies will get stronger each level.", _model.NewGamePosition + _model.InfoYOffset * 2, Color.White); _spriteBatch.DrawString(_gameFont, "Killing enemies will grant you XP.", _model.NewGamePosition + _model.InfoYOffset * 3, Color.White); _spriteBatch.DrawString(_gameFont, "Kill enough to get a level up and to become more stronger.", _model.NewGamePosition + _model.InfoYOffset * 4, Color.White); _spriteBatch.DrawString(_gameFont, "Level up and adjust your stats the way you want.", _model.NewGamePosition + _model.InfoYOffset * 5, Color.White); _spriteBatch.DrawString(_gameFont, "Sometimes there will be bonus items floating around.", _model.NewGamePosition + _model.InfoYOffset * 6, Color.White); _spriteBatch.DrawString(_gameFont, "Loot 'em or lose 'em!", _model.NewGamePosition + _model.InfoYOffset * 7, Color.White); _spriteBatch.DrawString(_gameFont, "Bonus items:", _model.NewGamePosition + _model.InfoYOffset * 8, Color.White); _spriteBatch.DrawString(_gameFont, "1UP: ", _model.NewGamePosition + _model.InfoYOffset * 9, Color.White); _spriteBatch.DrawString(_gameFont, "XP: ", new Vector2(_model.NewGamePosition.X + _model.BonusItemXOffset * 2 + 10, _model.NewGamePosition.Y) + _model.InfoYOffset * 9, Color.White); _spriteBatch.DrawString(_gameFont, "HP: ", new Vector2(_model.NewGamePosition.X + _model.BonusItemXOffset * 4 + 10, _model.NewGamePosition.Y) + _model.InfoYOffset * 9, Color.White); _spriteBatch.DrawString(_gameFont, "Damage: ", new Vector2(_model.NewGamePosition.X + _model.BonusItemXOffset * 6, _model.NewGamePosition.Y) + _model.InfoYOffset * 9, Color.White); _spriteBatch.DrawString(_gameFont, "Speed: ", new Vector2(_model.NewGamePosition.X + _model.BonusItemXOffset * 9 + 8, _model.NewGamePosition.Y) + _model.InfoYOffset * 9, Color.White); _spriteBatch.DrawString(_gameFont, "More bullets: ", new Vector2(_model.NewGamePosition.X + _model.BonusItemXOffset * 12 - 15, _model.NewGamePosition.Y) + _model.InfoYOffset * 9, Color.White); foreach (var item in _items) { if (item.Type != BonusItemType.ExtraLive) { _bonusItems.Draw(item.Position, item.Frame, Color.White); } if (item.Type == BonusItemType.ExtraLive) { _enemies.Draw(item.Position, item.Frame, Color.White); } } } }
public void Draw(SpriteBatch spriteBatch, bool editing, float itemDepth = -1) { if (propellerSprite != null) { Vector2 drawPos = item.DrawPosition; drawPos += PropellerPos; drawPos.Y = -drawPos.Y; propellerSprite.Draw(spriteBatch, (int)Math.Floor(spriteIndex), drawPos, Color.White, propellerSprite.Origin, 0.0f, Vector2.One); } if (editing && !DisablePropellerDamage && propellerDamage != null && !GUI.DisableHUD) { Vector2 drawPos = item.DrawPosition; drawPos += PropellerPos * item.Scale; drawPos.Y = -drawPos.Y; spriteBatch.DrawCircle(drawPos, propellerDamage.DamageRange * item.Scale, 16, GUI.Style.Red, thickness: 2); } }
public void Draw(SpriteBatch spriteBatch, bool editing, float itemDepth = -1) { if (propellerSprite != null) { Vector2 drawPos = item.DrawPosition; drawPos += PropellerPos; drawPos.Y = -drawPos.Y; propellerSprite.Draw(spriteBatch, (int)Math.Floor(spriteIndex), drawPos, Color.White, propellerSprite.Origin, 0.0f, Vector2.One); } if (editing) { Vector2 drawPos = item.DrawPosition; drawPos += PropellerPos; drawPos.Y = -drawPos.Y; GUI.DrawRectangle(spriteBatch, drawPos - Vector2.One * 10, Vector2.One * 20, Color.Red); } }
public void Draw() { GridPosition cache = new GridPosition(position); if (alignement == Alignement.RIGHT) { cache.X -= sequence.Count - 1; } else if (alignement == Alignement.CENTER) { cache.X -= (sequence.Count - 1) / 2; } for (int i = 0; i < sequence.Count; i++) { font.Draw(sequence[i], cache.ToVector()); cache.X += 1; } }
protected override void RenderShip(Graphics graphics, Camera camera, RectangleF screenBounds) { double drawingRotation = Pitch + Math.PI * 0.5; var offset = new PointF(screenBounds.X + screenBounds.Width * 0.5f, screenBounds.Y + screenBounds.Height * 0.5f); graphics.TranslateTransform(offset.X, offset.Y); graphics.RotateTransform((float)(drawingRotation * 180 / Math.PI)); graphics.TranslateTransform(-offset.X, -offset.Y); // Normalize the angle to [0,360] int rollAngle = (int)(Roll * MathHelper.RadiansToDegrees) % 360; // Index into the sprite int ships = _spriteSheet.Cols * _spriteSheet.Rows; int spriteIndex = (rollAngle * ships) / 120; while (spriteIndex >= ships) { spriteIndex -= ships; } _spriteSheet.Draw(spriteIndex, graphics, screenBounds); graphics.ResetTransform(); if (DateTime.Now - timestamp > TimeSpan.FromSeconds(1)) { string filename = MissionName + ".csv"; if (!File.Exists(filename)) { File.AppendAllText(filename, "Ma, FormDragCoefficient, SkinFrictionCoefficient, LiftCoefficient, rollAngle\r\n"); } timestamp = DateTime.Now; string contents = string.Format("{0:N3}, {1:N3}, {2:N3}, {3:N3}, {4:N3}\r\n", MachNumber, FormDragCoefficient, SkinFrictionCoefficient, LiftCoefficient, rollAngle); File.AppendAllText(filename, contents); } }
public override void Draw() { var visibleArea = VirtualScreenSize.CalculateVisibleArea(_playerModel.Position); var mouseState = Mouse.GetState(); var mousePoint = mouseState.Position; var mousePosition = VirtualScreenSize.ScreenToWorld(_playerModel.Position, mousePoint.X, mousePoint.Y); var position = new Vector2(visibleArea.X, visibleArea.Bottom); int i = 0; while (i <= visibleArea.Width) { _bar.Draw(new Vector2(position.X + i, visibleArea.Bottom - 47), 0, Color.White, new Vector2(0.25f, 0.25f)); i += 64; } var j = 15; foreach (var building in _buildingListModel.AvailableBuildings) { building.Position = new Vector2(position.X + j, visibleArea.Bottom - 47); building.Area = new Rectangle((int)building.Position.X, (int)building.Position.Y, 64, 64); _buildings.Draw(building.Position, building.Frame, _playerResourcesModel.HasEnoughResources(building.Cost) ? Color.White : Color.Red, new Vector2(0.5f, 0.5f)); j += 68; if (building.ShowTooltip) { ShowTooltip(building); } if (building.IsSelected) { _buildings.Draw(mousePosition, building.Frame, building.CanBuild ? Color.White : Color.Red); } } foreach (var b in _buildingListModel.BuiltBuildings) { _buildings.Draw(b.Position, b.Frame, Color.White); } }
public override void Draw() { foreach (var enemy in _enemyList.Enemies) { if (!enemy.IsDead && !enemy.IsBoss) { _enemies.Draw(enemy.Position, enemy.Frame, Color.White); // Uncomment to debug enemy positioning & area //_spriteBatch.DrawString(_gameFont, enemy.Position.ToString(), new Vector2(enemy.Position.X, enemy.Position.Y + 32), Color.Yellow); //_spriteBatch.DrawString(_gameFont, enemy.TargetPosition.ToString(), new Vector2(enemy.Position.X, enemy.Position.Y + 64), Color.Yellow); //_spriteBatch.DrawString(_gameFont, enemy.Area.ToString(), new Vector2(enemy.Position.X, enemy.Position.Y + 96), Color.Yellow); } if (!enemy.IsDead && enemy.IsBoss) { _boss.Draw(enemy.Position, enemy.Frame, Color.White); } } }
public override void Draw(GameTime gameTime, SpriteBatch spriteBatch) { if (!visible || sprite == null || !isAlive) { return; } else { Camera camera = GameWorld.Find("camera") as Camera; if (camera != null) { //background if (layer == -10) { sprite.Draw(spriteBatch, this.GlobalPosition + camera.Position / 60, origin); } else if (layer == -9) { sprite.Draw(spriteBatch, this.GlobalPosition + camera.Position / 50, origin); } else if (layer == -8) { sprite.Draw(spriteBatch, this.GlobalPosition + camera.Position / 30, origin); } else if (layer == -7) { sprite.Draw(spriteBatch, this.GlobalPosition + camera.Position / 2, origin); } else if (layer == 100) { sprite.Draw(spriteBatch, this.GlobalPosition + camera.Position, origin); } else { sprite.Draw(spriteBatch, this.GlobalPosition + camera.Position, origin); } } else { sprite.Draw(spriteBatch, this.GlobalPosition, origin); } //(texture, new Rectangle(400, 50, 100, 100), null, Color.Red, MathHelper.PiOver4, Vector2.Zero, SpriteEffects.None, 0); } }
public void Draw() { Vector2 p = Vector2.Zero; for (int i = 0; i < walls.Length; i++) { if (walls[i]) { p.X = i % SIZE * GridPosition.CELL_SIZE; p.Y = i / SIZE * GridPosition.CELL_SIZE; sheet.Draw(9, p); } } foreach (var item in items) { item.Draw(); } foreach (var obstacle in obstacles) { obstacle.Draw(); } }
public void Draw(RenderContext context) => _spriteSheet.Draw(context);
protected override void RenderShip(Graphics graphics, Camera camera, RectangleF screenBounds) { double drawingRotation = Pitch + Math.PI * 0.5; var offset = new PointF(screenBounds.X + screenBounds.Width * 0.5f, screenBounds.Y + screenBounds.Height * 0.5f); graphics.TranslateTransform(offset.X, offset.Y); float pitchAngle = (float)(drawingRotation * 180 / Math.PI); float rollFactor = (float)Math.Cos(Roll); float alphaAngle = (float)(GetAlpha() * 180 / Math.PI); float rotateAngle = (pitchAngle - alphaAngle) + alphaAngle * rollFactor; if (this.MissionName.Contains("EDL") || this.MissionName.Contains("Aerocapture") || this.MissionName.Contains("Direct")) { graphics.RotateTransform(rotateAngle); } else { graphics.RotateTransform(pitchAngle); } graphics.TranslateTransform(-offset.X, -offset.Y); // Normalize the angle to [0,360] int rollAngle = (int)(Roll * MathHelper.RadiansToDegrees) % 360; int heatingRate = Math.Min((int)this.HeatingRate, 2000000); if (heatingRate > 100000) { Random rnd = new Random(); float noise = (float)rnd.NextDouble(); float width = screenBounds.Width / (3 + noise); float height = screenBounds.Height / (18 + noise); RectangleF plasmaRect = screenBounds; plasmaRect.Inflate(new SizeF(width, height)); int alpha = Math.Min(heatingRate / 7800, 255); int red = alpha; int green = Math.Max(red - 128, 0) * 2; int blue = 0; Color glow = Color.FromArgb(alpha, red, green, blue); float penWidth = width / 12; Pen glowPen = new Pen(glow, penWidth); glowPen.StartCap = System.Drawing.Drawing2D.LineCap.Round; glowPen.EndCap = System.Drawing.Drawing2D.LineCap.Round; graphics.DrawArc(glowPen, plasmaRect, 220, 100); glowPen.Color = Color.FromArgb((int)(alpha * 0.75), glow); plasmaRect.Inflate(-penWidth, -penWidth); graphics.DrawArc(glowPen, plasmaRect, 200, 140); glowPen.Color = Color.FromArgb((int)(alpha * 0.5), glow); plasmaRect.Inflate(-penWidth, -penWidth); graphics.DrawArc(glowPen, plasmaRect, 180, 180); glowPen.Color = Color.FromArgb((int)(alpha * 0.25), glow); plasmaRect.Inflate(-penWidth, -penWidth); graphics.DrawArc(glowPen, plasmaRect, 160, 220); } // Index into the sprite int ships = _spriteSheet.Cols * _spriteSheet.Rows; int spriteIndex = (rollAngle * ships) / 360; while (spriteIndex < 0) { spriteIndex += ships; } _spriteSheet.Draw(spriteIndex, graphics, screenBounds); graphics.ResetTransform(); //if (DateTime.Now - timestamp > TimeSpan.FromSeconds(1)) //{ // string filename = MissionName + ".csv"; // if (!File.Exists(filename)) // { // File.AppendAllText(filename, "Ma, FormDragCoefficient, SkinFrictionCoefficient, LiftCoefficient, pitchAngle\r\n"); // } // timestamp = DateTime.Now; // string contents = string.Format("{0:N3}, {1:N3}, {2:N3}, {3:N3}, {4:N3}\r\n", // MachNumber, FormDragCoefficient, SkinFrictionCoefficient, LiftCoefficient, pitchAngle); // File.AppendAllText(filename, contents); //} }
public override void Draw(GameTime gameTime, SpriteBatch spriteBatch) { if (animationDelay) { animationDelay = false; } else { switch (animation) { case 0: // move if (sprite.SheetIndex > 11) { sprite.SheetIndex = 5; } else { if (!animationReverser) { if (sprite.SheetIndex == 11) { animationReverser = true; } else { sprite.SheetIndex++; } } else if (sprite.SheetIndex == 0) { animationReverser = false; } else { sprite.SheetIndex--; } } if (sprite2.SheetIndex > 11) { sprite2.SheetIndex = 11; } else { if (!animationReverser2) { if (sprite2.SheetIndex == 11) { animationReverser2 = true; } else { sprite2.SheetIndex++; } } else if (sprite2.SheetIndex == 0) { animationReverser2 = false; } else { sprite2.SheetIndex--; } } if (sprite3.SheetIndex > 11) { sprite3.SheetIndex = 0; } else { if (!animationReverser3) { if (sprite3.SheetIndex == 11) { animationReverser3 = true; } else { sprite3.SheetIndex++; } } else if (sprite3.SheetIndex == 0) { animationReverser3 = false; } else { sprite3.SheetIndex--; } } break; case 1: // attack if (sprite.SheetIndex < 12) { sprite.SheetIndex = 17; } else { if (!animationReverser) { if (sprite.SheetIndex == 19) { animationReverser = true; } else { sprite.SheetIndex++; } } else if (sprite.SheetIndex == 12) { animationReverser = false; } else { sprite.SheetIndex--; } } if (sprite2.SheetIndex < 12) { sprite2.SheetIndex = 12; } else { if (!animationReverser2) { if (sprite2.SheetIndex == 19) { animationReverser2 = true; } else { sprite2.SheetIndex++; } } else if (sprite2.SheetIndex == 12) { animationReverser2 = false; } else { sprite2.SheetIndex--; } } if (sprite3.SheetIndex < 12) { sprite3.SheetIndex = 19; } else { if (!animationReverser3) { if (sprite3.SheetIndex == 19) { animationReverser3 = true; } else { sprite3.SheetIndex++; } } else if (sprite3.SheetIndex == 12) { animationReverser3 = false; } else { sprite3.SheetIndex--; } } break; } animationDelay = true; } if (visible2) { sprite2.Draw(spriteBatch, new Vector2(this.GlobalPosition.X + 10, this.GlobalPosition.Y - 30), origin); } if (visible3) { sprite3.Draw(spriteBatch, new Vector2(this.GlobalPosition.X - 12, this.GlobalPosition.Y - 16), origin); } base.Draw(gameTime, spriteBatch); }
protected override void RenderShip(Graphics graphics, Camera camera, RectangleF screenBounds) { foreach (Skid skid in _skids) { if (skid.IsDeploying() || skid.IsDeployed()) { skid.RenderGdi(graphics, camera); } } double drawingRotation = Pitch + Math.PI * 0.5; var offset = new PointF(screenBounds.X + screenBounds.Width * 0.5f, screenBounds.Y + screenBounds.Height * 0.5f); graphics.TranslateTransform(offset.X, offset.Y); float pitchAngle = (float)(drawingRotation * 180 / Math.PI); float rollFactor = (float)Math.Cos(Roll); float alphaAngle = (float)(GetAlpha() * 180 / Math.PI); float rotateAngle = (pitchAngle - alphaAngle) + alphaAngle * rollFactor; if (this.MissionName.Contains("EDL") || this.MissionName.Contains("Aerocapture") || this.MissionName.Contains("Direct")) { graphics.RotateTransform(rotateAngle); } else { graphics.RotateTransform(pitchAngle); } graphics.TranslateTransform(-offset.X, -offset.Y); // Normalize the angle to [0,360] int rollAngle = (int)(Roll * MathHelper.RadiansToDegrees) % 360; int heatingRate = Math.Min((int)this.HeatingRate, 2000000); if (heatingRate > 100000) { Random rnd = new Random(); float noise = (float)rnd.NextDouble(); float width = screenBounds.Width / (3 + noise); float height = screenBounds.Height / (18 + noise); RectangleF plasmaRect = screenBounds; plasmaRect.Inflate(new SizeF(width, height)); int alpha = Math.Min(heatingRate / 7800, 255); int red = alpha; int green = Math.Max(red - 128, 0) * 2; int blue = 0; Color glow = Color.FromArgb(alpha, red, green, blue); float penWidth = width / 12; Pen glowPen = new Pen(glow, penWidth); glowPen.StartCap = System.Drawing.Drawing2D.LineCap.Round; glowPen.EndCap = System.Drawing.Drawing2D.LineCap.Round; graphics.DrawArc(glowPen, plasmaRect, 220, 100); glowPen.Color = Color.FromArgb((int)(alpha * 0.75), glow); plasmaRect.Inflate(-penWidth, -penWidth); graphics.DrawArc(glowPen, plasmaRect, 200, 140); glowPen.Color = Color.FromArgb((int)(alpha * 0.5), glow); plasmaRect.Inflate(-penWidth, -penWidth); graphics.DrawArc(glowPen, plasmaRect, 180, 180); glowPen.Color = Color.FromArgb((int)(alpha * 0.25), glow); plasmaRect.Inflate(-penWidth, -penWidth); graphics.DrawArc(glowPen, plasmaRect, 160, 220); } // Index into the sprite int ships = _spriteSheet.Cols * _spriteSheet.Rows; int spriteIndex = (rollAngle * ships) / 360; while (spriteIndex < 0) { spriteIndex += ships; } _spriteSheet.Draw(spriteIndex, graphics, screenBounds); graphics.ResetTransform(); if (_drogueChute.IsDeploying() || _drogueChute.IsDeployed()) { _drogueChute.RenderGdi(graphics, camera); } if (_parachute.IsDeploying() || _parachute.IsDeployed()) { _parachute.RenderGdi(graphics, camera); } if (Settings.Default.WriteCsv && (DateTime.Now - timestamp > TimeSpan.FromSeconds(1))) { string filename = MissionName + ".csv"; if (!File.Exists(filename)) { File.AppendAllText(filename, "Velocity, Acceleration, Altitude, Alpha\r\n"); } timestamp = DateTime.Now; string contents = string.Format("{0}, {1}, {2}, {3}\r\n", this.GetRelativeVelocity().Length(), this.GetRelativeAcceleration().Length() * 100, this.GetRelativeAltitude() / 10, this.GetAlpha() * 10); File.AppendAllText(filename, contents); } }
public void Draw(GameTime time) { // Globals.spriteBatch.Draw(texture, boundingBox, Color.Purple); currSpriteSheet.Draw(time, getPosition()); }
public override void Draw(GameTime gTime) { base.Draw(gTime); spriteSheet.Draw(Position, origin, color); }
public void Draw(double deltaTime) { _time += deltaTime; GL.ClearColor(_backColor); GL.Enable(EnableCap.DepthTest); GL.ClearDepth(1); GL.DepthFunc(DepthFunction.Less); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); var view = _camera.ComputeViewMatrix(); var model = Matrix4.CreateTranslation(_player.GetPosition()); var viewModel = model * view; { _baseShader.Bind(); _baseShader.SetUniformMatrix4("proj", false, ref _proj); model = _player.BoundingBox.CreateModelMatrix() * model; var color = new Vector3(1, 1, 1); foreach (var ground in _world.Grounds.ToArray()) { if (ground.GetType() == typeof(Intersection)) { var inter = (Intersection)ground; model = DirectionHelper.GetRotationFromDirection(inter.Direction) * Matrix4.CreateTranslation(inter.Position); viewModel = model * view; color = new Vector3(0.8f, 0.8f, 0.8f); _baseShader.SetUniform3("col", ref color); _baseShader.SetUniformMatrix4("view", false, ref viewModel); if (inter.Directions == 1) { inter.Mesh.Draw(); } else if (inter.Directions == 2) { inter.Mesh.Draw(); } else { inter.Mesh.Draw(); } } else { model = DirectionHelper.GetRotationFromDirection(ground.Direction) * Matrix4.CreateTranslation(ground.Position); viewModel = model * view; color = new Vector3(0.8f, 0.8f, 0.8f); _baseShader.SetUniform3("col", ref color); _baseShader.SetUniformMatrix4("view", false, ref viewModel); ground.Mesh.Draw(); } } foreach (var obstacle in _world.Obstacles.ToArray()) { model = DirectionHelper.GetRotationFromDirection(obstacle.Direction) * Matrix4.CreateTranslation(obstacle.Position); viewModel = model * view; color = new Vector3(0.7f, 0.2f, 1f); _baseShader.SetUniform3("col", ref color); _baseShader.SetUniformMatrix4("view", false, ref viewModel); obstacle.Mesh?.Draw(); } color = new Vector3(1f, 0.6f, 0.2f); _baseShader.SetUniform3("col", ref color); foreach (var trigger in _world.Triggers.ToArray()) { model = trigger.BoundingBox.CreateModelMatrix() * Matrix4.CreateTranslation(trigger.Position); viewModel = model * view; _baseShader.SetUniformMatrix4("view", false, ref viewModel); } var coinRotationMatrix = Matrix4.CreateRotationY(_coinsRotation); foreach (var coin in _world.Coins.ToArray()) { model = coinRotationMatrix * Matrix4.CreateTranslation(coin.Position); viewModel = model * view; color = new Vector3(1f, 1f, 1f); _baseShader.SetUniform3("col", ref color); _baseShader.SetUniformMatrix4("view", false, ref viewModel); coin.Mesh.Draw(); } _baseShader.Unbind(); } { _3dSpriteShader.Bind(); _3dSpriteShader.SetUniformMatrix4("proj", false, ref _proj); model = DirectionHelper.GetRotationFromDirection(_player.CurrentDirection) * Matrix4.CreateTranslation(_player.GetPosition()); viewModel = model * view; _3dSpriteShader.SetUniformMatrix4("view", false, ref viewModel); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); _playerSpriteSheet.Draw(_player.AnimationFrame, 0); GL.Disable(EnableCap.Blend); _3dSpriteShader.Unbind(); } { GL.Disable(EnableCap.DepthTest); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); _flatColorShader.Bind(); //_guiFramebuffer.Bind(); _flatColorShader.SetUniformMatrix4("proj", false, ref _guiProj); viewModel = Matrix4.CreateTranslation(new Vector3(_scoreText.Position + -new Vector2(_width / 2, _height / 2))); _flatColorShader.SetUniformMatrix4("view", false, ref viewModel); _scoreText.Draw(); //_guiFramebuffer.Unbind(); _flatColorShader.Unbind(); GL.Disable(EnableCap.Blend); GL.Enable(EnableCap.DepthTest); } }
protected override void RenderShip(Graphics graphics, Camera camera, RectangleF screenBounds) { double drawingRotation = Pitch + Math.PI * 0.5; var offset = new PointF(screenBounds.X + screenBounds.Width * 0.5f, screenBounds.Y + screenBounds.Height * 0.5f); camera.ApplyScreenRotation(graphics); camera.ApplyRotationMatrix(graphics, offset, drawingRotation); // Normalize the angle to [0,360] int rollAngle = (int)(Roll * MathHelper.RadiansToDegrees) % 360; int heatingRate = Math.Min((int)this.HeatingRate, 600000); if (heatingRate > 10000) { Random rnd = new Random(); float noise = (float)rnd.NextDouble(); float width = screenBounds.Width / (3 + noise); float height = screenBounds.Height / (18 + noise); RectangleF plasmaRect = screenBounds; plasmaRect.Inflate(new SizeF(width, height)); if (Roll != 0) { float foreshortening = (float)Math.Pow(Math.Cos(Roll), 0.4); plasmaRect.Y += plasmaRect.Height * (1 - foreshortening); plasmaRect.Height *= foreshortening; } int alpha = 255; int blue = Math.Min(heatingRate / 2000, 255); int green = 0; int red = Math.Max(blue - 64, 0); Color glow = Color.FromArgb(alpha, red, green, blue); float penWidth = width / 12; Pen glowPen = new Pen(glow, penWidth); glowPen.StartCap = System.Drawing.Drawing2D.LineCap.Round; glowPen.EndCap = System.Drawing.Drawing2D.LineCap.Round; graphics.DrawArc(glowPen, plasmaRect, 220, 100); glowPen.Color = Color.FromArgb((int)(alpha * 0.75), glow); plasmaRect.Inflate(-penWidth, -penWidth); graphics.DrawArc(glowPen, plasmaRect, 200, 140); glowPen.Color = Color.FromArgb((int)(alpha * 0.5), glow); plasmaRect.Inflate(-penWidth, -penWidth); graphics.DrawArc(glowPen, plasmaRect, 180, 180); glowPen.Color = Color.FromArgb((int)(alpha * 0.25), glow); plasmaRect.Inflate(-penWidth, -penWidth); graphics.DrawArc(glowPen, plasmaRect, 160, 220); } //graphics.DrawImage(this.Texture, screenBounds.X, screenBounds.Y, screenBounds.Width, screenBounds.Height); // Index into the sprite int ships = _spriteSheet.Cols * _spriteSheet.Rows; int spriteIndex = (rollAngle * ships) / 360; while (spriteIndex < 0) { spriteIndex += ships; } _spriteSheet.Draw(spriteIndex, graphics, screenBounds); graphics.ResetTransform(); if (Settings.Default.WriteCsv && (DateTime.Now - timestamp > TimeSpan.FromSeconds(1))) { string filename = MissionName + ".csv"; if (!File.Exists(filename)) { File.AppendAllText(filename, "Velocity, Acceleration, Altitude, Throttle\r\n"); } timestamp = DateTime.Now; string contents = string.Format("{0}, {1}, {2}, {3}\r\n", this.GetRelativeVelocity().Length(), this.GetRelativeAcceleration().Length() * 100, this.GetRelativeAltitude() / 100, this.Throttle * 10); File.AppendAllText(filename, contents); } }