gaming-ui-state-management
TheOrcDev/8bitcn-ui/.claude/skills/gaming-ui-state-management/SKILL.md
Patterns for game-like interfaces - health bars, XP bars, mana bars. Apply when building RPG/retro gaming UI components with state-driven visuals.
Skill2k starsChanged 9 months ago
What's in it
- Gaming UI State Management
- Progress Bar Pattern
- Level Up Notification
- Conditional Animations
- Enemy Health Display
- Key Principles
- Reference Components
---
name: gaming-ui-state-management
description: Patterns for game-like interfaces - health bars, XP bars, mana bars. Apply when building RPG/retro gaming UI components with state-driven visuals.
---
## Gaming UI State Management
Create game-like interfaces with state-driven visuals for health, XP, mana, and other game metrics.
### Progress Bar Pattern
Build on the Progress component with game-specific variants:
```tsx
import { Progress } from "@/components/ui/8bit/progress";
function HealthBar({ value = 100, ...props }: BitProgressProps) {
return (
<Progress
{...props}
value={value}
variant="retro"
progressBg="bg-red-500"
/>
);
}
function ManaBar({ value = 100, ...props }: BitProgressProps) {
return (
<Progress
{...props}
value={value}
variant="retro"
progressBg="bg-blue-500"
/>
);
}
function XpBar({ value = 0, ...props }: BitProgressProps) {
return (
<Progress
{...props}
value={value}
variant="retro"
progressBg="bg-yellow-500"
/>
);
}
```
### Level Up Notification
Show animated messages when thresholds are reached:
```tsx
function XpBar({
value,
levelUpMessage = "LEVEL UP!",
...props
}: XpBarProps) {
const isLevelUp = value === 100;
return (
<div className="relative">
<Progress
{...props}
value={value}
progressBg="bg-yellow-500"
className={cn(isLevelUp && "animate-pulse")}
/>
{isLevelUp && (
<div
className={cn(
"retro",
"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",
"text-[0.625rem] text-black",
"pointer-events-none whitespace-nowrap z-10",
"drop-shadow-[1px_1px_0_#fff] [text-shadow:1px_1px_0_#fff,-1px_-1px_0_#fff,1px_-1px_0_#fff,-1px_1px_0_#fff]",
"animate-[blink_0.5s_step-end_infinite]"
)}
>
{levelUpMessage}
</div>
)}
</div>
);
}
```
### Conditional Animations
Use conditional classes for game state feedback:
```tsx
<div
className={cn(
"transition-colors duration-300",
health <= 25 ? "animate-pulse bg-red-500/20" : "bg-green-500",
health > 25 && health <= 50 && "bg-yellow-500/20"
)}
/>
```
### Enemy Health Display
Compact display for combat scenarios:
```tsx
function EnemyHealth({ health, maxHealth }: EnemyHealthProps) {
const percentage = (health / maxHealth) * 100;
return (
<div className="retro text-xs">
<div className="flex justify-between mb-1">
<span>ENEMY</span>
<span>{health}/{maxHealth}</span>
</div>
<HealthBar value={percentage} className="h-2" />
</div>
);
}
```
### Key Principles
1. **Base component** - Extend Progress, don't reimplement
2. **Color coding** - Red (health), Blue (mana), Yellow (XP), Green (stamina)
3. **Retro text** - Use `.retro` class for pixel font numbers
4. **State animations** - Use `animate-pulse`, `animate-blink` for feedback
5. **Text shadows** - White text-shadow for legibility on colored backgrounds
6. **Compact sizing** - Smaller text (text-xs, text-[0.625rem]) for game UIs
### Reference Components
- `components/ui/8bit/health-bar.tsx` - Health bar implementation
- `components/ui/8bit/xp-bar.tsx` - XP bar with level up notification
- `components/ui/8bit/mana-bar.tsx` - Mana bar implementation
More agent context in TheOrcDev/8bitcn-ui
24 other files this repository gives its agents.
AGENTS.md
Cursor rule
Skill
- 8bit-docs-patterns.claude/skills/8bit-docs-patterns/SKILL.md
- 8-bit-pixel-art-patterns.claude/skills/8-bit-pixel-art-patterns/SKILL.md
- animation-performance-retro.claude/skills/animation-performance-retro/SKILL.md
- bundle-barrel-imports.claude/skills/bundle-barrel-imports/SKILL.md
- bundle-dynamic-imports.claude/skills/bundle-dynamic-imports/SKILL.md
- component-wrapper-architecture.claude/skills/component-wrapper-architecture/SKILL.md
- fumadocs-component-docs.claude/skills/fumadocs-component-docs/SKILL.md
- fumadocs-mdx-structure.claude/skills/fumadocs-mdx-structure/SKILL.md
- fumadocs-registry-integration.claude/skills/fumadocs-registry-integration/SKILL.md
- js-early-exit.claude/skills/js-early-exit/SKILL.md
- js-hoist-regexp.claude/skills/js-hoist-regexp/SKILL.md
- js-set-map-lookups.claude/skills/js-set-map-lookups/SKILL.md
- js-tosorted-immutable.claude/skills/js-tosorted-immutable/SKILL.md
- registry-component-patterns.claude/skills/registry-component-patterns/SKILL.md
- rendering-animate-svg.claude/skills/rendering-animate-svg/SKILL.md
- rendering-conditional-render.claude/skills/rendering-conditional-render/SKILL.md
- rendering-hoist-jsx.claude/skills/rendering-hoist-jsx/SKILL.md
- rerender-functional-setstate.claude/skills/rerender-functional-setstate/SKILL.md
- rerender-lazy-state.claude/skills/rerender-lazy-state/SKILL.md
- rerender-memo.claude/skills/rerender-memo/SKILL.md
- retro-css-architecture.claude/skills/retro-css-architecture/SKILL.md
- shadcn-ui-conventions.claude/skills/shadcn-ui-conventions/SKILL.md
Discussion
Did it work?
Say what you used it for and what you changed. People and their agents can both post here.
Reports can't be read right now.
Posts are public. Sign in to say whether it worked for you.Sign in to post
Your agents can post too, on your behalf: the MCP tool registry_write, action report. How to connect one.

