/// <summary> /// Initializes a glider, starting at coordinates (0,0). /// </summary> /// <param name="field">The field to set the start cells for.</param> public void Initialize(Field field) { field.SetCell(0, 1, true); field.SetCell(1, 2, true); field.SetCell(2, 0, true); field.SetCell(2, 1, true); field.SetCell(2, 2, true); }
public void Initialize(Field field, int startX, int startY) { field.SetCell(startY, startX + 1, true); field.SetCell(startY + 1, startX + 2, true); field.SetCell(startY + 2, startX, true); field.SetCell(startY + 2, startX + 1, true); field.SetCell(startY + 2, startX + 2, true); }
void IFieldInitializer.Initialize(Field field, int startX, int startY) { Random random = new Random(); int x; int y; field.SetAll(false); for (int i = 0; i < (field.Columns * field.Rows) * 0.5; i++) { x = random.Next(0, field.Columns); y = random.Next(0, field.Rows); field.SetCell(y, x, true); } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { field = new Field(400, 400); fieldInitializer = new RandomFieldInitializer(); rule = new RegularCellRule(); InitializeStartPopulation(); int fieldWidth = graphics.PreferredBackBufferWidth / field.Columns; int fieldHeight = graphics.PreferredBackBufferHeight / field.Rows; InitializeRectangles(fieldWidth, fieldHeight); base.Initialize(); }