How to change an Image variable in the middle of label?
Posted: Sun May 02, 2021 1:39 am
Hello, i'm trying to create a game where an image is shown first on the screen, then the player has to select the arrow keys to change the image colour that is assigned for each arrow keys. But I don't know how to declare the image variable. I somehow made i work yesterday but now, I'ts not working. And the circle image is Red colour from the start instead of being yellow. I would be very thankful if you could tell me the various methods to declare an image (like 'default', $ , 'image') and whey my circle is red colour from the get go. And also the colour of the circle is not changing when I click the arrow keys. What am I doing wrong?
This is my script code:
This is my screen code:
This is what the game shows(the circle is red colour instead of yellow)
Then the screen is shown
The colour should have changed here(the colour should have been yellow from the start but even if it was red, it should have changed into blue if I had clicked the up arrow but it didn't)
This is my script code:
Code: Select all
# The script of the game goes in this file.
# Declare characters used by this game. The color argument colorizes the
# name of the character.
define e = Character("Eileen")
default Red = False
default Blue = False
image arrow_down = "down_arrow.png"
image arrow_up = "up_arrow.png"
image circle = "yellow_circle"
# The game starts here.
label start:
# Show a background. This uses a placeholder by default, but you can
# add a file (named either "bg room.png" or "bg room.jpg") to the
# images directory to show it.
scene bg room
# This shows a character sprite. A placeholder is used, but you can
# replace it by adding a file named "eileen happy.png" to the images
# directory.
show eileen happy
# These display lines of dialogue.
e "You've created a new Ren'Py game."
e "Once you add a story, pictures, and music, you can release it to the world!"
hide eileen
show circle at truecenter
"This is to test the key statement"
"choose"
window hide
show screen keyscreen
show screen arrowscreen
pause
if Blue == True:
image circle = "blue_circle"
elif Red == True:
image circle = "red_circle"
window show
"The game ends"
pause
# This ends the game.
return
Code: Select all
screen keyscreen():
key "K_UP" action (SetVariable("Blue", True), Hide('keyscreen'), Hide('arrowscreen'))
key "K_DOWN" action (SetVariable("Red", True), Hide('keyscreen'), Hide('arrowscreen'))
screen arrowscreen():
vbox:
xalign 0.8
yalign 0.5
spacing 50
imagebutton idle "up_arrow" action NullAction()
imagebutton idle "down_arrow" action NullAction()
Then the screen is shown
The colour should have changed here(the colour should have been yellow from the start but even if it was red, it should have changed into blue if I had clicked the up arrow but it didn't)