Hidden Object Code
Posted: Sun Jul 24, 2011 5:33 pm
After an afternoon of hitting my head against the computer screen (And listening to Repo! the Genetic Opera) I made some code for a basic Hidden Object screen.
I would write more about this but I am rather tired of the code right now.
Basics:
woods_ground = is the background image
woods_idle = the objects in their normal state
woods_hover = what happens when you hover over an object
OPTIONAL
woods_insensitive = what happens when an object is found. If you leave this out, the objects disappear when found.
Next steps:
Make the code more generic so you can pass a list of objects
Any suggestions welcome!
EDIT:
Adding distributions if you want to play the LAMEST hidden object game ever:
http://www.thecatsweb.com/games/Hidden% ... st-all.zip (18 MB)
http://www.thecatsweb.com/games/Hidden% ... -win32.zip (8 MB)
Susan
Code: Select all
init python:
showitems = True
def display_items_overlay():
if showitems:
inventory_show = "Items to Find: "
items = hidelist.keys()
for i in range(0, len(items)):
inventory_prefix = ""
inventory_suffix = ""
item_name = items[i]
item_state = hidelist[items[i]]
if i > 0:
inventory_show += ", "
if item_state == 'Found':
inventory_prefix = "{s}"
inventory_suffix = "{/s}"
inventory_show += inventory_prefix+item_name+inventory_suffix
ui.frame()
ui.text(inventory_show)
config.overlay_functions.append(display_items_overlay)
def is_all_found():
newitem = hidelist.keys()
for i in range(0, len(newitem)):
if hidelist[newitem[i]] == 'Not found':
return False
return True
##
# The game starts here.
label start:
$ hidelist = {'tshirt': 'Not found', 'girl': 'Not found'}
call screen hidden_object
"Result: %(_return)s!"
return
screen hidden_object:
tag hidden
imagemap:
auto "woods_%s.png"
hotspot (530, 400, 90, 110) action If(hidelist['girl']=='Not found', SetDict(hidelist,'girl','Found'), None)
hotspot (90, 70, 250, 270) action If(hidelist['tshirt']=='Not found', SetDict(hidelist,'tshirt','Found'), None)
hotspot (175, 475, 250, 70) action If(is_all_found(), Return("All Found!"), None)
Basics:
woods_ground = is the background image
woods_idle = the objects in their normal state
woods_hover = what happens when you hover over an object
OPTIONAL
woods_insensitive = what happens when an object is found. If you leave this out, the objects disappear when found.
Next steps:
Make the code more generic so you can pass a list of objects
Any suggestions welcome!
EDIT:
Adding distributions if you want to play the LAMEST hidden object game ever:
http://www.thecatsweb.com/games/Hidden% ... st-all.zip (18 MB)
http://www.thecatsweb.com/games/Hidden% ... -win32.zip (8 MB)
Susan