Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- init python:
- import random
- # Define drink recipes (with ingredient quantities)
- drink_recipes = {
- "Lemon Drop": ["bottle" + "lemon"],
- "Mojito": ["bottle" + "lime"],
- "Gin and Tonic": ["bottle" + "lime"],
- "Tequila Sunrise": ["bottle" + "lemon"],
- "Margarita": ["bottle" + "lime"]
- }
- # Initialize variables
- bottle = 0
- lemon = 0
- lime = 0
- cup_full = 0
- selected_drink = random.choice(list(drink_recipes.keys())) # Randomly pick a drink
- # Function to check if the drink is correct (only correct ingredients)
- def is_good_drink():
- ingredients = drink_recipes[selected_drink]
- # Check if all ingredients in the cup are part of the selected drink
- if bottle == ingredients.count("bottle") and lemon == ingredients.count("lemon") and lime == ingredients.count("lime"):
- return True
- return False
- # Store last dropped item
- def on_drop(drags, drop):
- global bottle, lemon, lime, cup_full
- if drop == "cup":
- if drags.drag_name == "bottle":
- bottle += 1
- elif drags.drag_name == "lemon":
- lemon += 1
- elif drags.drag_name == "lime":
- lime += 1
- cup_full = bottle + lemon + lime
- # Check if the cup is full and if the drink is complete
- if cup_full >= 2: # A drink is considered complete with 2 ingredients
- if is_good_drink():
- return "Here's your drink! Enjoy!"
- else:
- return "This isn't right. Try again."
- label drink_minigame:
- scene bg bar
- with dissolve
- # Reset variables
- $ bottle = 0
- $ lemon = 0
- $ lime = 0
- $ cupFull = 0
- $ last_drag = None
- # Show the screen and enter loop
- show screen drink_screen
- label drink_loop:
- # Wait for a drop event
- $ renpy.pause(0.1)
- # When the cup is full → evaluate drink
- if cupFull >= 2:
- hide screen drink_screen
- jump evaluate_drink
- jump drink_loop
- label evaluate_drink:
- # Check if the drink is good (correct ingredients and quantities)
- if is_good_drink():
- scene bg bar
- show expression "minigame/cup.png"
- "Wow! This is delicious!"
- return
- else:
- scene bg bar
- show expression "minigame/cup2.png"
- "Uh-oh! You added an incorrect ingredient or the quantities aren't right. Try again."
- # Reset all variables and jump back to drink minigame
- $ bottle = 0
- $ lemon = 0
- $ lime = 0
- $ cupFull = 0
- jump drink_minigame
- screen drink_screen():
- add "minigame/bg bar.png"
- # Instructions
- text "Drop ingredients into the cup!" style "outlined_text" pos (475, 15)
- text "Bottle: [bottle]" style "outlined_text" pos (1600, 600)
- text "Lemon: [lemon]" style "outlined_text" pos (1600, 650)
- text "Lime: [lime]" style "outlined_text" pos (1600, 700)
- draggroup:
- # Cup is the drop target
- drag:
- drag_name "cup"
- droppable True
- draggable False
- xalign 0.5
- yalign 0.7
- child "minigame/cup.png"
- # Bottle
- drag:
- drag_name "bottle"
- draggable True
- droppable False
- xalign 0.2
- yalign 0.1
- frame:
- xysize (432, 432)
- idle_background "minigame/bottle1.png"
- hover_background "minigame/bottle2.png"
- selected_hover_background "minigame/bottle4.png"
- dragged on_drop
- # Lemon
- drag:
- drag_name "lemon"
- draggable True
- droppable False
- xalign 0.35
- yalign 0.1
- frame:
- xysize (200, 200)
- idle_background "minigame/lemon1.png"
- hover_background im.Scale("minigame/lemon1.png", 220, 220)
- selected_hover_background "minigame/lemon2.png"
- dragged on_drop
- # Lime
- drag:
- drag_name "lime"
- draggable True
- droppable False
- xalign 0.5
- yalign 0.1
- frame:
- xysize (200, 200)
- idle_background "minigame/lime1.png"
- hover_background im.Scale("minigame/lime1.png", 220, 220)
- selected_hover_background "minigame/lime2.png"
- dragged on_drop
- return
Advertisement
Add Comment
Please, Sign In to add comment