Documentation
Boofer SDK Docs
Everything you need to build, integrate, and publish HTML5 games on the Boofer platform. The SDK is a single JavaScript file that bridges your game with the native Boofer app.
Include the SDK
<script src="https://booferapp.github.io/bgames/assets/sdk/boofer-sdk.js"></script>Add this inside your game's <head> tag.
AI Copilot Prompt Generator
Don't want to write the SDK code yourself? Fill in your game details to generate a customized prompt. Copy and paste it into your favorite AI developer agent (like Claude, Cursor, or Antigravity) to build a fully integrated HTML5 game.
Generated System Prompt
You are an expert HTML5 game developer. I want you to build a single-file or structure-complete HTML5 game for me.
Here are the details of the game I want to build:
- **Game Title**: [Specify Game Title, e.g., Flappy Bird]
- **Tech Stack**: HTML5 Canvas & JavaScript
- **Game Concept & Vision**: [Describe your game idea and how it should play]
### Critical Requirement: Boofer SDK Integration
You MUST integrate the Boofer SDK into this game. Follow these guidelines exactly to ensure the game works properly inside the Boofer platform.
1. **Include the CDN Script**:
Add this inside the game's `<head>` tag:
```html
<script src="https://booferapp.github.io/bgames/assets/sdk/boofer-sdk.js"></script>
```
2. **Configure SEO, API Key & Dev Environment**:
Include these tags in the `<head>`:
```html
<title>[Specify Game Title, e.g., Flappy Bird]</title>
<meta name="description" content="[Specify Game Short Description for SEO]">
<meta name="boofer-api-key" content="YOUR_API_KEY">
<!-- Environment tag (for development, must be removed before production) -->
<meta name="boofer-env" content="development">
```
3. **CSS Styling (Tailwind or Custom)**:
- Please include Tailwind CSS via CDN in the `<head>` for styling: `<script src="https://cdn.tailwindcss.com"></script>`
- Alternatively, write clean, minimalistic custom CSS. Make the UI modern, responsive, and polished.
4. **SDK Initialization & Safe Fallback**:
Initialize communication with the parent shell immediately upon game startup. Implement a fallback for testing outside the Boofer shell.
```javascript
let playerContext = null;
let isBooferActive = false;
(async () => {
try {
// Wait for native bridge (timeout defaults to 6s)
await Boofer.ready(6000);
// Initialize game session and extract context
const config = await Boofer.initGame({
gameId: 'your_game_id',
gameVersion: '1.0.0'
});
playerContext = config.player;
isBooferActive = true;
console.log("Welcome back,", playerContext.displayName);
// Start game loop with actual player details
startGame(playerContext);
} catch (err) {
console.warn("Running outside Boofer shell:", err.message);
// Fallback context for local browser testing / development
playerContext = {
userId: 'guest_user_123',
displayName: 'Guest Player',
avatarUrl: 'https://placehold.co/150',
level: 1,
highScore: 0
};
startGame(playerContext);
}
})();
```
4. **Required Game UI - Profile Button**:
- The game UI MUST have a clearly visible "Profile" button.
- When clicked, this button must call `await Boofer.getPlayerInfo(true)` (to fetch the latest level/high score details) and display the player details (avatarUrl, displayName, level, highScore) in a styled overlay or modal.
- The game loop and audio should be paused while the profile overlay/modal is open, and resumed when closed.
5. **Lifecycle Event Listeners**:
Subscribe to application state notifications from the host shell:
```javascript
Boofer.onAppEvent('pause', () => {
// Pause game loop, sounds, and active gameplay
});
Boofer.onAppEvent('resume', () => {
// Resume game loop, sounds, and active gameplay
});
```
6. **Monetization (Rewarded Videos)**:
Add support for rewarded video ads. For example, if the player loses their lives, you can offer them a rewarded ad:
```javascript
// Listen to rewarded events
Boofer.onRewardEarned(({ type, amount }) => {
if (type === 'extra_life') {
playerLives += amount;
resumeGame();
}
});
```
7. **Scores, High Scores & Leaderboards**:
- Save scores when completing levels or matching new milestones:
```javascript
await Boofer.saveScore(currentScore);
```
- When the game is over (Game Over):
- Trigger haptic error feedback: `await Boofer.triggerHaptic('error');`
- Submit final score and trigger native post-match leaderboard display:
```javascript
await Boofer.gameOver(finalScore, { reason: 'lives_depleted' });
```
- In the main menu / game over screen, add buttons to:
- View leaderboard: `Boofer.showLeaderboard();`
- Share score: `await Boofer.shareScore(finalScore, "I just scored " + finalScore + "!");`
8. **Gameplay Haptic Feedback & Telemetry**:
- Trigger haptic feedback for key interactions:
- Small actions (jumping, shooting, collection): `await Boofer.triggerHaptic('light');` or `'medium'`
- Milestone/Success (level complete, high score): `await Boofer.triggerHaptic('success');`
- Track custom telemetry events:
```javascript
await Boofer.trackEvent('level_failed', { level: currentLevel, finalScore: currentScore });
```
9. **Achievements, Inventory & Backend (If applicable)**:
- Fetch achievements: `await Boofer.getAchievements();`
- Unlock achievement: `await Boofer.unlockAchievement('achievement_id', 100);`
- Consume inventory item: `await Boofer.consumeItem('item_id', 1);`
- For backend verification, get the Xaor token: `const { token } = await Boofer.getSessionToken();`
Please design the game to be modern, responsive, and completely functional within a single HTML/JS bundle.
Quick Start
Get up and running in 5 minutes.
SDK Reference
Complete API reference for the Boofer SDK.
Player Profiles
Fetch and display player data.
Monetization
Integrate ads and earn revenue.
Xaor Encryption
Secure game save data with Xaor.
Publishing
Submit and manage your games.
FAQ
Common questions and answers.