A pill slinging pygame!
- Sound Effects by Pixabay modified for creative use
- CC0 license
Requirements:
- Python 3.13
- UV package and project manager
uv run SassyCathySassy Cathy is a simple game created using Pygame. It features a primary GameObjectController (GOC) that manages all in-game objects and a RulesEngine (RE) that enforces the game’s logic and rules. During each game tick, the GOC iterates over all objects, and the RE applies rules to those objects based on various criteria.
Sassy Cathy is a simple 2D game built using the Pygame library. Players control a character named Cathy as she interacts with other game objects in a dynamic environment. The game is structured around a core loop, where objects are managed, and game rules are enforced, creating an engaging and interactive experience.
The GameObjectController is responsible for managing all in-game objects. It serves as a central registry, storing and updating the state of every object during the game loop.
- Tracking GameObjects: Managing the creation, updating, rendering, and deletion of game objects.
- Collision Management: Handling interactions between objects.
- Object Updates: Iterating through all objects and applying position, movement, or state changes.
In essence, the GOC is the backbone of the game, ensuring that all objects behave and render correctly.
The RulesEngine encapsulates the game logic and defines how objects interact with one another. It evaluates game states and applies rules based on specific conditions.
- Enforcing Game Rules: Applying logic such as player movement restrictions, level-based mechanics, or win/lose conditions.
- Enemy Spawning: Introducing enemies or obstacles as the game progresses.
- Score and Level Management: Calculating scores and tracking progression.
The RE ensures the game remains fun, challenging, and coherent by controlling behavior based on predefined logic.
- Initialization: The game starts by creating the GOC, RE, and initializing Cathy, the player-controlled character.
- Game Loop:
- The GOC updates all game objects (e.g., moving Cathy, handling interactions).
- The RE applies rules (e.g., spawning enemies, enforcing boundaries).
- Objects are rendered to the screen.
- Player Interaction: Players move Cathy around, interact with the environment, and progress through the game’s challenges.
The combination of the GOC and RE forms a robust system for managing game objects and enforcing rules, making the game dynamic and replayable.