- Apr 15, 2017
- 35
- 22
I'm using a match-3 minigame as a key component to my renpy game and I've gotten it to work in the 2 generic instances I need it to so far but since I'm new to renpy and making games in general I'm not sure how to go about this next part...
The idea is that the mc will compete against a number of different npcs and it seems pointless to repeat the game code for every round or every character so I figure there has to be a way that I can call the game when necessary and then set certain variables, or when I want to call a label mid game that may change per character per game how do I get back to the game? But since I don't know renpy I don't know what to look up to find how to do it.
Here is the game code I'm using:
What I'm trying to figure out is 3 things...
First after specific rounds I want t b able to call a label which will have some dialogue and images but then as soon as its over it returns to the game. But can I do that without resetting the game?
Second, just like the above issue, I want to be able to call various menus based on the game... depending on who you challenge you may have different options so rather then making 3 or 4 menus live inside the game it seemed like it'd make more sense to have it call them as needed. But again, if I do that and then tell it to return will it reset or break the minigame?
Lastly and this really should be easy but I don't see why its not working. Certain options will also add or subtract to the time limit. In this case it startes at 25s and if an option is select from the menu it is supposed to add 2s but it doesn't.
I think the last part would be the ending options that will change based on the above (who was playing, what the stats were, etc) but I'm assuming I could just control that with something like:
The idea is that the mc will compete against a number of different npcs and it seems pointless to repeat the game code for every round or every character so I figure there has to be a way that I can call the game when necessary and then set certain variables, or when I want to call a label mid game that may change per character per game how do I get back to the game? But since I don't know renpy I don't know what to look up to find how to do it.
Here is the game code I'm using:
Python:
label Game:
$ GameCount += 1
screen memo_scr:
##### Timer
timer 1.0 action If (memo_timer > 1, SetVariable("memo_timer", memo_timer - 1), Jump("memo_game_lose") ) repeat True
text str(memo_timer) xalign 0.5 yalign 0.0
text str(loss) xalign 0.25 yalign 0.0
text str(win) xalign 0.75 yalign 0.0
grid 3 5 xalign 0.5 yalign 0.23:
for card in cards_list:
button:
background None
if card["c_chosen"]:
add card["c_value"]
else:
add "C"
action If ( (card["c_chosen"] or not can_click), None, [SetDict(cards_list[card["c_number"]], "c_chosen", True), Return(card["c_number"]) ] )
init:
python:
def cards_shuffle(x):
renpy.random.shuffle(x)
return x
##### Images
image A = "img_1.png"
image B = "img_2.png"
image D = "img_3.png"
image C = "back.png"
default gameSet = 0
default gameMCWin = 0
default powerplay = False
$ gameSet = 0
$ gameMCWin = 0
label memoria_game:
scene black
default win = 0
default loss = 0
default winImg = 1
default lossImg = 1
default powerdom = "x"
default competitor = "npc1"
image img_competition = "wall-[competitor]-[winImg]-[powerdom].png"
image img_mc = "wall-mc1-[lossImg].png"
show img_competition at left
show img_mc at right
$ values_list = ["A", "A", "A", "A", "A", "A", "B", "B", "B", "B", "B", "B", "D", "D", "D"]
$ values_list = cards_shuffle(values_list)
$ cards_list = []
python:
for i in range (0, len(values_list) ):
cards_list.append ( {"c_number":i, "c_value": values_list[i], "c_chosen":False} )
$ memo_timer = 25.0
show screen memo_scr
label memo_game_loop:
$ can_click = True
$ turned_cards_numbers = []
$ turned_cards_values = []
$ turns_left = 3
label turns_loop:
if turns_left > 0:
$ result = ui.interact()
$ memo_timer = memo_timer
$ turned_cards_numbers.append (cards_list[result]["c_number"])
$ turned_cards_values.append (cards_list[result]["c_value"])
$ turns_left -= 1
jump turns_loop
$ can_click = False
if turned_cards_values.count(turned_cards_values[0]) != len(turned_cards_values):
$ renpy.pause (0.5, hard = True)
python:
for i in range (0, len(turned_cards_numbers) ):
cards_list[turned_cards_numbers[i]]["c_chosen"] = False
else:
$ renpy.pause (0.5, hard = True)
python:
for i in range (0, len(turned_cards_numbers) ):
cards_list[turned_cards_numbers[i]]["c_value"] = Null()
for j in cards_list:
if j["c_chosen"] == False:
renpy.jump ("memo_game_loop")
renpy.jump ("memo_game_win")
jump memo_game_loop
label memo_game_lose:
hide screen memo_scr
$ renpy.pause (0.1, hard = True)
$ renpy.pause (0.1, hard = True)
"You lose!"
$ gameSet += 1
$ loss += 1
$ lossImg += 1
if loss >= 4:
$ loss == 3
if lossImg >= 4:
$ lossImg = 3
if loss == 2:
if GameCount <= 1:
$ lossImg = 2
jump mulligan
elif GameCount >= 2:
jump memoria_game
if gameSet <= 4:
if loss == 3:
jump matchEnd_loss
elif loss <= 2:
jump memoria_game
elif gameSet == 5:
if $ loss == 3:
jump matchEnd_loss
elif loss <= 2:
jump matchEnd_win
label memo_game_win:
hide screen memo_scr
$ renpy.pause (0.1, hard = True)
$ renpy.pause (0.1, hard = True)
"You win!"
$ gameSet += 1
$ win += 1
$ winImg += 1
if win >= 4:
$ win == 3
if winImg >= 5:
$ winImg = 4
if gameSet == 2:
if win == 2:
# jump to specific cut scene
"There is dialogue that will go here"
#I want to be able to call the menu below without it having to live WITHIN the game code itself
label options-menu:
menu:
"Select Option":
menu:
"option1":
$ variable
"option2":
$ variable
"..."
$ memo_timer += 2.0
$ option = True
$ winImg += 1
"No":
jump memoria_game
if gameSet <= 4:
if win == 3:
jump matchEnd_win
elif win <= 2:
jump memoria_game
elif gameSet == 5:
if win == 3:
jump matchEnd_win
elif loss <= 2:
jump matchEnd_loss
First after specific rounds I want t b able to call a label which will have some dialogue and images but then as soon as its over it returns to the game. But can I do that without resetting the game?
Code:
if gameSet == 2:
if win == 2:
# jump to specific cut scene
"There is dialogue that will go here"
# jump back to this point in the game
...
Code:
if gameSet == 2:
if win == 2:
label options-menu:
menu:
"Select Option":
menu:
"option1":
$ variable
"option2":
$ variable
"..."
$ memo_timer += 2.0
$ option = True
$ winImg += 1
"No":
jump memoria_game
Code:
$ memo_timer += 2.0
Code:
jump matchEnd_win[npc]
Last edited: