Build a scratch card with scratch-to-reveal animation, prize reveal, and satisfying scratch effect.
Assistant
I'll build a scratch card with an interactive scratch-to-reveal animation. Let me first explore the project structure and then create the implementation.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Let me install a confetti library for the prize reveal celebration effect:
Now I'll create the scratch card component with the scratch-to-reveal animation and satisfying effects:
Let me fix the syntax error in the ScratchCard component:
Let me fix the component properly - the function needs to be inside useEffect to have access to ctx:
Let me create a proper type declaration file and fix the component:
Now let me update the App.tsx to use the ScratchCard component:
Now let me update the title in index.html:
Now let me build the project to verify it works:
The build succeeded. Let me clean up the unnecessary type declaration file:
The scratch card game has been built successfully. Let me verify the final implementation:
Let me install the type definitions for canvas-confetti:
The build succeeded. Let me verify the final App.tsx file:
I see there's still a missing quote on line 20. Let me fix that:
The scratch card game has been built successfully. Let me verify the final files:
The build is successful. Let me verify the final output by reading the built HTML:
The scratch card game has been built successfully. Here's a summary of what was created:
Scratch Card Game - Features
src/ScratchCard.tsx
Interactive canvas-based scratch effect using destination-out composite operation for smooth erasing
6 different prizes with colorful gradient backgrounds (gift cards, cash, gaming, headphones, Tesla, etc.)
Scratch progress tracking with a visual progress bar that changes color (gray → yellow → green)
Confetti celebration when 60% of the card is revealed
Touch support for mobile devices
Smooth scratch animation with round line caps and joins
src/App.tsx
Game states: idle (start screen), playing (scratch card), completed (prize revealed)
Win counter to track total prizes won
Start button with gradient styling and hover effects
Play again button after winning
Helpful hint on how to play
index.html
Updated title to "Scratch & Win - Scratch Card Game"
The build completed successfully with all assets inlined into a single HTML file (271KB). Users can click/tap and drag across the scratch card to reveal their randomly assigned prize!