Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Separate / Divide code handling graphics from code handling logic #114

Merged

Conversation

tcoyvwac
Copy link
Collaborator

@tcoyvwac tcoyvwac commented Oct 13, 2019

Contributions to the project are welcomed.
New contributors vary in Issues and Pull Requests. However, logical Issues and PRs (to do with game flow and running of the game) are different from stylistic Issues and PRs (to do with spacing in 2048 game board's grid, language text-labels presentation, e.t.c.).

Currently, for newcomers and reviewers, it can be slow to understand the project's code because "graphics" code is too interlinked with code dealing with logic. This PR is to help fix this.

Key points:

  • "Graphical functions" in the project have been moved to translation units with "*-graphics" at the end of its name as much as possible.
  • Graphical functions' dependency on the global variable std::cout has been reduced as much as possible.
  • A new DataSuppliment function has been added to pass data required for some graphical functions to work.
  • Comments on the standard "layering of elements" in a typical 2048 game session has been added.
  • Basic design of a "separation of concerns" of event-triggers / flags has been added. Will be more robust in a future PR.

DataSuppliment() is a simple dependency injection tool for (future)
functions in the "game-graphics" (and other similar / related)
translation units. This DI-like function helps the separation of the
coupling between data and the UI.
* Using DataSuppliment(), decoupled global variable state from
drawMainMenuGraphics().
* drawMainMenuGraphics() now uses DrawAlways() to render to screen.
drawEndGameStatistics() renamed to EndGameStatisticsPrompt().
drawScoreBoard() renamed to CurrentGameScoreBoardPrompt().
Accepts a custom tuple-struct type (scoreboard_display_data_t) as
additional data for its printing purposes.
scoreboard_display_data_t{} made outside of drawBoard().
- drawBoard() renamed to GameScoreBoardOverlay().
- CurrentGameScorePrompt() renamed to GameScoreBoardBox().

- Accepts a custom tuple-struct type (scoreboard_display_data_t) as
additional data for its printing purposes.
@tcoyvwac tcoyvwac force-pushed the fix/extract_graphics_code_from_logic_code branch from fc2369a to e36d2eb Compare October 13, 2019 06:12
@tcoyvwac tcoyvwac force-pushed the fix/extract_graphics_code_from_logic_code branch from e36d2eb to 5812b23 Compare October 13, 2019 06:48
graphics TU

- prettyPrintStats() now named TotalStatisticsOverlay().
parameter

- TotalStatisticsOverlay() uses total_stats_display_data_t as parameter.
- getPlaySizeOfGameboardDataArray and getTileOnGameboardDataArray now
have public TU linkage visibility.
- drawTileString() and tileColor() moved to tile-graphics TU.
- drawGameBoard() now renamed to GameBoardTextOutput().
- GameBoardTextOutput() wrapped in Gameboard::Graphics namespace.
- Moved AsciiArt2048() call from Game-Graphics TU's
GameScoreBoardOverlay() into Game TU's drawGraphics().
- FLAG_GAME_IS_ASKING_QUESTION_MODE added to gamestatus_t.
- DisplayGameQuestionsToPlayerPrompt() created to hold all text prompt
for questions to player. Only active when
FLAG_GAME_IS_ASKING_QUESTION_MODE is active.
- drawEndGameLoopGraphics() is a helper function that draws items needed
for game-over screen.
@tcoyvwac tcoyvwac force-pushed the fix/extract_graphics_code_from_logic_code branch from 5812b23 to be5d659 Compare October 13, 2019 07:15
@tcoyvwac
Copy link
Collaborator Author

The PR will be closed via a regular "Merge". 📨 📥
(Will be automatically merged in <12hrs from this message if no objections)

@tcoyvwac
Copy link
Collaborator Author

As there are no objections, will merge.

@tcoyvwac tcoyvwac merged commit 7bda02a into plibither8:master Oct 13, 2019
@tcoyvwac
Copy link
Collaborator Author

This PR removes soft-blocking on Issue #111.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant