make a bunch of fields readonly

GitOrigin-RevId: 0c3533c6509a6f0199410e977d3377c34b4a753d
This commit is contained in:
Colin McMillen 2020-01-24 21:04:30 -05:00
parent 0c7c15c047
commit 4b14aef1b5
4 changed files with 14 additions and 14 deletions

View File

@ -28,9 +28,9 @@ namespace SemiColinGames {
public static bool Enabled; public static bool Enabled;
// This is a LinkedList instead of a List because SetFpsText() adds to its front. // This is a LinkedList instead of a List because SetFpsText() adds to its front.
static LinkedList<string> toasts = new LinkedList<string>(); static readonly LinkedList<string> toasts = new LinkedList<string>();
static List<DebugRect> rects = new List<DebugRect>(); static readonly List<DebugRect> rects = new List<DebugRect>();
static List<DebugLine> lines = new List<DebugLine>(); static readonly List<DebugLine> lines = new List<DebugLine>();
static Texture2D whiteTexture; static Texture2D whiteTexture;

View File

@ -11,9 +11,9 @@ namespace SemiColinGames {
private const int jumpSpeed = -600; private const int jumpSpeed = -600;
private const int gravity = 2400; private const int gravity = 2400;
private Texture2D texture;
private const int spriteSize = 48; private const int spriteSize = 48;
private const int spriteWidth = 7; private const int spriteWidth = 7;
private readonly Texture2D texture;
private Point position = new Point(64, 16 * 14); private Point position = new Point(64, 16 * 14);
private int jumps = 0; private int jumps = 0;

View File

@ -7,7 +7,7 @@ using System.Collections.Generic;
namespace SemiColinGames { namespace SemiColinGames {
public class SneakGame : Game { public class SneakGame : Game {
GraphicsDeviceManager graphics; readonly GraphicsDeviceManager graphics;
RenderTarget2D renderTarget; RenderTarget2D renderTarget;
SpriteBatch spriteBatch; SpriteBatch spriteBatch;
@ -16,15 +16,15 @@ namespace SemiColinGames {
bool paused = false; bool paused = false;
IDisplay display; IDisplay display;
History<Input> input = new History<Input>(2); readonly History<Input> input = new History<Input>(2);
FpsCounter fpsCounter = new FpsCounter(); readonly FpsCounter fpsCounter = new FpsCounter();
Texture2D grasslandBg1; Texture2D grasslandBg1;
Texture2D grasslandBg2; Texture2D grasslandBg2;
Player player; Player player;
World world; World world;
Camera camera = new Camera(); readonly Camera camera = new Camera();
public SneakGame() { public SneakGame() {
graphics = new GraphicsDeviceManager(this); graphics = new GraphicsDeviceManager(this);

View File

@ -17,8 +17,8 @@ namespace SemiColinGames {
} }
class Tile { class Tile {
Texture2D texture; readonly Texture2D texture;
Terrain terrain; readonly Terrain terrain;
Rectangle position; Rectangle position;
public Tile(Texture2D texture, Terrain terrain, Rectangle position) { public Tile(Texture2D texture, Terrain terrain, Rectangle position) {
@ -84,14 +84,14 @@ namespace SemiColinGames {
class World { class World {
public const int TileSize = 16; public const int TileSize = 16;
int width; readonly int width;
int height; readonly int height;
Tile[,] tiles; readonly Tile[,] tiles;
public int Width { get; } public int Width { get; }
public int Height { get; } public int Height { get; }
string worldString = @" readonly string worldString = @"