A stealth-based 2D platformer where you don't have to kill anyone unless you want to. https://www.semicolin.games
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.9 KiB

  1. using Microsoft.Xna.Framework;
  2. using Microsoft.Xna.Framework.Audio;
  3. using Microsoft.Xna.Framework.Graphics;
  4. using System;
  5. namespace SemiColinGames {
  6. public sealed class TreeScene : IScene {
  7. const int MAX_LINE_VERTICES = 4;
  8. private readonly Color backgroundColor = Color.SkyBlue;
  9. private readonly GraphicsDevice graphics;
  10. private readonly BasicEffect basicEffect;
  11. private VertexPositionColor[] lineVertices;
  12. private VertexBuffer vertexBuffer;
  13. public TreeScene(GraphicsDevice graphics) {
  14. this.graphics = graphics;
  15. basicEffect = new BasicEffect(graphics) {
  16. World = Matrix.CreateTranslation(0, 0, 0),
  17. View = Matrix.CreateLookAt(Vector3.Backward, Vector3.Zero, Vector3.Up),
  18. VertexColorEnabled = true
  19. };
  20. basicEffect.Projection = Matrix.CreateOrthographicOffCenter(0, 1920, 1080, 0, -1, 1);
  21. lineVertices = new VertexPositionColor[MAX_LINE_VERTICES];
  22. vertexBuffer = new VertexBuffer(
  23. graphics, typeof(VertexPositionColor), MAX_LINE_VERTICES, BufferUsage.WriteOnly);
  24. }
  25. ~TreeScene() {
  26. Dispose();
  27. }
  28. public void Dispose() {
  29. vertexBuffer.Dispose();
  30. GC.SuppressFinalize(this);
  31. }
  32. public void Draw(bool isRunningSlowly, IWorld iworld, bool paused) {
  33. graphics.Clear(backgroundColor);
  34. lineVertices[0] = new VertexPositionColor(new Vector3(100, 100, 0), Color.Black);
  35. lineVertices[1] = new VertexPositionColor(new Vector3(300, 200, 0), Color.Black);
  36. lineVertices[2] = new VertexPositionColor(new Vector3(200, 200, 0), Color.Black);
  37. lineVertices[3] = new VertexPositionColor(new Vector3(100, 100, 0), Color.Black);
  38. graphics.SetVertexBuffer(vertexBuffer);
  39. vertexBuffer.SetData(lineVertices);
  40. foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes) {
  41. pass.Apply();
  42. graphics.DrawPrimitives(PrimitiveType.LineStrip, 0, 3 /* num lines */);
  43. }
  44. }
  45. }
  46. }