This or That Game with Smooth Fade Transitions and Local Storage Voting
This tutorial shows how to build a This or That voting game using AI coding tools. The idea comes from App Ideas (Florin Pop) which presents the concept of a game where users pick between two images. We'll use the full prompt provided on this page to generate the entire codebase in one go. By following these steps, you'll learn how to integrate modern UI design, responsive layout, and local storage for persistent voting stats.
The process uses AI tools such as ChatGPT, Claude, Gemini, Cursor, Lovable, and v0. These platforms can interpret complex instructions and output clean HTML, CSS, and JavaScript in a single file. You'll end up with a fully functional browser-based game that works on mobile and desktop. We’ll cover running it locally, testing all features, debugging, and deploying it for free.
What you need
- A modern web browser
- Access to an AI coding assistant (e.g., ChatGPT, Claude, Cursor)
- A text editor or IDE for viewing code
- Basic understanding of HTML, CSS, and JavaScript
- Internet access to load images from public APIs
- Optional: GitHub account for deployment
The full prompt
Build ImageBattle - A This or That Voting Game
Build a complete browser-based voting game using HTML5 Canvas and vanilla JavaScript in a single index.html file. The game presents users with two random images to choose from, tracks their selections, and displays voting results.
- Users see two large, centered images with clear voting buttons
- Players select their favorite image by clicking "This" or "That" buttons
- Smooth fade animations transition between image pairs when voting
- Images load dynamically from public APIs (unsplash, pixabay, or similar)
- Vote tracking persists in browser's localStorage for session-based statistics
- Leaderboard displays top 10 most voted images with vote counts
- Responsive design works on mobile, tablet, and desktop screens
- Clean modern UI with card-based layout and subtle shadows
- Color scheme: Deep blue primary (#2563eb), white background, gray accents (#6b7280)
- Typography: Sans-serif fonts with clear hierarchy (24px main headings, 16px body text)
- Keyboard navigation support (arrow keys for voting)
- Accessibility features including ARIA labels and screen reader support
- Auto-refresh mechanism to load new image pairs after voting
- Visual feedback on button hover and click states
- Progress indicator showing voting history
The game flow starts with two random images displayed side-by-side. Players select their preferred image, triggering a smooth fade animation to the next pair. All votes are stored locally and displayed in a leaderboard section. The interface uses a clean card-based design with consistent spacing and responsive layout.
Output should be a single index.html file containing all HTML, CSS, and JavaScript. Run by simply opening the file in any modern browser. No build tools or external dependencies required.1Choose an AI Tool and Paste the Prompt
Open your preferred AI coding tool such as ChatGPT, Claude, or Cursor. Paste the full prompt exactly as it appears on this page under "The full prompt". This prompt tells the AI to generate a complete voting game with two images, buttons for selection, smooth animations, leaderboard, and persistent storage.
Ensure that you select an AI tool that supports generating HTML/CSS/JS in one file. The output should be ready to run without any build process. Tools like Lovable and v0 are also compatible with such tasks.
Wait for the AI to return a full index.html file, which will include all required code. If the AI returns partial or incorrect output, proceed to Step 3.

Pro tip: Use the exact prompt text; AI works best when given clear, structured instructions.
2Save and Run the Generated Code Locally
Once you receive the HTML file from your AI tool, save it as index.html on your computer. Open this file directly in a modern browser like Chrome, Firefox, or Edge. The game should load with two images side-by-side and voting buttons.
Check that the layout is centered, responsive, and visually appealing. You may need to tweak font sizes or spacing depending on how the AI interpreted the prompt. For example, if the text is too small or buttons don’t respond, you can adjust styles manually in the CSS section.
If everything works as expected, proceed to Step 4 to test all core features.
Pro tip: Always test locally before deployment; it helps catch rendering or logic errors early.
3Test Core Game Features
Click the 'This' and 'That' buttons to verify that voting works correctly. Each click should trigger a smooth fade animation between image pairs.
Check that:
- Images load dynamically from public APIs (Unsplash or Pixabay)
- Vote statistics are tracked in localStorage
- The leaderboard updates with each vote
- Keyboard navigation (arrow keys) functions properly
- ARIA labels and screen reader support are present
Verify that the game automatically loads new image pairs after voting. If one of these features fails, you’ll need to refine your prompt or debug the output.

Pro tip: Test both mouse clicks and keyboard inputs to ensure full accessibility.
4Fix Any Bugs Using Follow-Up Prompts
If certain features don't work as expected, try refining your prompt. For instance, if the leaderboard isn’t updating, ask the AI to modify the JavaScript logic for saving votes.
You can use prompts like:
Fix the leaderboard so it shows top 10 voted images after each vote.
Or:
Add smooth fade animation when transitioning between image pairs.
Repeat this process until all features behave as intended. The AI will iteratively improve its output based on your corrections.
Pro tip: Be specific with your follow-up prompts to get precise fixes.
5Optimize Performance and Add Enhancements
Optimize the game's performance by:
- Reducing unnecessary DOM elements
- Ensuring lazy loading of images
- Adding visual feedback for hover and click states
You can enhance the UI with subtle shadows, transitions, and responsive breakpoints. For example, add media queries to adjust font sizes on smaller screens.
If you want to improve responsiveness further, ask the AI to:
Make sure the game layout is fully responsive across mobile, tablet, and desktop.
Also, ensure that animations are performant using transform and opacity instead of moving elements directly.
Pro tip: Use CSS transitions for animation performance over JavaScript-based solutions.
6Validate Accessibility and Keyboard Support
Ensure the game meets accessibility standards by checking:
- All buttons have ARIA labels
- Screen readers can navigate easily through controls
- Keyboard navigation works (arrow keys or enter)
- Color contrast passes WCAG guidelines
Test the game using browser developer tools or screen reader extensions. If needed, update the HTML and CSS to make sure all interactive elements are properly labeled.
Ask the AI to enhance accessibility if necessary:
Add proper ARIA roles and attributes for buttons and sections.
Also verify that focus states are visible during keyboard navigation.
Pro tip: Always test with screen readers or assistive devices to ensure usability.
7Deploy Your Game for Free
Deploy your game using free hosting platforms like GitHub Pages, Netlify, or Vercel.
For GitHub:
- Create a new repository
- Upload
index.htmland any assets - Enable GitHub Pages in Settings
- Share the public URL
For Netlify/Vercel:
- Drag and drop your folder
- Let them auto-deploy
- Get a live link immediately
These platforms are ideal for small games like this one because they don’t require build tools or complex configurations.
Pro tip: GitHub Pages is the easiest way to host static web apps for free.
8Share and Iterate Based on Feedback
Once live, share your game with friends or on social media. Collect feedback on UI, performance, and gameplay.
Use this input to refine the prompt and generate updated versions. You might want to add:
- Sound effects for voting
- User avatars or names
- Social sharing buttons
The beauty of using AI tools is that you can quickly iterate and experiment with new features. Each round of improvement brings you closer to a polished final product.
Pro tip: User feedback is invaluable for improving game mechanics and design.
Adapt it to your own brand
- Change the image category (dogs, cats, cars) by modifying API endpoints in the JavaScript
- Adjust the color scheme to match your brand or theme using CSS variables
- Modify typography choices to align with a specific font stack for branding consistency
- Add more interactive elements like comments or ratings next to images
- Integrate social media sharing buttons for easy game distribution
- Support custom image uploads instead of relying solely on public APIs
- Include multiplayer functionality or leaderboards across multiple users
Common mistakes and fixes
- Forgetting to use localStorage for persistent vote tracking, this breaks the game's core logic
- Not handling API errors when fetching images, leads to broken displays
- Ignoring responsive design, causes layout issues on mobile devices
- Overcomplicating animations, can slow down performance on low-end machines
- Missing ARIA labels, reduces accessibility and fails WCAG compliance
- Using outdated CSS syntax or JavaScript methods that don’t work in all browsers
Frequently asked questions
Can I use this game for commercial purposes?
Yes, as long as you comply with the image source licenses. Since images are fetched from public APIs, make sure to follow their terms.
Does the game work offline?
No, it requires internet access to load images from APIs. However, voting stats persist using localStorage.
What browser versions does this support?
Modern browsers like Chrome, Firefox, Safari, and Edge are fully supported. Legacy IE is not supported.
How do I change the image categories?
Modify the API endpoint URLs in JavaScript to fetch from different sources like animals, cars, or landscapes.
Final thoughts
This tutorial demonstrated how to build a This or That voting game using AI tools. By following each step and leveraging the full prompt from Prompt Grabber, you’ve created an interactive browser-based game that works on all devices.
Try copying the prompt above and running it in your preferred AI coding assistant. You’ll quickly see how powerful these tools are for rapid prototyping and development.