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 | 289 | // Run game logic in here. Do NOT render anything here! |
|
290 | 290 | KeyboardState keyboardCur = Keyboard.GetState(); |
|
291 | if (keyboardCur.IsKeyDown(Keys.Q) && keyboardPrev.IsKeyUp(Keys.Q)) | |
|
292 | { | |
|
293 | System.Console.WriteLine("Quitting"); | |
|
294 | Environment.Exit(0); | |
|
295 | } | |
|
296 | ||
|
297 | ||
|
298 | if (keyboardCur.IsKeyDown(Keys.Down)) | |
|
291 | ||
|
292 | #region input | |
|
293 | #region camera_movement_keys | |
|
294 | if (keyboardCur.IsKeyDown(Keys.Down)) | |
|
299 | 295 | { |
|
300 | 296 | this.camera.Move(new Vector2(0, 2)); |
|
301 | 297 | } |
@@ -323,7 +319,14 | |||
|
323 | 319 | |
|
324 | 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 | 330 | if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash)) |
|
328 | 331 | { |
|
329 | 332 | this.show_another_window = !this.show_another_window; |
@@ -335,19 +338,24 | |||
|
335 | 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 | 349 | if (keyboardCur.IsKeyDown(Keys.D0) && keyboardPrev.IsKeyUp(Keys.D0)) |
|
340 | 350 | { |
|
341 | 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 | 359 | //if (keyboardCur.IsKeyDown(Keys.P) && keyboardPrev.IsKeyUp(Keys.P)) |
|
352 | 360 | // { |
|
353 | 361 | // this.player_state = !this.player_state; |
@@ -378,7 +386,7 | |||
|
378 | 386 | { |
|
379 | 387 | this.camera.Move(new Vector2(0, 4)); |
|
380 | 388 | } |
|
381 | ||
|
389 | #endregion input | |
|
382 | 390 | |
|
383 | 391 | this.simulation.update(gameTime.ElapsedGameTime); |
|
384 | 392 | |
@@ -496,11 +504,6 | |||
|
496 | 504 | |
|
497 | 505 | } |
|
498 | 506 | |
|
499 | ||
|
500 | ||
|
501 | ||
|
502 | ||
|
503 | ||
|
504 | 507 | protected override void Draw(GameTime gameTime) |
|
505 | 508 | { |
|
506 | 509 | // Render stuff in here. Do NOT run game logic in here! |
@@ -520,8 +523,8 | |||
|
520 | 523 | null, |
|
521 | 524 | camera.get_transformation(GraphicsDevice)); |
|
522 | 525 | |
|
523 |
|
|
|
524 | /* | |
|
526 | //New tile stuff | |
|
527 | /* | |
|
525 | 528 | Vector2 firstSquare = Vector2.Zero; |
|
526 | 529 | int firstX = (int)firstSquare.X; |
|
527 | 530 | int firstY = (int)firstSquare.Y; |
@@ -558,9 +561,9 | |||
|
558 | 561 | } |
|
559 | 562 | }*/ |
|
560 | 563 | |
|
561 | ||
|
562 | //reset | |
|
563 |
|
|
|
564 | #region draw_tiles | |
|
565 | //reset | |
|
566 | this.tilesDrawn = 0; | |
|
564 | 567 | |
|
565 | 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 | 605 | //need to go one extra so gridlines include the far side of the final tile: |
|
600 | 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 | |
|
628 | //Lines going down and to the right: | |
|
629 | /* | |
|
634 | ||
|
635 | //Gridlines | |
|
636 | //Lines going down and to the right: | |
|
637 | /* | |
|
630 | 638 | for (int x = (int)(-this.squaresAcross/2); x < this.squaresAcross; x++) |
|
631 | 639 | { |
|
632 | 640 | int rowOffset = 0; |
@@ -663,16 +671,15 | |||
|
663 | 671 | } |
|
664 | 672 | */ |
|
665 | 673 | |
|
666 |
|
|
|
674 | drawTileAt(4, 4, 140, 3); | |
|
667 | 675 | drawTileAt(6, 4, 141, 3); |
|
668 | 676 | drawTileAt(8, 4, 142, 2); |
|
669 | 677 | drawTileAt(10, 4, 142, 3); |
|
670 | 678 | |
|
671 | ||
|
672 |
|
|
|
673 | ||
|
674 | ||
|
675 | /* | |
|
679 | #region draw_cursor | |
|
680 | drawTileAt((int)this.mouseGrid.X, (int)this.mouseGrid.Y, 2, 1, 0.85f); //between tiles and gridlines | |
|
681 | #endregion draw_cursor | |
|
682 | /* | |
|
676 | 683 | |
|
677 | 684 | for (int i = 0; i< 80; i++) |
|
678 | 685 | { |
@@ -693,8 +700,8 | |||
|
693 | 700 | } |
|
694 | 701 | }//*/ |
|
695 | 702 | |
|
696 | ||
|
697 |
|
|
|
703 | #region draw_trees | |
|
704 | for (int i = 0; i < this.simulation.map.MapHeight; i++) | |
|
698 | 705 | { |
|
699 | 706 | for (int j = 0; j < this.simulation.map.MapWidth; j += 1) |
|
700 | 707 | { |
@@ -709,20 +716,19 | |||
|
709 | 716 | { |
|
710 | 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 | 725 | drawTileAt(1, 1, 140, 2); |
|
721 | 726 | drawTileAt(3, 2, 140, 2); |
|
722 | 727 | |
|
723 | 728 | batch.End(); |
|
724 | 729 | |
|
725 | batch.Begin(SpriteSortMode.BackToFront, | |
|
730 | #region draw_header | |
|
731 | batch.Begin(SpriteSortMode.BackToFront, | |
|
726 | 732 | BlendState.AlphaBlend, |
|
727 | 733 | null, |
|
728 | 734 | null, |
@@ -752,12 +758,12 | |||
|
752 | 758 | |
|
753 | 759 | batch.DrawString(monoFont, header_left, new Vector2(1, 1), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f); |
|
754 | 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 | 767 | //Calcs for debug window: |
|
762 | 768 | if ((this.frameCounter % 15) == 0) { |
|
763 | 769 | past_fps.Enqueue(this.frameRate); |
@@ -825,9 +831,11 | |||
|
825 | 831 | } |
|
826 | 832 | |
|
827 | 833 | _imGuiRenderer.AfterLayout(); |
|
828 | ||
|
834 | ||
|
835 | #endregion debug_window | |
|
829 | 836 | |
|
830 | stopWatch.Stop(); | |
|
837 | ||
|
838 | stopWatch.Stop(); | |
|
831 | 839 | this.drawTime = stopWatch.Elapsed; |
|
832 | 840 | |
|
833 | 841 | base.Draw(gameTime); |
You need to be logged in to leave comments.
Login now