I’m making a game about serving food to customers, and there’s a light puzzle mechanic involved with serving the right foods. I’d like for the player to be able to drag a food icon to either dish drag(droppable), and for the program to wait for both dishes to be full, at which point the player can click a button to accept the choice. Only when the button is clicked would I want the data of which food went into which dish to be stored, and for the game to proceed. I’d also like for players to be able to pick the food icons back up off the plates, if the button hasn’t been clicked yet. In case they want to change their minds. I'd use the variables of which food was in which dish to determine future plot and whatnot.
Currently, my code doesn’t want to wait, and moves on when any food is dropped into any dish. I’m only able to make the code store the names of one dish and one food. I’ve tried looking at the card game examples, and I also tried to start from scratch and implement something using this very cool-looking coding instead. It has a wonderful snapping-back function, and would not proceed, but I lost some hovering functionality in my drags, and couldn't figure out where any drag variables were being stored.
So here’s my current code for the serving mechanic:
Code: Select all
#####################################################################
# Orig Attempt ####
#####################################################################
scene tmeal with fade
init python:
def fud_dragged(drags, drop):
if not drop:
return
store.fud = drags[0].drag_name
store.plate = drop.drag_name
store.fud2 = drags[0].drag_name
store.plate2 = drop.drag_name
#if
return True
screen tsend_fud_screen:
add "tmeal.png"
draggroup:
############## FOODS ###############
drag:
drag_name "Steak"
child "steak.png"
droppable False
dragged fud_dragged
hovered Show("thap")
unhovered Hide("thap")
alt "A delicious, rare steak."
xpos 800 ypos 200
drag:
drag_name "Salad"
child "salad.png"
droppable False
dragged fud_dragged
hovered Show("tmad")
unhovered Hide("tmad")
alt "A leafy green salad."
xpos 1000 ypos 280
############# DISHES ####################
drag:
drag_name "Dish1"
child "dish.png"
draggable False
xpos 203 ypos 285
drag:
drag_name "Dish2"
child "dish.png"
draggable False
xpos 603 ypos 385
##### This is a little frown face that shows up on top of a character's face when the salad is hovered over.
screen tmad:
add "mad.png" xpos 9 ypos 255
#### This is a little happy face that shows up on top of a character's face when the steak is hovered over.
screen thap:
add "happy.png" xpos 9 ypos 280
#### This is a placeholder for a textbox to pop up and show a description of food when the food is hovered over. Currently doesn't show.
screen des:
add "descriptionbox.png" xpos 9 ypos 900
label tsend_fud:
"Drag and drop the food from your imagination to the serving dish!"
### Display Proceed button
$ proceed = "true"
call screen tsend_fud_screen
label check_fud:
#### Blah blah blah game continues below ###And here’s my current code for the button to proceed. I’ve got it crammed into the quick menu:
Code: Select all
hbox:
style_prefix "quick"
xalign 0.9
yalign .9
if proceed == "true":
imagebutton:
idle "sw1.png"
hover "sw2.png"
insensitive "swg.png"
#### I'm trying to gray out the button if both dishes are not filled. I was thinking about just making it check both dish variables, and if both are still the default, the button won't work.
sensitive "store.fud" != "drags[0].drag_name"
action Confirm("Serve this food?", yes=Call("check_fud"), no=None, confirm_selected=False)
alt "Proceed?"