public override void Draw(Camera3D camera) { PointBatch.Begin(Matrix.Identity, camera); for (int i = 0; i < starCount; i++) { PointBatch.Draw(points[i], starRadius, new Color(brightnesses[i], brightnesses[i], brightnesses[i])); } PointBatch.End(); }
public override void Draw(Camera3D camera) { Matrix translation = Matrix.CreateTranslation(new Vector3(0.0f, 0.0f, -500.0f)); LineBatch.Begin(translation, camera); PointBatch.Begin(translation, camera); foreach (Bullet b in Bullets) { b.Draw(LineBatch, PointBatch); } PointBatch.End(); LineBatch.End(); base.Draw(camera); }
public override void Draw(Camera3D camera) { if (Alive) { Matrix translationMatrix = Matrix.CreateTranslation(Position); LineBatch.Begin(translationMatrix, camera); for (int i = 0; i < vertices.Count; i++) { LineBatch.Draw(vertices[i], vertices[(i + 1) % vertices.Count], 2.5f, lineColor); } LineBatch.End(); PointBatch.Begin(translationMatrix, camera); PointBatch.Draw(lightPosition, 15.0f, lightColor); PointBatch.End(); } }
public override void Draw(Camera3D camera) { // draw ship if (Alive) { Matrix rotationMatrix = Matrix.CreateRotationZ(Rotation); Matrix translationMatrix = Matrix.CreateTranslation(Position); LineBatch.Begin(rotationMatrix * translationMatrix, camera); for (int i = 0; i < vertices.Count; i++) { LineBatch.Draw(vertices[i], vertices[(i + 1) % vertices.Count], lineWidth, lineColor); } LineBatch.End(); PointBatch.Begin(translationMatrix, camera); PointBatch.Draw(lightPosition, lightRadius, lightColor); PointBatch.End(); } }
public override void Draw(Camera3D camera) { Vector2 scoreLabelSize = SpriteFont.MeasureString("Score"); Vector2 scoreSize = SpriteFont.MeasureString(PlayerShip.Score.ToString("#,#")); Vector2 multiplierLabelSize = SpriteFont.MeasureString("Multiplier"); Vector2 multiplierSize = SpriteFont.MeasureString(PlayerShip.Multiplier.ToString("#,#") + "x"); Vector2 timerLabelSize = SpriteFont.MeasureString("Time"); Vector2 timerSize = SpriteFont.MeasureString(TimeAttackTimer.Minutes.ToString() + ":" + TimeAttackTimer.Seconds.ToString()); SpriteBatch.Begin(); SpriteBatch.DrawString(SpriteFont, "Multiplier", new Vector2(padding, padding), Color.White); SpriteBatch.DrawString(SpriteFont, PlayerShip.Multiplier.ToString("#,#") + "x", new Vector2(padding, padding + multiplierLabelSize.Y / 2), Color.White); SpriteBatch.DrawString(SpriteFont, "Score", new Vector2(screenWidth - padding - scoreLabelSize.X, padding), Color.White); SpriteBatch.DrawString(SpriteFont, PlayerShip.Score.ToString("#,#"), new Vector2(screenWidth - padding - scoreSize.X, padding + scoreLabelSize.Y / 2), Color.White); if (TimeAttackTimer != TimeSpan.Zero) { SpriteBatch.DrawString(SpriteFont, "Time", new Vector2(screenWidth / 2 - timerLabelSize.X / 2, padding), Color.White); SpriteBatch.DrawString(SpriteFont, TimeAttackTimer.Minutes.ToString() + ":" + TimeAttackTimer.Seconds.ToString(), new Vector2(screenWidth / 2 - timerSize.X / 2, padding + timerLabelSize.Y / 2), Color.White); } SpriteBatch.End(); }
public override void Draw(Camera3D camera) { LineBatch.Begin(Matrix.Identity, camera); for (int i = 0; i < startPoints.Count; i++) { LineBatch.Draw(startPoints[i], endPoints[i], widths[i], new Color(gridBrightnesses[i], gridBrightnesses[i], gridBrightnesses[i], 1.0f)); } LineBatch.Draw(new Vector3(bounds.Min.X, bounds.Min.Y, bounds.Min.Z), new Vector3(bounds.Max.X, bounds.Min.Y, bounds.Max.Z), 5.0f, Color.White); LineBatch.Draw(new Vector3(bounds.Min.X, bounds.Max.Y, bounds.Min.Z), new Vector3(bounds.Max.X, bounds.Max.Y, bounds.Max.Z), 5.0f, Color.White); LineBatch.Draw(new Vector3(bounds.Max.X, bounds.Min.Y, bounds.Min.Z), new Vector3(bounds.Max.X, bounds.Max.Y, bounds.Max.Z), 5.0f, Color.White); LineBatch.Draw(new Vector3(bounds.Min.X, bounds.Max.Y, bounds.Min.Z), new Vector3(bounds.Min.X, bounds.Min.Y, bounds.Max.Z), 5.0f, Color.White); LineBatch.End(); }
// Begin is called to tell the LineBatch what camera to draw from, // and to prepare the graphics card to render those primitives. public void Begin(Matrix world, Camera3D camera) { if (hasBegun) { throw new InvalidOperationException ("End must be called before Begin can be called again."); } basicEffect.World = world; basicEffect.View = camera.View; basicEffect.Projection = camera.Projection; //tell our basic effect to begin. basicEffect.CurrentTechnique.Passes[0].Apply(); // flip the error checking boolean. It's now ok to call Add, Flush, // and End. hasBegun = true; }