Nice coincidence, I'm currently making a very similar thing xD
I currently use the choice menu for the player selections, but I don't plan to keep it that way.
The code I use also won't stay this way forever, but for all intents and purposes, it does work. I believe it's pretty much close to what you're after.
Anyway, if it's of any use to you, here's how I do things: (I've added comments to explain why I have what I have)
Code: Select all
## Self explanatory
define d = Character("Developer")
## Sets up the music to use in game
define audio.balloon = "music/Balloon Game.mp3"
## set the computer selection to nothing
default result = "none"
## set the player selection to nothing
default selection = "none"
## set player victories to zero
default score = 0
## set computer victories to zero
default computer = 0
## This is used as a developer test and will probably make its way into the final game somehow because I miss the late 90's / early 2000s and "cheats" >.>
default persistent.cheating = 0
label start:
## My game does not use saves. This line sets the "pause menu" aka the game_menu, to the about screen to avoid crashing Ren'Py.
$ _game_menu_screen = "about"
## play the music "Balloon game.mp3"
play music balloon
## an image named rps.jpg is found in the images folder. This sets it as the background.
scene rps
## This is a screen with score statistics. It can be found in the next block of code.
show screen stats
label rps_select:
## What to do if a game plays as it should
if not persistent.cheating:
menu:
## Player chooses their "selection" and computer makes a random selection
"Rock":
$selection = "rock"
$result = renpy.random.choice(['rock', 'paper', 'scissors'])
"Paper":
$selection = "paper"
$result = renpy.random.choice(['rock', 'paper', 'scissors'])
"Scissors":
$selection = "scissors"
$result = renpy.random.choice(['rock', 'paper', 'scissors'])
## Return the player to the main menu
"End":
return
## What to do if a game allows the player to never lose
else:
menu:
## ingenuity at work >.> sets the computer to a losing move no matter what the player chooses
"Rock":
$selection = "rock"
$result = "scissors"
"Paper":
$selection = "paper"
$result = "rock"
"Scissors":
$selection = "scissors"
$result = "paper"
"End":
return
## This label tests the outcomes and decides a win, loss or tie outcome.
label results:
####rock####
if result == "rock":
if selection == "rock":
jump tie
elif selection == "paper":
jump win
elif selection == "scissors":
jump lose
####paper####
elif result == "paper":
if selection == "rock":
jump lose
elif selection == "paper":
jump tie
elif selection == "scissors":
jump win
####scissors####
elif result == "scissors":
if selection == "rock":
jump win
elif selection == "paper":
jump lose
elif selection == "scissors":
jump tie
## Declare a tie and return to the selection menu
label tie:
d "We tied with [result]!"
jump rps_select
## Declare player the winner and add +1 to player score
label win:
d "[selection] beats [result], you win!"
$ score += 1
jump rps_select
## Declare Computer the winner and add +1 to computer score
label lose:
d "[result] beats [selection], you lost!"
$ computer += 1
jump rps_select
rps.rpy
Code: Select all
screen stats():
## Allow player to click through screen
modal False
## Keep screen at front of layers
zorder 100
## Position a box with some text at the middle, top of the screen.
vbox:
xalign 0.5
ypos 0.01
text "{color=#000}Computer: [computer] You: [score]{/color}"
## This is called from the main menu [c]textbutton _("Cheats") action ShowMenu("cheats")[/c]
screen cheats():
tag menu
use game_menu(_("Cheats"), scroll="viewport"):
style_prefix "cheats"
hbox:
vbox:
## An original name...
label "Never lose"
## Set cheat on or off. Player must return to this screen to adjust.
textbutton _("On") action SetField(persistent, "cheating", 1)
textbutton _("Off") action SetField(persistent, "cheating", 0)
style cheats_label is gui_label
style cheats_label_text is gui_label_text
style cheats_text is gui_text
style cheats_label_text:
size gui.label_text_size
Now, to stop a player from rolling back and selecting a different option isn't necessary, as the player cannot roll back through the menu after they're returned to the menu, but they CAN roll back as soon as they know the computer's move.
If you feel it necessary to block this entirely, perhaps consult this for further ideas.
https://www.renpy.org/doc/html/save_loa ... k_rollback
And with an example of it in use:
https://www.renpy.org/wiki/renpy/doc/re ... k_rollback
An additional link I don't quite understand, but may be of use:
https://www.renpy.org/doc/html/config.h ... out_choice
Now, I haven't got that far yet, but adding an image is as simple as adding a "show" and maybe use a transition, during the results label.
Hope this helps, good luck.