Forum Academy Marketplace Showcase Pricing Features

Simple guessing game: Location of pixels (x,y) within Image?

I am making a game where a random pixel in a 100 x 100 image will be the winning pixel.
The user would click on the image and if the pixel is the winning pixel, they get a prize.

Is there a way with Bubble to get the location of the user’s mouse within the image when they clicked (i.e. can I have an event that returns the pixel within the image that the user clicked)?

rather new to Bubble, so any help appreciated!

You could definitely do this with custom JavaScript that then [auto-fills an input field || generates a string || whatever method you prefer to store the x-y coords] After this you tell Bubble to read the coords in a workflow which checks if the coords match. The one downside I see is someone programatically clicking every pixel and cheating the system. Maybe you can check user IP address and add a time buffer between clicks…?

1 Like

This might help you get started:

https://www.kirupa.com/html5/getting_mouse_click_position.htm

I’m sure there are better resources but you’ll have to do some Googling :slight_smile:

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.