Browse Source

make a bunch of fields readonly

GitOrigin-RevId: 0c3533c650
master
Colin McMillen 4 years ago
parent
commit
4b14aef1b5
  1. 6
      Shared/Debug.cs
  2. 2
      Shared/Player.cs
  3. 8
      Shared/SneakGame.cs
  4. 12
      Shared/World.cs

6
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<string> toasts = new LinkedList<string>();
static List<DebugRect> rects = new List<DebugRect>();
static List<DebugLine> lines = new List<DebugLine>();
static readonly LinkedList<string> toasts = new LinkedList<string>();
static readonly List<DebugRect> rects = new List<DebugRect>();
static readonly List<DebugLine> lines = new List<DebugLine>();
static Texture2D whiteTexture;

2
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;

8
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> 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 grasslandBg2;
Player player;
World world;
Camera camera = new Camera();
readonly Camera camera = new Camera();
public SneakGame() {
graphics = new GraphicsDeviceManager(this);

12
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 = @"

Loading…
Cancel
Save