I was thinking of adding a cooking mini-game on my game.
The idea is having a kitchen as a background (kind of abvious hah), and there would be different recipes.
A background like this:
To cook these recipes you'd need 3,5 ingredients. For eg., let's say it's a sandwich. Then the ingredients would be: bread, cheese, tomato and lettuce.
There would be "tomato.png", "lettuce.png", "chocolate.png", etc. And they would be displayed like this (animated):
You would have to click the image(ingredient) you need when it shows up inside the circle frame.
Then it would go to one of the square boxes, so the person would know that one of the ingredients was already picked.
If it's not an ingredient you need, it simply would go to the box, or maybe an "X" could appear when clicked.
And then when the person have all the ingredients they win the game (kind of obvious haha).
I know how to make this in a simple way. Like a "questions and answers" game. But that wouldn't be fun at all.
I was thinking of making it animated like this.
I'm not asking anyone to make this for me
I just want to know if someone have any idea how it could work.
If the code works nice, I think it can help other people too.
Thanks.
[Solved] Does anyone know if there's a code/tutorial like this? Mini-game idea?
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
[Solved] Does anyone know if there's a code/tutorial like this? Mini-game idea?
Last edited by Nanahs on Sun Feb 10, 2019 5:05 pm, edited 1 time in total.
-
- Regular
- Posts: 111
- Joined: Fri Oct 11, 2013 12:46 am
- Contact:
Re: Does anyone know if there's a code/tutorial like this? Mini-game idea?
You can define each recipe as an object that takes a list of ingredient names. Each ingredient is then placed into a dictionary so you can track if it's been added or not:
Then each ingredient as an object:
Then write a function to try and add the ingredient, and show a screen with a red X if not:
You can then create an screen action like:
Code: Select all
class Recipe(store.object):
def __init__(self, ingredients):
self.ingredients = {i: False for i in ingredients}
def add_ingredient(self, name):
"""If an ingredient is part of the recipe, add it.
Returns:
bool: True if added, else False
"""
if self.ingredients.get(name) is not None:
self.ingredients[name] = True
return True
return False
default apple_pie = Recipe(['apples', 'flour', 'sugar'])
Code: Select all
class Ingredient(store.object):
def __init__(name, image):
self.name = name
self.image = image
default apples = Ingredient('apples', 'apples.png')
default flour = Ingredient('apples', 'flour.png')
default sugar = Ingredient('apples', 'sugar.png')
Code: Select all
def try_to_add_ingredient(recipe, ingredient):
result = recipe.add_ingredient(ingredient)
if not result:
renpy.show_screen('red_x_screen')
Code: Select all
imagebutton idle apples.image action Function(try_to_add_ingredient, apple_pie, apples.name)
Re: Does anyone know if there's a code/tutorial like this? Mini-game idea?
Thank you so much! I'll try thatHuman Bolt Diary wrote: ↑Sat Feb 09, 2019 4:37 pm You can define each recipe as an object that takes a list of ingredient names. Each ingredient is then placed into a dictionary so you can track if it's been added or not:
Then each ingredient as an object:Code: Select all
class Recipe(store.object): def __init__(self, ingredients): self.ingredients = {i: False for i in ingredients} def add_ingredient(self, name): """If an ingredient is part of the recipe, add it. Returns: bool: True if added, else False """ if self.ingredients.get(name) is not None: self.ingredients[name] = True return True return False default apple_pie = Recipe(['apples', 'flour', 'sugar'])
Then write a function to try and add the ingredient, and show a screen with a red X if not:Code: Select all
class Ingredient(store.object): def __init__(name, image): self.name = name self.image = image default apples = Ingredient('apples', 'apples.png') default flour = Ingredient('apples', 'flour.png') default sugar = Ingredient('apples', 'sugar.png')
You can then create an screen action like:Code: Select all
def try_to_add_ingredient(recipe, ingredient): result = recipe.add_ingredient(ingredient) if not result: renpy.show_screen('red_x_screen')
Code: Select all
imagebutton idle apples.image action Function(try_to_add_ingredient, apple_pie, apples.name)
Who is online
Users browsing this forum: No registered users