diff --git a/Shared/Debug.cs b/Shared/Debug.cs index 89a3448..741e0a0 100644 --- a/Shared/Debug.cs +++ b/Shared/Debug.cs @@ -28,9 +28,9 @@ namespace SemiColinGames { public static bool Enabled; // This is a LinkedList instead of a List because SetFpsText() adds to its front. - static LinkedList toasts = new LinkedList(); - static List rects = new List(); - static List lines = new List(); + static readonly LinkedList toasts = new LinkedList(); + static readonly List rects = new List(); + static readonly List lines = new List(); static Texture2D whiteTexture; diff --git a/Shared/Player.cs b/Shared/Player.cs index 4635f7a..b67500a 100644 --- a/Shared/Player.cs +++ b/Shared/Player.cs @@ -11,9 +11,9 @@ namespace SemiColinGames { private const int jumpSpeed = -600; private const int gravity = 2400; - private Texture2D texture; private const int spriteSize = 48; private const int spriteWidth = 7; + private readonly Texture2D texture; private Point position = new Point(64, 16 * 14); private int jumps = 0; diff --git a/Shared/SneakGame.cs b/Shared/SneakGame.cs index bd2a384..c9775c2 100644 --- a/Shared/SneakGame.cs +++ b/Shared/SneakGame.cs @@ -7,7 +7,7 @@ using System.Collections.Generic; namespace SemiColinGames { public class SneakGame : Game { - GraphicsDeviceManager graphics; + readonly GraphicsDeviceManager graphics; RenderTarget2D renderTarget; SpriteBatch spriteBatch; @@ -16,15 +16,15 @@ namespace SemiColinGames { bool paused = false; IDisplay display; - History input = new History(2); + readonly History input = new History(2); - FpsCounter fpsCounter = new FpsCounter(); + readonly FpsCounter fpsCounter = new FpsCounter(); Texture2D grasslandBg1; Texture2D grasslandBg2; Player player; World world; - Camera camera = new Camera(); + readonly Camera camera = new Camera(); public SneakGame() { graphics = new GraphicsDeviceManager(this); diff --git a/Shared/World.cs b/Shared/World.cs index 1ea056f..f18a851 100644 --- a/Shared/World.cs +++ b/Shared/World.cs @@ -17,8 +17,8 @@ namespace SemiColinGames { } class Tile { - Texture2D texture; - Terrain terrain; + readonly Texture2D texture; + readonly Terrain terrain; Rectangle position; public Tile(Texture2D texture, Terrain terrain, Rectangle position) { @@ -84,14 +84,14 @@ namespace SemiColinGames { class World { public const int TileSize = 16; - int width; - int height; - Tile[,] tiles; + readonly int width; + readonly int height; + readonly Tile[,] tiles; public int Width { get; } public int Height { get; } - string worldString = @" + readonly string worldString = @"