diff --git a/docs/core-features/game-development-with-sdk.md b/docs/core-features/game-development-with-sdk.md new file mode 100644 index 00000000..f2b1a593 --- /dev/null +++ b/docs/core-features/game-development-with-sdk.md @@ -0,0 +1,131 @@ +# Game Development with SpriteAI SDK + +## Overview + +The SpriteAI SDK provides powerful tools for game development, enabling developers to easily generate and manage game assets, characters, and environments. This guide will walk you through the core features of game development using the SpriteAI SDK. + +## Key Functions for Game Asset Generation + +### Character Sprite Generation + +The `generateCharacterSpritesheet()` function allows you to create dynamic character spritesheets with multiple animation states: + +```javascript +import { generateCharacterSpritesheet } from 'spriteai'; + +async function createPlayerSprite() { + const playerSprite = await generateCharacterSpritesheet('fantasy warrior', { + states: ['idle', 'walk', 'run', 'attack'], + framesPerState: 6, + style: 'pixel-art' + }); + + console.log(playerSprite.metadata); +} +``` + +#### Available Options +- `states`: Animation states (default: ['idle', 'walk', 'run', 'attack']) +- `framesPerState`: Number of frames per animation state +- `style`: Sprite art style +- `size`: Spritesheet dimensions +- `save`: Option to save the generated spritesheet + +### Available Animation States + +You can fetch the list of predefined animation states: + +```javascript +import { fetchAvailableAnimationStates } from 'spriteai'; + +async function getAnimationStates() { + const states = await fetchAvailableAnimationStates(); + console.log(states); + // Returns: ['idle', 'walk', 'run', 'attack', 'jump', 'fall', 'hurt', 'die'] +} +``` + +### Available Sprite Styles + +Get a list of supported sprite art styles: + +```javascript +import { fetchAvailableSpriteStyles } from 'spriteai'; + +async function getSpriteStyles() { + const styles = await fetchAvailableSpriteStyles(); + console.log(styles); + // Returns: ['pixel-art', 'vector', '3d', 'hand-drawn', 'anime'] +} +``` + +## Environment and Item Sprite Generation + +### Creating Environment Sprites + +Generate environment tilesets for your game world: + +```javascript +import { generateEnvironmentSprites } from 'spriteai'; + +async function createGameEnvironment() { + const environmentSprites = await generateEnvironmentSprites('fantasy forest', { + elements: 4, + style: 'pixel-art', + theme: 'fantasy' + }); + + console.log(environmentSprites.metadata); +} +``` + +### Creating Item Sprites + +Generate item sprites for inventory and collectibles: + +```javascript +import { generateItemSprites } from 'spriteai'; + +async function createGameItems() { + const itemSprites = await generateItemSprites('medieval weapons', { + itemCount: 4, + style: 'pixel-art', + itemType: 'equipment' + }); + + console.log(itemSprites.metadata); +} +``` + +## Background Color Removal + +Remove background colors from sprites for seamless integration: + +```javascript +import { removeBackgroundColor } from 'spriteai'; + +async function processSprite() { + await removeBackgroundColor( + 'input-sprite.png', + 'output-sprite.png', + 'white', + colorThreshold + ); +} +``` + +## Best Practices + +1. Always check the available styles and states before generating sprites +2. Use consistent art styles across your game assets +3. Experiment with different generation options +4. Save generated assets for reuse +5. Consider performance when generating large or complex spritesheets + +## Next Steps + +- Explore advanced sprite manipulation techniques +- Learn about animation state management +- Investigate sprite optimization strategies + +Happy game development with SpriteAI! \ No newline at end of file diff --git a/docs/core-features/sdk-quickstart.md b/docs/core-features/sdk-quickstart.md new file mode 100644 index 00000000..080d64bd --- /dev/null +++ b/docs/core-features/sdk-quickstart.md @@ -0,0 +1,125 @@ +# SDK Quickstart Guide + +## Overview + +This quickstart guide will help you get started with the SpriteAI SDK, providing a step-by-step introduction to generating game sprites and assets. + +## Prerequisites + +- Node.js (version 12 or higher) +- npm package manager +- OpenAI API key (for AI-powered sprite generation) + +## Installation + +Install the SpriteAI SDK using npm: + +```bash +npm install spriteai +``` + +## Basic Usage + +### Character Sprite Generation + +Generate a character spritesheet with different animation states: + +```javascript +import { generateCharacterSpritesheet } from 'spriteai'; + +async function createCharacterSprite() { + const characterSprite = await generateCharacterSpritesheet('warrior hero', { + states: ['idle', 'walk', 'run', 'attack'], + style: 'pixel-art', + framesPerState: 6 + }); + + console.log(characterSprite.metadata); +} +``` + +### Available Animation States + +Retrieve a list of available animation states: + +```javascript +import { fetchAvailableAnimationStates } from 'spriteai'; + +async function getAnimationStates() { + const states = await fetchAvailableAnimationStates(); + console.log('Available Animation States:', states); +} +``` + +### Sprite Styles + +Get a list of available sprite styles: + +```javascript +import { fetchAvailableSpriteStyles } from 'spriteai'; + +async function getSpriteStyles() { + const styles = await fetchAvailableSpriteStyles(); + console.log('Available Sprite Styles:', styles); +} +``` + +## Advanced Sprite Generation + +### Environment Sprites + +Generate environment sprites for your game: + +```javascript +import { generateEnvironmentSprites } from 'spriteai'; + +async function createEnvironmentSprites() { + const environmentSprites = await generateEnvironmentSprites('fantasy forest', { + elements: 4, + style: 'pixel-art', + theme: 'fantasy' + }); + + console.log(environmentSprites.metadata); +} +``` + +### Item Sprites + +Create game item sprites: + +```javascript +import { generateItemSprites } from 'spriteai'; + +async function createItemSprites() { + const itemSprites = await generateItemSprites('medieval weapons', { + itemCount: 4, + style: 'pixel-art', + itemType: 'equipment' + }); + + console.log(itemSprites.metadata); +} +``` + +## Best Practices + +- Always handle async operations with try/catch +- Check the metadata returned by sprite generation functions +- Use appropriate styles and state configurations for your game +- Consider saving generated sprites for reuse + +## Next Steps + +- Explore the full API documentation +- Join our community forums for tips and advanced techniques +- Experiment with different sprite generation options + +## Troubleshooting + +- Ensure you have a valid OpenAI API key +- Check your internet connection +- Verify the SDK is up to date +- Review the error messages for specific issues + +Happy sprite creation! \ No newline at end of file diff --git a/docs/getting-started.md b/docs/getting-started.md index bb03851d..8c4c08c7 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -1,7 +1,5 @@ # Getting Started with SpriteAI -Welcome to SpriteAI! This guide will walk you through the process of integrating the SpriteAI npm package into your projects. - ## Installation To begin using SpriteAI, you'll need to install it in your project directory. Simply run the following command: @@ -12,63 +10,95 @@ npm install spriteai ## Basic Usage -Once SpriteAI is installed, you can start leveraging its powerful features in your project. Here's a quick example demonstrating the main functionalities: +SpriteAI provides powerful tools for generating and manipulating game sprites. Here's a comprehensive overview of its key features: + +### Character Sprite Generation + +Create dynamic character spritesheets with ease: ```javascript const spriteAI = require('spriteai'); -// Initialise a new SpriteAI instance -const ai = new spriteAI.SpriteAI(); - -// Generate a sprite -ai.generateSprite('player', 32, 32) - .then(sprite => { - console.log('Sprite successfully generated:', sprite); - }) - .catch(error => { - console.error('Sprite generation encountered an error:', error); - }); - -// Load an existing sprite -ai.loadSprite('path/to/sprite.png') - .then(sprite => { - console.log('Sprite successfully loaded:', sprite); - }) - .catch(error => { - console.error('Sprite loading encountered an error:', error); - }); - -// Save a sprite -ai.saveSprite(sprite, 'path/to/save/sprite.png') - .then(() => { - console.log('Sprite saved successfully'); - }) - .catch(error => { - console.error('Sprite saving encountered an error:', error); - }); +// Generate a character spritesheet +await spriteAI.generateCharacterSpritesheet('hero warrior', { + states: ['idle', 'walk', 'run', 'attack'], + framesPerState: 6, + style: 'pixel-art', + save: true +}); ``` -## Key Features +### Available Animation States + +SpriteAI supports a variety of predefined animation states: + +```javascript +const animationStates = await spriteAI.fetchAvailableAnimationStates(); +// Returns: ['idle', 'walk', 'run', 'attack', 'jump', 'fall', 'hurt', 'die'] +``` + +### Sprite Styles -SpriteAI offers a range of powerful features to enhance your sprite creation and manipulation: +Choose from multiple sprite rendering styles: -1. **Sprite Generation**: Utilise `generateSprite(name, width, height)` to programmatically create new sprites. -2. **Sprite Loading**: Easily load existing sprites with `loadSprite(path)`. -3. **Sprite Saving**: Preserve your sprites using `saveSprite(sprite, path)`. +```javascript +const spriteStyles = await spriteAI.fetchAvailableSpriteStyles(); +// Returns: ['pixel-art', 'vector', '3d', 'hand-drawn', 'anime'] +``` -## Advanced Techniques +### Environment Sprite Generation -SpriteAI is capable of much more than basic sprite operations. You can create intricate sprite animations, apply various transformations, and unlock a world of creative possibilities. Dive into our comprehensive API documentation to explore the full potential of SpriteAI. +Create environment sprite tilesets for game worlds: + +```javascript +await spriteAI.generateEnvironmentSprites('fantasy forest', { + elements: 4, + style: 'pixel-art', + theme: 'fantasy' +}); +``` + +### Item Sprite Generation + +Generate item sprites for game inventories: + +```javascript +await spriteAI.generateItemSprites('magical weapons', { + itemCount: 4, + style: 'pixel-art', + itemType: 'equipment' +}); +``` + +## Advanced Features + +### Background Removal + +Remove background colors from sprites: + +```javascript +await spriteAI.removeBackgroundColor( + 'input-sprite.png', + 'output-sprite.png', + 'white', + colorThreshold +); +``` + +## Key Features -## Next Steps +1. **AI-Powered Sprite Generation**: Create unique sprites using advanced AI algorithms +2. **Multiple Animation States**: Support for various character animations +3. **Flexible Style Options**: Choose from multiple artistic styles +4. **Environment and Item Sprite Creation**: Generate complete game asset collections +5. **Background Removal**: Easy sprite background manipulation -To truly master SpriteAI, we recommend: +## Recommended Next Steps -1. Exploring the full API documentation -2. Experimenting with complex sprite animations -3. Applying different transformations to your sprites -4. Joining our community forums for tips and inspiration +1. Explore the full API documentation +2. Experiment with different sprite generation options +3. Join our community forums for tips and inspiration -For in-depth information and advanced usage scenarios, please refer to our extensive API documentation. +For in-depth information and advanced usage scenarios, please refer to our comprehensive API documentation. -Thank you for choosing SpriteAI. We're excited to see the amazing sprites you'll create with our package! +Thank you for choosing SpriteAI. We're excited to see the amazing game assets you'll create with our package!