# HG changeset patch # User alys # Date 2020-12-31 04:01:26 # Node ID 801ffb2fd989258e0b157f4094b3492d049446ee # Parent 7254c1b5cd6c09882324e23b9e93fc576a0df871 Organize code and add regions. diff --git a/isometric-park-fna/FNAGame.cs b/isometric-park-fna/FNAGame.cs --- a/isometric-park-fna/FNAGame.cs +++ b/isometric-park-fna/FNAGame.cs @@ -288,14 +288,10 @@ // Run game logic in here. Do NOT render anything here! KeyboardState keyboardCur = Keyboard.GetState(); - if (keyboardCur.IsKeyDown(Keys.Q) && keyboardPrev.IsKeyUp(Keys.Q)) - { - System.Console.WriteLine("Quitting"); - Environment.Exit(0); - } - - - if (keyboardCur.IsKeyDown(Keys.Down)) + + #region input + #region camera_movement_keys + if (keyboardCur.IsKeyDown(Keys.Down)) { this.camera.Move(new Vector2(0, 2)); } @@ -323,7 +319,14 @@ this.camera.ZoomIn(); } + #endregion camera_movement_keys + #region misc_keys + if (keyboardCur.IsKeyDown(Keys.Q) && keyboardPrev.IsKeyUp(Keys.Q)) + { + System.Console.WriteLine("Quitting"); + Environment.Exit(0); + } if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash)) { this.show_another_window = !this.show_another_window; @@ -335,19 +338,24 @@ this.showGrid = !this.showGrid; } + if (keyboardCur.IsKeyDown(Keys.Space) && keyboardPrev.IsKeyUp(Keys.Space)) + { + sound.Play(volume, pitch, pan); + } + #endregion misc_keys + + #region gamerate_keys if (keyboardCur.IsKeyDown(Keys.D0) && keyboardPrev.IsKeyUp(Keys.D0)) { this.simulation.paused = !this.simulation.paused; } + #endregion gamerate_keys + - if (keyboardCur.IsKeyDown(Keys.Space) && keyboardPrev.IsKeyUp(Keys.Space)) - { - sound.Play(volume, pitch, pan); - } //if (keyboardCur.IsKeyDown(Keys.P) && keyboardPrev.IsKeyUp(Keys.P)) // { // this.player_state = !this.player_state; @@ -378,7 +386,7 @@ { this.camera.Move(new Vector2(0, 4)); } - + #endregion input this.simulation.update(gameTime.ElapsedGameTime); @@ -496,11 +504,6 @@ } - - - - - protected override void Draw(GameTime gameTime) { // Render stuff in here. Do NOT run game logic in here! @@ -520,8 +523,8 @@ null, camera.get_transformation(GraphicsDevice)); - //New tile stuff - /* + //New tile stuff + /* Vector2 firstSquare = Vector2.Zero; int firstX = (int)firstSquare.X; int firstY = (int)firstSquare.Y; @@ -558,9 +561,9 @@ } }*/ - - //reset - this.tilesDrawn = 0; + #region draw_tiles + //reset + this.tilesDrawn = 0; for (int y = 0; y < this.squaresDown; y++) { @@ -593,8 +596,11 @@ } } + #endregion draw_tiles - if (this.showGrid) + #region draw_gridlines + + if (this.showGrid) { //need to go one extra so gridlines include the far side of the final tile: for (int y = 0; y < (this.squaresDown + 1); y++) @@ -623,10 +629,12 @@ } } + #endregion draw_gridlines - //Gridlines - //Lines going down and to the right: - /* + + //Gridlines + //Lines going down and to the right: + /* for (int x = (int)(-this.squaresAcross/2); x < this.squaresAcross; x++) { int rowOffset = 0; @@ -663,16 +671,15 @@ } */ - drawTileAt(4, 4, 140, 3); + drawTileAt(4, 4, 140, 3); drawTileAt(6, 4, 141, 3); drawTileAt(8, 4, 142, 2); drawTileAt(10, 4, 142, 3); - - drawTileAt((int)this.mouseGrid.X, (int)this.mouseGrid.Y, 2, 1, 0.85f); //between tiles and gridlines - - - /* + #region draw_cursor + drawTileAt((int)this.mouseGrid.X, (int)this.mouseGrid.Y, 2, 1, 0.85f); //between tiles and gridlines + #endregion draw_cursor + /* for (int i = 0; i< 80; i++) { @@ -693,8 +700,8 @@ } }//*/ - - for (int i = 0; i < this.simulation.map.MapHeight; i++) + #region draw_trees + for (int i = 0; i < this.simulation.map.MapHeight; i++) { for (int j = 0; j < this.simulation.map.MapWidth; j += 1) { @@ -709,20 +716,19 @@ { drawTileAt(i, j, 142, 2); } - } - - } } + #endregion draw_trees - drawTileAt(2, 2, 140, 2); + drawTileAt(2, 2, 140, 2); drawTileAt(1, 1, 140, 2); drawTileAt(3, 2, 140, 2); batch.End(); - batch.Begin(SpriteSortMode.BackToFront, + #region draw_header + batch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, @@ -752,12 +758,12 @@ batch.DrawString(monoFont, header_left, new Vector2(1, 1), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f); batch.DrawString(monoFont, header_middle, new Vector2(middle_start, 1), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f); - + #endregion draw_header - batch.End(); + batch.End(); - + #region debug_window //Calcs for debug window: if ((this.frameCounter % 15) == 0) { past_fps.Enqueue(this.frameRate); @@ -825,9 +831,11 @@ } _imGuiRenderer.AfterLayout(); - + + #endregion debug_window - stopWatch.Stop(); + + stopWatch.Stop(); this.drawTime = stopWatch.Elapsed; base.Draw(gameTime);