r/HTML • u/Annais24 • 15d ago
Question [JavaScript/HTML] Unboxing simulator: Dual image display issue & daily forced wins
https://unboxingtimecraciun.neocities.org/please note that I am a beginner at this and I don't know much about coding
Hi! I'm building a Christmas unboxing web app for my boyfriend, featuring a skin-case style spinning wheel. I'm running into two main issues:
- Dual Images & Display: I want the wheel to show a 'mystery/boxed' version of each item (e.g.,
canax.png), and then reveal the actual item image (e.g.,cana.png) in the win popup modal when it lands. However, when I try to implement this, the images on the wheel disappear. (Note: All my image files and the HTML file are in the same root folder, no subfolders). What am I doing wrong? - Forced Daily Outcomes: I want to be able to hardcode or easily change a variable every day so the wheel always lands on a specific item (e.g., day 1 is a mug, day 2 is a hoodie, etc.), allowing me to manually update just the item for that specific day. How can I structure my code to easily configure daily forced wins?
3
Upvotes
1
u/thejester1324 15d ago
I can't see the wheel code, so I can't say for sure why the images vanish. Two checks first:
For the daily item, keep the schedule in one list at the top and pick from it by day:
Pick the winner first, then animate the wheel so it stops on that slice. Don't spin it and check the result afterward.
If the images still fail after the console check, paste the wheel code here.
1
u/f13th 13d ago
I'd represent each prize as one object containing an
id,mysteryImageandrevealImage, rather than keeping two separate image arrays that can get out of sync. The wheel drawsmysteryImage; once a prize is selected, the popup usesrevealImagefrom that same object.For forced daily wins, keep a simple date-to-prize-ID lookup and decide the winner before animating the wheel, so the wheel actually stops on the right item.
Also check whether you're drawing images onto a canvas before they've loaded. That can make the images disappear even when the filenames are correct.