public void Update(GameTime gameTime) { var delta = (float)gameTime.ElapsedGameTime.Milliseconds; KeyboardState stateInput = Keyboard.GetState(); if (stateInput.IsKeyDown(Keys.Space) && !previousStateInput.IsKeyDown(Keys.Space)) { if (stateEvolve == StateEvolve.Run) { stateEvolve = StateEvolve.Pause; State = "Pause"; } else { stateEvolve = StateEvolve.Run; State = "Run"; } } previousStateInput = Keyboard.GetState(); if (stateEvolve == StateEvolve.Run) { time += 0.001f * delta; Console.WriteLine("Time : {0} Delta : {1}", time, delta); if (time >= 1) { evolveLife(); iteration++; time = 0; } } }
public BoardGame(int height, int width, GraphicsDeviceManager graphics) { heightBoard = height; widthBoard = width; boardTab = new bool[height, width]; initializeValueBoardTab(); heightTile = graphics.GraphicsDevice.Viewport.Height / heightBoard; widthTile = graphics.GraphicsDevice.Viewport.Width / widthBoard; tileBlack = new Texture2D(graphics.GraphicsDevice, widthTile, heightTile); initializeColorTile(); initializeTileInBoard(); iteration = 0; time = 0; stateEvolve = StateEvolve.Run; State = "Run"; previousStateInput = Keyboard.GetState(); }