This is my first RenPy excursion (as the designer), and I'm stuck. I can make 90% of the game no problem, but there's a minigame that I just can't make happen. I've spent all day today trying different approaches. Here's what I need to have happen:
I provide a list of items. The game randomizes that list, and shares it with the user. Sometimes this list is 5 items long. Sometimes it's 10 or 20. This part is going OK.
The user is going to try to remember and re-create the list. So I want to give them a bank of 20 options across the bottom of the screen. When they click on one, it appears across the top. With each new click, an item is added to the list above. When they are satisfied that they have laid the items in the proper sequence, they can "submit" and the game will compare the two.
I'm feeling good about generating the random list from a pool. I'm feeling good about comparing the two. But for the life of me, I cannot get the interface for the interactivity working. I've been trying to use 2 hbox screens, one with textbuttons (will upgrade to imagebuttons after I get this working in even a rudimentary fashion) and to somehow register the clicks by showing them in the hbox at the top...that's where it falls apart.
Any guidance would be most appreciated. I've tried so many approaches it's not worth recounting them.
New to RenPy, can't make matching game work. Help!?
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.
-
twinkletoesCT
- Newbie
- Posts: 1
- Joined: Sat Apr 14, 2018 10:06 pm
- Contact:
- Qlara
- Regular
- Posts: 80
- Joined: Fri Nov 28, 2014 10:22 am
- Completed: Carmilla
- Skype: kantonija
- itch: visualgothic
- Location: Berlin
- Contact:
Re: New to RenPy, can't make matching game work. Help!?
It would be helpful to see your code or a screenshot.
As a stab in the dark, however, I would use 2 separate screens (instead of two hboxes on one screen).
If I understand correctly, the bottom doesn't change, as it's the pool with all items.
The top screen starts with empty fields/boxes (sized like the items) that get filled one after another, so you'll need a counter that keeps track of which field gets filled next.
Field one and counter c is 1.
Now user clicks item "b3" in the list below. That click should cause "b3" to appear in slot c (=1 at the moment) in the screen above, by setting field(1) = b3 and increment c (c = c+1), so the next item goes to slot 2.
Those are just some rough ideas, as I'm not sure I understood your problem.
As a stab in the dark, however, I would use 2 separate screens (instead of two hboxes on one screen).
If I understand correctly, the bottom doesn't change, as it's the pool with all items.
The top screen starts with empty fields/boxes (sized like the items) that get filled one after another, so you'll need a counter that keeps track of which field gets filled next.
Field one and counter c is 1.
Now user clicks item "b3" in the list below. That click should cause "b3" to appear in slot c (=1 at the moment) in the screen above, by setting field(1) = b3 and increment c (c = c+1), so the next item goes to slot 2.
Those are just some rough ideas, as I'm not sure I understood your problem.
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: New to RenPy, can't make matching game work. Help!?
I’d say show code (inside code tags) rather than a screen shot, so we don’t have to retype everything if we want to create a project to fix your code.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
Re: New to RenPy, can't make matching game work. Help!?
Do you mean something like this?
Code: Select all
screen match_game_scr():
vbox:
align (0.5, 0.6)
hbox:
align (0.5,0.0)
for i in items_list:
textbutton i action If(can_click, Function(my_add_func, i), [[]])
null width 10
textbutton "remove" action If(can_click, Function(my_remove_func), [[]])
textbutton "Done" action If(can_click, Return(players_sequence), [[]]) align (0.5, 1.0)
hbox:
align (0.5, 0.25)
for i in players_sequence:
textbutton i action [[]]
textbutton "hint" action If(can_click, If(not renpy.get_screen("show_sequence"), Show("show_sequence"), Hide("show_sequence")), [[]]) align (0.95,0.05)
screen show_sequence():
hbox:
align (0.5,0.5)
spacing 10
for i in sequence:
textbutton i action [[]]
init python:
def my_add_func(x):
global players_sequence
players_sequence.append(x)
def my_remove_func():
global players_sequence
players_sequence = players_sequence[:-1]
# The game starts here.
label start:
scene black
"..."
call match_game
"That's all."
return
label match_game(j=3, i=["a", "b", "c", "d", "e", "f", "g"]):
$ items_list = i
$ sequence_length = j
$ sequence = []
python:
for i in range(sequence_length):
sequence.append(renpy.random.choice(items_list))
$ players_sequence = []
$ can_click = False
show screen match_game_scr
show screen show_sequence
"Remember this..."
hide screen show_sequence
label loop:
$ can_click = True
$ res = ui.interact()
$ can_click = False
if res == sequence:
jump win
else:
"Wrong!"
$ players_sequence = []
jump loop
label win:
"You win!"
hide screen match_game_scr
"..."
returnWho is online
Users browsing this forum: Google [Bot]
