34 lines
No EOL
3.1 KiB
Markdown
34 lines
No EOL
3.1 KiB
Markdown
Project Summary: C/SDL2 Cinematic Game Template with Screen Shake and Audio
|
|
# 🛠 Technical Stack
|
|
Language: C (C11 standard)
|
|
Libraries: SDL2, SDL2_ttf, SDL2_mixer
|
|
OS: macOS (Homebrew environment)
|
|
Build System: Makefile using sdl2-config for cross-platform header/library paths.
|
|
# 🚀 Current Implementation
|
|
1. Core Architecture
|
|
Game Loop: Implemented a professional Input → Update → Render cycle.
|
|
FPS Locking: Locked at 60 FPS using a dynamic frame-capper (SDL_Delay based on frame start/end timestamps) to ensure CPU efficiency and consistent timing.
|
|
Delta Time: Fixed time-step used for consistent updates; delta time passed to input handling (currently unused for movement but maintains architectural consistency).
|
|
2. Cinematic Text System
|
|
Typewriter Effect: A custom-built system that reveals two messages letter-by-letter.
|
|
Message 1: "Hello, human." (large font, 120pt)
|
|
Message 2: Multi-line Undertale-themed message about C being the best programming language (small font, 24pt) with the words "Undertale", "rewritten", "opensourced", "C", "GPL3.0" rendered in yellow and shifted up for better centering
|
|
Timing: Uses SDL_GetTicks() to trigger a new character reveal every ~333ms for message 1 and ~36ms for message 2 (after 3.5s delay).
|
|
Rendering: Uses SDL_ttf for high-quality text. The text is dynamically centered on the screen by calculating surface dimensions relative to window size, supporting multi-line strings.
|
|
Memory Safety: Implemented strict null-termination (\0) on text buffers to prevent memory leakage/artifacts.
|
|
3. Enhanced Effects & Features
|
|
Screen Shake: Triggered on each non-space character beep, providing visual feedback with decaying intensity.
|
|
Audio Feedback: Plays a beep sound effect (lowered pitch via mixer frequency) for each typed non-space character.
|
|
Hold-to-Quit: A safety exit mechanism where the user must hold the Escape key for exactly 1000ms (1 second) to terminate the program.
|
|
Player Object: A Player struct exists with position and speed data; arrow key movement is implemented (invisible during intro sequence but functional in background).
|
|
4. Game Mechanics & State
|
|
Game State Struct: A centralized Game struct that manages loop status, timers, font pointers, audio resources, shake effect, and player data.
|
|
Message Transition: Automatically switches from message 1 to message 2 after 3.5 seconds of completing message 1.
|
|
Resource Management: Proper initialization and cleanup of SDL, TTF, mixer, fonts, and audio chunks.
|
|
# 📂 Project Structure
|
|
Makefile: Handles compilation and linking of SDL2 libraries.
|
|
src/main.c: The entire game logic, fully documented with header and inline comments.
|
|
assets/font.ttf: External TrueType font used for rendering.
|
|
assets/dialog-beep.wav: Sound effect for character typing.
|
|
# 🎯 Current Status
|
|
The game launches a black window, reveals a centered message with a cinematic typewriter animation (two sequences), includes screen shake and audio feedback for each typed character, and allows the user to exit via a timed Escape-key hold. Arrow keys move an invisible player character in the background. The codebase is cleaned, documented, and optimized for macOS. |