This project uses AI to automatically generate game assets (characters, world maps) from story descriptions and creates an interactive game experience.
Dream Farming transforms written stories into visual game assets using multiple AI services:
- Google Gemini: Extracts character and location information from stories
- Imagen-3.0: Generates character images
- DALL-E: Creates world maps
- Recraft: Removes backgrounds from character images
- Python 3.8+
- pip package manager
- API keys for Google Gemini, OpenAI, and Recraft
- Clone the repository:
git clone <repository-url>
cd "Dream Farming"- Install required dependencies:
pip install google-generativeai openai pillow requests pyyaml pygameCreate a story file named story.txt in the root directory. Write your story including:
- Character descriptions (appearance, personality, role)
- Location descriptions (environment, atmosphere)
- Plot elements and dialogue
Example:
In the mystical land of Eldoria, a young mage named Luna with silver hair and blue robes...
The ancient forest of Whisperwind is filled with glowing mushrooms and crystal streams...
Edit the configuration file code/config.yaml and add your API keys:
# API Keys Configuration
# Google Gemini API key for image generation and text processing
gemini_api_key: "your_gemini_api_key_here"
# OpenAI API key for DALL-E image generation
openai_api_key: "your_openai_api_key_here"
# Recraft API key for background removal
recraft_api_key: "your_recraft_api_key_here"How to get API keys:
- Google Gemini: Visit Google AI Studio and create an API key
- OpenAI: Sign up at OpenAI Platform and generate an API key
- Recraft: Register at Recraft AI and obtain an API key
Run the AI asset generator:
cd code
python llm.pyThis will:
- Extract character and location information from your story
- Generate character images using Imagen-3.0
- Remove backgrounds from character images
- Create a world map using DALL-E
- Save all assets in the
graphics/directory - Output extracted information to
output.json
Generated Assets:
graphics/character/[character_name].png- Character images with backgroundsgraphics/character/[character_name]_vector.png- Character images without backgroundsgraphics/world/world_map.png- Generated world mapoutput.json- Extracted story information
Launch the interactive game:
python main.pyThe game will load your generated assets and create an interactive experience based on your story.
Dream Farming/
├── code/
│ ├── llm.py # AI asset generator
│ ├── config.yaml # API configuration
│ └── prompt_hub.py # AI prompts
├── graphics/
│ ├── character/ # Generated character images
│ └── world/ # Generated world maps
├── story.txt # Your input story
├── output.json # Extracted story data
├── main.py # Game launcher
└── readme.me # This file
- Story Analysis: Automatically extracts characters, locations, and plot elements
- Character Generation: Creates unique character images based on descriptions
- World Building: Generates atmospheric world maps
- Background Removal: Creates clean character sprites for games
- Interactive Game: Playable experience using generated assets
Common Issues:
- "Config file not found": Ensure
config.yamlis in thecode/directory - "API key not found": Check that your API keys are correctly set in
config.yaml - Image generation fails: Verify your API keys have sufficient credits/quota
- Import errors: Install missing packages with
pip install <package-name>
API Rate Limits:
- If you encounter rate limit errors, wait a few minutes before retrying
- Consider upgrading your API plans for higher limits
After running the complete pipeline, you'll have:
- Character sprites ready for game development
- A custom world map matching your story's setting
- JSON data structure with all extracted story elements
- An interactive game showcasing your generated content
This project is open source. Please ensure you comply with the terms of service for all AI APIs used.
Feel free to submit issues and enhancement requests!
