Description:
Organize code and add regions.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -288,14 +288,10 | |||||
|
288 |
|
288 | ||
|
289 | // Run game logic in here. Do NOT render anything here! |
|
289 | // Run game logic in here. Do NOT render anything here! |
|
290 | KeyboardState keyboardCur = Keyboard.GetState(); |
|
290 | KeyboardState keyboardCur = Keyboard.GetState(); |
|
291 | if (keyboardCur.IsKeyDown(Keys.Q) && keyboardPrev.IsKeyUp(Keys.Q)) |
|
291 | |
|
292 | { |
|
292 | #region input |
|
293 | System.Console.WriteLine("Quitting"); |
|
293 | #region camera_movement_keys |
|
294 | Environment.Exit(0); |
|
294 | if (keyboardCur.IsKeyDown(Keys.Down)) |
|
295 | } |
|
||
|
296 |
|
|||
|
297 |
|
|||
|
298 | if (keyboardCur.IsKeyDown(Keys.Down)) |
|
||
|
299 | { |
|
295 | { |
|
300 | this.camera.Move(new Vector2(0, 2)); |
|
296 | this.camera.Move(new Vector2(0, 2)); |
|
301 | } |
|
297 | } |
@@ -323,7 +319,14 | |||||
|
323 |
|
319 | ||
|
324 | this.camera.ZoomIn(); |
|
320 | this.camera.ZoomIn(); |
|
325 | } |
|
321 | } |
|
|
322 | #endregion camera_movement_keys | ||
|
326 |
|
323 | ||
|
|
324 | #region misc_keys | ||
|
|
325 | if (keyboardCur.IsKeyDown(Keys.Q) && keyboardPrev.IsKeyUp(Keys.Q)) | ||
|
|
326 | { | ||
|
|
327 | System.Console.WriteLine("Quitting"); | ||
|
|
328 | Environment.Exit(0); | ||
|
|
329 | } | ||
|
327 | if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash)) |
|
330 | if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash)) |
|
328 | { |
|
331 | { |
|
329 | this.show_another_window = !this.show_another_window; |
|
332 | this.show_another_window = !this.show_another_window; |
@@ -335,19 +338,24 | |||||
|
335 | this.showGrid = !this.showGrid; |
|
338 | this.showGrid = !this.showGrid; |
|
336 |
|
339 | ||
|
337 | } |
|
340 | } |
|
|
341 | if (keyboardCur.IsKeyDown(Keys.Space) && keyboardPrev.IsKeyUp(Keys.Space)) | ||
|
|
342 | { | ||
|
|
343 | sound.Play(volume, pitch, pan); | ||
|
|
344 | } | ||
|
|
345 | #endregion misc_keys | ||
|
338 |
|
346 | ||
|
|
347 | |||
|
|
348 | #region gamerate_keys | ||
|
339 | if (keyboardCur.IsKeyDown(Keys.D0) && keyboardPrev.IsKeyUp(Keys.D0)) |
|
349 | if (keyboardCur.IsKeyDown(Keys.D0) && keyboardPrev.IsKeyUp(Keys.D0)) |
|
340 | { |
|
350 | { |
|
341 | this.simulation.paused = !this.simulation.paused; |
|
351 | this.simulation.paused = !this.simulation.paused; |
|
342 |
|
352 | ||
|
343 | } |
|
353 | } |
|
|
354 | #endregion gamerate_keys | ||
|
344 |
|
355 | ||
|
|
356 | |||
|
345 |
|
357 | ||
|
346 |
|
358 | ||
|
347 | if (keyboardCur.IsKeyDown(Keys.Space) && keyboardPrev.IsKeyUp(Keys.Space)) |
|
||
|
348 | { |
|
||
|
349 | sound.Play(volume, pitch, pan); |
|
||
|
350 | } |
|
||
|
351 | //if (keyboardCur.IsKeyDown(Keys.P) && keyboardPrev.IsKeyUp(Keys.P)) |
|
359 | //if (keyboardCur.IsKeyDown(Keys.P) && keyboardPrev.IsKeyUp(Keys.P)) |
|
352 | // { |
|
360 | // { |
|
353 | // this.player_state = !this.player_state; |
|
361 | // this.player_state = !this.player_state; |
@@ -378,7 +386,7 | |||||
|
378 | { |
|
386 | { |
|
379 | this.camera.Move(new Vector2(0, 4)); |
|
387 | this.camera.Move(new Vector2(0, 4)); |
|
380 | } |
|
388 | } |
|
381 |
|
389 | #endregion input | |
|
382 |
|
390 | ||
|
383 | this.simulation.update(gameTime.ElapsedGameTime); |
|
391 | this.simulation.update(gameTime.ElapsedGameTime); |
|
384 |
|
392 | ||
@@ -496,11 +504,6 | |||||
|
496 |
|
504 | ||
|
497 | } |
|
505 | } |
|
498 |
|
506 | ||
|
499 |
|
|||
|
500 |
|
|||
|
501 |
|
|||
|
502 |
|
|||
|
503 |
|
|||
|
504 | protected override void Draw(GameTime gameTime) |
|
507 | protected override void Draw(GameTime gameTime) |
|
505 | { |
|
508 | { |
|
506 | // Render stuff in here. Do NOT run game logic in here! |
|
509 | // Render stuff in here. Do NOT run game logic in here! |
@@ -520,8 +523,8 | |||||
|
520 | null, |
|
523 | null, |
|
521 | camera.get_transformation(GraphicsDevice)); |
|
524 | camera.get_transformation(GraphicsDevice)); |
|
522 |
|
525 | ||
|
523 |
|
|
526 | //New tile stuff |
|
524 | /* |
|
527 | /* |
|
525 | Vector2 firstSquare = Vector2.Zero; |
|
528 | Vector2 firstSquare = Vector2.Zero; |
|
526 | int firstX = (int)firstSquare.X; |
|
529 | int firstX = (int)firstSquare.X; |
|
527 | int firstY = (int)firstSquare.Y; |
|
530 | int firstY = (int)firstSquare.Y; |
@@ -558,9 +561,9 | |||||
|
558 | } |
|
561 | } |
|
559 | }*/ |
|
562 | }*/ |
|
560 |
|
563 | ||
|
561 |
|
564 | #region draw_tiles | |
|
562 | //reset |
|
565 | //reset |
|
563 |
|
|
566 | this.tilesDrawn = 0; |
|
564 |
|
567 | ||
|
565 | for (int y = 0; y < this.squaresDown; y++) |
|
568 | for (int y = 0; y < this.squaresDown; y++) |
|
566 | { |
|
569 | { |
@@ -593,8 +596,11 | |||||
|
593 | } |
|
596 | } |
|
594 |
|
597 | ||
|
595 | } |
|
598 | } |
|
|
599 | #endregion draw_tiles | ||
|
596 |
|
600 | ||
|
597 | if (this.showGrid) |
|
601 | #region draw_gridlines |
|
|
602 | |||
|
|
603 | if (this.showGrid) | ||
|
598 | { |
|
604 | { |
|
599 | //need to go one extra so gridlines include the far side of the final tile: |
|
605 | //need to go one extra so gridlines include the far side of the final tile: |
|
600 | for (int y = 0; y < (this.squaresDown + 1); y++) |
|
606 | for (int y = 0; y < (this.squaresDown + 1); y++) |
@@ -623,10 +629,12 | |||||
|
623 |
|
629 | ||
|
624 | } |
|
630 | } |
|
625 | } |
|
631 | } |
|
|
632 | #endregion draw_gridlines | ||
|
626 |
|
633 | ||
|
627 | //Gridlines |
|
634 | |
|
628 | //Lines going down and to the right: |
|
635 | //Gridlines |
|
629 | /* |
|
636 | //Lines going down and to the right: |
|
|
637 | /* | ||
|
630 | for (int x = (int)(-this.squaresAcross/2); x < this.squaresAcross; x++) |
|
638 | for (int x = (int)(-this.squaresAcross/2); x < this.squaresAcross; x++) |
|
631 | { |
|
639 | { |
|
632 | int rowOffset = 0; |
|
640 | int rowOffset = 0; |
@@ -663,16 +671,15 | |||||
|
663 | } |
|
671 | } |
|
664 | */ |
|
672 | */ |
|
665 |
|
673 | ||
|
666 |
|
|
674 | drawTileAt(4, 4, 140, 3); |
|
667 | drawTileAt(6, 4, 141, 3); |
|
675 | drawTileAt(6, 4, 141, 3); |
|
668 | drawTileAt(8, 4, 142, 2); |
|
676 | drawTileAt(8, 4, 142, 2); |
|
669 | drawTileAt(10, 4, 142, 3); |
|
677 | drawTileAt(10, 4, 142, 3); |
|
670 |
|
678 | ||
|
671 |
|
679 | #region draw_cursor | |
|
672 |
|
|
680 | drawTileAt((int)this.mouseGrid.X, (int)this.mouseGrid.Y, 2, 1, 0.85f); //between tiles and gridlines |
|
673 |
|
681 | #endregion draw_cursor | |
|
674 |
|
682 | /* | |
|
675 | /* |
|
||
|
676 |
|
683 | ||
|
677 | for (int i = 0; i< 80; i++) |
|
684 | for (int i = 0; i< 80; i++) |
|
678 | { |
|
685 | { |
@@ -693,8 +700,8 | |||||
|
693 | } |
|
700 | } |
|
694 | }//*/ |
|
701 | }//*/ |
|
695 |
|
702 | ||
|
696 |
|
703 | #region draw_trees | |
|
697 |
|
|
704 | for (int i = 0; i < this.simulation.map.MapHeight; i++) |
|
698 | { |
|
705 | { |
|
699 | for (int j = 0; j < this.simulation.map.MapWidth; j += 1) |
|
706 | for (int j = 0; j < this.simulation.map.MapWidth; j += 1) |
|
700 | { |
|
707 | { |
@@ -709,20 +716,19 | |||||
|
709 | { |
|
716 | { |
|
710 | drawTileAt(i, j, 142, 2); |
|
717 | drawTileAt(i, j, 142, 2); |
|
711 | } |
|
718 | } |
|
712 |
|
|||
|
713 | } |
|
719 | } |
|
714 |
|
|||
|
715 |
|
|||
|
716 | } |
|
720 | } |
|
717 | } |
|
721 | } |
|
|
722 | #endregion draw_trees | ||
|
718 |
|
723 | ||
|
719 |
|
|
724 | drawTileAt(2, 2, 140, 2); |
|
720 | drawTileAt(1, 1, 140, 2); |
|
725 | drawTileAt(1, 1, 140, 2); |
|
721 | drawTileAt(3, 2, 140, 2); |
|
726 | drawTileAt(3, 2, 140, 2); |
|
722 |
|
727 | ||
|
723 | batch.End(); |
|
728 | batch.End(); |
|
724 |
|
729 | ||
|
725 | batch.Begin(SpriteSortMode.BackToFront, |
|
730 | #region draw_header |
|
|
731 | batch.Begin(SpriteSortMode.BackToFront, | ||
|
726 | BlendState.AlphaBlend, |
|
732 | BlendState.AlphaBlend, |
|
727 | null, |
|
733 | null, |
|
728 | null, |
|
734 | null, |
@@ -752,12 +758,12 | |||||
|
752 |
|
758 | ||
|
753 | batch.DrawString(monoFont, header_left, new Vector2(1, 1), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f); |
|
759 | batch.DrawString(monoFont, header_left, new Vector2(1, 1), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f); |
|
754 | batch.DrawString(monoFont, header_middle, new Vector2(middle_start, 1), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f); |
|
760 | batch.DrawString(monoFont, header_middle, new Vector2(middle_start, 1), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f); |
|
755 |
|
761 | #endregion draw_header | |
|
756 |
|
762 | ||
|
757 |
|
763 | ||
|
758 |
|
|
764 | batch.End(); |
|
759 |
|
765 | ||
|
760 |
|
766 | #region debug_window | |
|
761 | //Calcs for debug window: |
|
767 | //Calcs for debug window: |
|
762 | if ((this.frameCounter % 15) == 0) { |
|
768 | if ((this.frameCounter % 15) == 0) { |
|
763 | past_fps.Enqueue(this.frameRate); |
|
769 | past_fps.Enqueue(this.frameRate); |
@@ -825,9 +831,11 | |||||
|
825 | } |
|
831 | } |
|
826 |
|
832 | ||
|
827 | _imGuiRenderer.AfterLayout(); |
|
833 | _imGuiRenderer.AfterLayout(); |
|
828 |
|
834 | ||
|
|
835 | #endregion debug_window | ||
|
829 |
|
836 | ||
|
830 | stopWatch.Stop(); |
|
837 | |
|
|
838 | stopWatch.Stop(); | ||
|
831 | this.drawTime = stopWatch.Elapsed; |
|
839 | this.drawTime = stopWatch.Elapsed; |
|
832 |
|
840 | ||
|
833 | base.Draw(gameTime); |
|
841 | base.Draw(gameTime); |
You need to be logged in to leave comments.
Login now