npm package: @jonsoku2/game-sdk
Description: Canvas-based 2D game development SDK with AI integration
Author: GameFlow Platform Team
Latest version: 1.0.0

# @jonsoku2/game-sdk

Canvas-based 2D game development SDK with AI integration for creating browser games.

## Features

- 🎮 **Canvas 2D Rendering** - High-performance game rendering engine
- 🤖 **AI Integration** - AI-powered game generation and templates
- 📱 **Mobile Optimized** - Touch controls and responsive design
- 🎯 **Game Templates** - Pre-built templates for Action, Puzzle, Casual, and Strategy games
- ⚡ **TypeScript Support** - Full type safety and IntelliSense
- 🔄 **Lifecycle Management** - Complete game state management

## Installation

### NPM

```bash
npm install @jonsoku2/game-sdk
```

### CDN

```html
<!-- jsDelivr (recommended) -->
<script src="https://cdn.jsdelivr.net/npm/@jonsoku2/game-sdk@latest/index.mjs" type="module"></script>

<!-- unpkg -->
<script src="https://unpkg.com/@jonsoku2/game-sdk@latest/index.mjs" type="module"></script>
```

## Quick Start

### Basic Usage

```typescript
import { GameSDK, ActionGame } from '@jonsoku2/game-sdk';

// Create canvas element
const canvas = document.createElement('canvas');
canvas.width = 800;
canvas.height = 600;
document.body.appendChild(canvas);

// Initialize GameSDK
const gameSDK = new GameSDK(canvas);

// Create and start a game
const gameConfig = {
  category: 'action',
  name: 'My Action Game',
  world: { width: 800, height: 600, gravity: 0.5 },
  player: { x: 100, y: 500, speed: 5, jumpForce: 12 }
};

const game = new ActionGame(gameConfig);
await game.initialize();
gameSDK.start();
```

### Using with HTML

```html
<!DOCTYPE html>
<html>
<head>
    <title>My Game</title>
</head>
<body>
    <canvas id="game-canvas" width="800" height="600"></canvas>
    
    <script type="module">
        import { GameSDK, ActionGame } from 'https://cdn.jsdelivr.net/npm/@jonsoku2/game-sdk@latest/index.mjs';
        
        const canvas = document.getElementById('game-canvas');
        const gameSDK = new GameSDK(canvas);
        
        const gameConfig = {
            category: 'action',
            name: 'Browser Game',
            world: { width: 800, height: 600 },
            player: { x: 100, y: 500, speed: 5 }
        };
        
        const game = new ActionGame(gameConfig);
        game.initialize().then(() => {
            gameSDK.start();
        });
    </script>
</body>
</html>
```

## Game Templates

### Action Games
```typescript
import { ActionGame } from '@jonsoku2/game-sdk';

const config = {
  category: 'action',
  name: 'Platformer Game',
  world: { width: 800, height: 600, gravity: 0.5, friction: 0.85 },
  player: { x: 100, y: 500, width: 32, height: 32, speed: 5, jumpForce: 12 },
  enemies: [{ type: 'walker', speed: 2, health: 50 }],
  weapons: [{ type: 'bullet', damage: 25, speed: 8 }]
};
```

### Puzzle Games
```typescript
import { PuzzleGame } from '@jonsoku2/game-sdk';

const config = {
  category: 'puzzle',
  name: 'Match-3 Game',
  grid: { width: 8, height: 8, cellSize: 40 },
  pieces: { colors: ['#ff0000', '#00ff00', '#0000ff'], minMatchLength: 3 },
  gameRules: { targetScore: 1000, timeLimit: 180 }
};
```

## API Reference

### GameSDK

Main SDK class for managing the game lifecycle.

```typescript
class GameSDK {
  constructor(canvas: HTMLCanvasElement)
  start(): void
  pause(): void
  resume(): void
  stop(): void
  getRenderer(): Canvas2DRenderer
}
```

### Game Templates

- `ActionGame` - Platform, shooter, and action games
- `PuzzleGame` - Match-3, tetris, and puzzle games  
- `CasualGame` - Clicker, collector, and casual games
- `StrategyGame` - Turn-based and strategy games

## AI Integration

The SDK includes AI-powered game generation capabilities:

```typescript
import { GameSDKGenerator } from '@jonsoku2/game-sdk';

const generator = new GameSDKGenerator({
  model: yourLangChainModel,
  includeBundledSDK: false,
  optimizeForMobile: true
});

const gameResponse = await generator.generateGame({
  category: 'action',
  prompt: 'Create a space shooter game',
  difficulty: 'medium',
  graphics: 'retro'
});
```

## Browser Support

- ✅ Chrome 90+
- ✅ Firefox 88+
- ✅ Safari 14+
- ✅ Edge 90+

## Performance

- **Bundle Size**: ~170KB (39KB gzipped)
- **Target FPS**: 60 FPS
- **Mobile Optimized**: Touch controls and responsive canvas

## Contributing

This SDK is part of the GameFlow Platform. For contributions, please see the [main repository](https://github.com/gameflow-platform/gameflow-platform).

## License

MIT License - see [LICENSE](LICENSE) file for details.

## Links

- [Documentation](https://docs.gameflow.dev/game-sdk)
- [Examples](https://examples.gameflow.dev)
- [GitHub Repository](https://github.com/gameflow-platform/gameflow-platform)
- [NPM Package](https://www.npmjs.com/package/@jonsoku2/game-sdk)