This tutorial assumes you know the basics of programming in Ren'py and the basics of creating an image.
1. Start a new project
2. Add the hidden object code + the empty_* images to the game directory (can be found in the zip file attached to this post)
3. Create your image pack (Or just use mine )
Create images in your favorite image editor using layers: background, objects, foreground
Save as transparent png!
- image_ground.png - base image with all objects
- image_hover.png - just the hidden objects and anything over them
- image_insensitive - base image with the objects how they look when found
- image_sensitive_idle - just the hidden objects in hint mode
- image_empty - not needed, but nice to have as a background
4. Put the following code in script.rpy
Code: Select all
image bg locker = "locker_empty.png"
init python:
locker_items = []
##
# The game starts here.
label start:
$ start = renpy.time.time()
# this sets all the items back to not found
$ resetItems(locker_items)
# which image set to use
$ hidden_files = "locker_%s.png"
# randomize the list and pick 5 items
$ hidden_items = renpy.random.sample(locker_items,0)
# set number of hints
$ num_hints = 3
# set number of extra clicks
$ num_clicks = 0
scene bg locker
"Get ready to find the items!"
$ showitems = True
call screen hidden_object
scene bg locker
$ elapsed = round(renpy.time.time() - start)
"Result: [_return] in [elapsed] seconds with [num_clicks] extra clicks!"
5. And launch it!
WHOA! What a boring game.
We are just running it to get at a useful tool in Renpy: The Developer menu!
6. Hit Shift+D to bring up the Developer menu
7. Click on Image Location Picker
8. Choose your hover image to get the pixel locations of your objects
9. Highlight the area around the object
The coordinates appear in the lower left of the screen
10. Now you have the laborous task of adding your items to the code using format:
locker_items.append(Item("Item Name", x,y,width,height))
For each item using the numbers given in the picker in the same order.
Now the init block should look like this:
Code: Select all
init python:
locker_items = []
locker_items.append(Item("teddy", 362,325,95,103))
locker_items.append(Item("pen", 193,396,100,36))
locker_items.append(Item("bookmark", 240,454,56,101))
locker_items.append(Item("crackers",189,112,167,63))
locker_items.append(Item("mirror",528,73,91,129))
locker_items.append(Item("photo",515,296,98,99))
locker_items.append(Item("pencil case",380,153,109,134))
locker_items.append(Item("book",346,0,80,83))
locker_items.append(Item("card",648,159,83,61))
locker_items.append(Item("flower",295,238,43,48))
$ hidden_items = renpy.random.sample(locker_items,5)
12. Launch!
You now have a basic hidden object game
Susan
EDIT: Duplicate line in code