Game Renderer Module
The Game Renderer module is the primary engine for visualizing the Property Tycoon game during active play. It acts as an interface between the game’s internal state (managed by Game, GameLogic, Board, Player, etc.) and the visual output presented to the user via the Pygame display surface. Its core responsibility is to accurately and efficiently draw all necessary game elements frame by frame, including static components like the board, dynamic elements like player tokens and dice, and context-sensitive UI panels for actions like buying, auctioning, or managing properties.
High-Level Design
Use Case Diagram (What it Renders)
This diagram outlines the key visual components and information that the GameRenderer is tasked with displaying during a typical game session. The “Game Loop” represents the main process invoking the renderer.
Game Renderer Responsibilities
Dependency Diagram
This diagram illustrates the main modules and libraries that the GameRenderer relies upon to function. It highlights its central role in accessing game state and utilizing utility modules for presentation.
Game Renderer Dependencies
Simplified State-Based Rendering Logic
The main draw() method adapts its output based significantly on the current game.state. This state diagram shows the primary rendering paths determined by the game state.
State Diagram: GameRenderer Draw Logic by Game State
Detailed Design
Class Diagram
This diagram details the structure of the GameRenderer class itself, showing its attributes (dependencies and fonts) and its public methods responsible for drawing specific elements.
GameRenderer Class Diagram
Activity Diagram: Drawing Dice
This diagram details the logic within the draw_dice method, including handling the rolling animation state and the special effect for doubles.
Activity Diagram: draw_dice Method
Sequence Diagrams
Main Draw Sequence
Illustrates the high-level flow of execution when the main GameRenderer.draw() method is invoked by the game loop.
Sequence Diagram: Main Draw Call
Drawing Time Remaining with Warning
Shows the specific logic executed within the draw_time_remaining method, particularly when the game timer is low, triggering visual warnings.
Sequence Diagram: Drawing Time Warning
Drawing Auction UI
Details the steps for rendering the auction interface when the game is in the “AUCTION” state.
Sequence Diagram: Drawing Auction UI
Drawing Jail Options
Shows the process for displaying the available actions to a player currently in jail.
Sequence Diagram: Drawing Jail Options
Drawing Notification/Popup
Illustrates how temporary messages (notifications or popups) are displayed over the main game view.
Sequence Diagram: Drawing Notification/Popup
Key Classes Overview
GameRenderer: The central class orchestrating the drawing process. It holds references to the game state (Game, GameActions), the display surface (screen), and various fonts (Font_Manager). It contains numerous draw_ methods, each responsible for rendering a specific visual component (e.g., draw_dice, draw_player_info_panel implicitly, draw_auction, draw_property_card). The main draw() method acts as the primary entry point, called each frame, which then delegates rendering tasks to the appropriate sub-methods based on the current game.state and other conditions.