Ren'Py Hidden Objects Game Script!
Added 2025-01-14 11:14:49 +0000 UTCHappy new year everyone! Hope your holidays have been OK wherever you are in the world. It's already 2025 hey. Let's see what this new year brings about. 😊
I've been working on this hidden object game script for everyone in the Supporter tier or higher. The artwork took the longest as I kind of wanted to make it look nicer. That's why I usually tend to avoid drawing anything too fancy as it takes longer to get a script out.
So as I said, it's a hidden object game script where you have to find hidden objects in different scenes. I have only made one proper scene, and then I made a "lazy" second scene which serves more to illustrate how to have more levels available.
The script isn't too big. It's been separated into a second .rpy file to, as usual, show how you can separate files and the game still be working.
Short explanation of the script
I'll give a short explanation of somethings in the script. Other than that, the script is commented with explanations as well.
Making levels with objects
The game works by first of all having a dictionary with all the levels of hidden object games available. So if you have 5 levels, then you'd have 5 dictionary entries/keys called "level1", "level2" etc. Each value of the entries are a list containing the names of the object to find on that level:

The names should be the same as they are in the images folder. So for example, "candy-cane.png" is the filename of the candy cane object. You'd just omit the .png in the dictionary entries.
The main game screen "hidden_objects" then loops through the dictionary to add each hidden object as an imagebutton automatically, instead of us manually writing out each one ourselves.
To make sure we loop through the list values in the dictionary, for the current level, we first make sure to pick the correct level entry in the dictionary. That is done with string interpolation where %s is replaced with whatever comes after the %.

So "level%s" % hog_level will be replaced by Ren'Py with "level1", if hog_level is equal to 1 that is.
Each image has the same size as the project, which means we don't have to manually fiddle with numbers to get them to place at correct locations.
Focus masks
Some of the items are a bit small in the first example scene, so they can be hard to click on. That is why I also implemented displayable masks that are used with the focus_mask property.
The masks are slightly larger in pixel area to make it easier to click on them:

Not all imagebuttons have the focus_mask displayables though as not all needed them.
We check with renpy.loadable() if a mask exists for a specific object:
if renpy.loadable("images/HOG game/items/level%s/%s-focus-mask.png" % (hog_level, item_name))
If the file with this path exists, then we tell Ren'Py to use an imagebutton with that focus mask. If not, then Ren'Py should use the opaque pixels of the image.
Timers and hints?
Classic hidden object games usually have timers for time bonuses and hint buttons. This is nothing I've added to this script but will make a separate extended version with these included for the Voting-tier and higher, but you can also develop something yourself if you feel up to it.
I'll update this post with information about when it's released as well.
That's all for now. You can download the script project below.
If you have questions or notice a mistake or a bug in the script, feel free to leave a comment and I'll have a look at and update the code.
I also appreciate comments letting me know if you found this script useful. 😁
Comments
Such a simple yet awesome minigame you've made!
Pytem
2025-05-16 15:34:42 +0000 UTCHope it will be useful for you! Thanks for your kind comment. Appreciate it. 😁
Sara
2025-04-24 14:41:26 +0000 UTCI was just looking up tutorials for this on YouTube, thank you so much for what you do for the Renpy community!
Melanie
2025-04-24 13:50:40 +0000 UTC