26 lines
No EOL
2 KiB
Markdown
26 lines
No EOL
2 KiB
Markdown
Project Summary: C/SDL2 Cinematic Game Template
|
|
# 🛠 Technical Stack
|
|
Language: C (C11 standard)
|
|
Libraries: SDL2, SDL2_ttf
|
|
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 $\rightarrow$ Update $\rightarrow$ 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: Implemented time-based calculations instead of frame-based ones to ensure gameplay speed is identical regardless of hardware performance.
|
|
2. Cinematic Text System
|
|
Typewriter Effect: A custom-built system that reveals a message ("Hello, human.") letter-by-letter.
|
|
Timing: Uses SDL_GetTicks() to trigger a new character reveal every 150ms.
|
|
Rendering: Uses SDL_ttf for high-quality text. The text is dynamically centered on the screen by calculating the surface dimensions relative to the window size.
|
|
Memory Safety: Implemented strict null-termination (\0) on the text buffer to prevent memory leakage/artifacts.
|
|
3. Game Mechanics & State
|
|
Game State Struct: A centralized Game struct that manages the loop status, timers, font pointers, and player data.
|
|
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 (currently invisible but fully functional in the background).
|
|
# 📂 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.
|
|
# 🎯 Current Status
|
|
The game currently launches a black window, reveals a centered message with a cinematic typewriter animation, and allows the user to exit via a timed Escape-key hold. The codebase is cleaned, documented, and optimized for macOS. |