Game Types
GameShield offers a variety of game-based CAPTCHA challenges, each designed to be engaging while effectively preventing automated access.
Core Game Types
GameShield currently includes several primary game types that provide a balance of user engagement and security:
Snake
Pattern-based challenge where players collect items in sequence, testing planning and control abilities.
Breakout
Block-breaking arcade game that tests precision and strategic planning abilities while maintaining user engagement.
Dino Run
Timing-based challenge requiring precise jumps and obstacle avoidance, inspired by the popular offline browser game.
Game Selection
GameShield allows you to specify which game type to use or set it to "random" for automatic selection:
// React component with specific game type
<GameShield
gameType="snake"
size="400px"
onSuccess={handleSuccess}
/>
// Core API with random game selection
const gameShield = createGameShield({
container: document.getElementById('captcha-container'),
gameType: 'random',
size: '400px',
onSuccess: handleSuccess
});
Game Type Options
The gameType
property accepts the following values:
Value | Description |
---|---|
"snake" | Snake movement and collection game |
"breakout" | Block-breaking arcade game |
"dino-run" | Obstacle jumping game |
"random" | Randomly selects one of the available games |
Difficulty Levels
Each game can be configured with different difficulty levels to balance security and user experience:
// React component with easy difficulty
<GameShield
gameType="snake"
difficulty="easy"
size="400px"
onSuccess={handleSuccess}
/>
Difficulty Options
The difficulty
property accepts the following values:
Value | Description |
---|---|
"easy" | Lower challenge level, suitable for most users |
"medium" | Balanced difficulty (default) |
"hard" | Higher challenge level for enhanced security |
Game Behavior
All games in GameShield share common characteristics:
- 1:1 Aspect Ratio: All games maintain a perfect square aspect ratio for consistent display
- Responsive Design: Games adapt to the specified size while maintaining playability
- Touch Support: All games work with both mouse and touch input
- Behavior Analysis: User interactions during gameplay are analyzed for bot detection
- Completion Criteria: Each game has specific objectives that must be met for verification
Implementation
React Component
import React, { useState } from 'react';
import { GameShield } from '@gameshield/react';
function CaptchaForm() {
const [token, setToken] = useState(null);
return (
<div>
<GameShield
size="450px"
gameType="random"
difficulty="medium"
onSuccess={(token) => {
setToken(token);
console.log('Verification successful!');
}}
onFailure={(reason) => {
console.log('Verification failed:', reason);
}}
/>
<button disabled={!token}>Submit</button>
</div>
);
}
Core API
import { createGameShield } from '@gameshield/core';
const container = document.getElementById('captcha-container');
const gameShield = createGameShield({
container,
size: '400px',
gameType: 'breakout',
difficulty: 'medium',
onSuccess: (token) => {
console.log('Verification successful!', token);
document.getElementById('submit-button').disabled = false;
},
onFailure: (reason) => {
console.log('Verification failed:', reason);
}
});
// To destroy the instance when no longer needed
function cleanup() {
if (gameShield) {
gameShield.destroy();
}
}
Accessibility Considerations
GameShield games are designed with accessibility in mind:
- Keyboard Support: All games can be played using keyboard controls
- Color Contrast: Visual elements maintain sufficient contrast ratios
- Motion Reduction: Games respect the user's reduced motion preferences when possible
- Alternative Games: Different game types accommodate various user abilities
Future Game Types
The GameShield team is continuously developing new game types to enhance both security and user experience. Future releases will include additional games that provide even more variety and challenge types.