[SOLVED] Problems with displaying variable images
Posted: Mon Oct 24, 2022 1:19 pm
Hello,
I am trying to show scene images based on the current location in the game and got some issues. I found a post on these forums dealing with this but am unable to implement it correctly.
I have a dictionary with possible places:
And I have enter_place() function:
bg_code is my attempt for variable images. In the init python block are also:
What I am trying to achieve is:
This (I hope I put here all the relevant code) results in a grey screen with "places_list X" on top where X is the number of bg image. In the example above it would be 0.
It feels like I am almost there but fail to pair the bg_code with choosing the correct image. Thank you for your time.
I am trying to show scene images based on the current location in the game and got some issues. I found a post on these forums dealing with this but am unable to implement it correctly.
I have a dictionary with possible places:
Code: Select all
default current_place = {
"room_1":False,
"room_2":False,
}
Code: Select all
# enter place
def enter_place(place):
global bg_code
for x in current_place: # safeguard, leave all and any current places
current_place[x] = False
current_place[place] = True # switch to True for chosen location
bg_code = current_place.index(place)
Code: Select all
room_1 = "bg_room_1.png",
room_2 = "bg_room_2.png",
places_list = [
room_1,
room_2,
]
Code: Select all
$ enter_place("room_1")
scene places_list[bg_code] # display correct picture
It feels like I am almost there but fail to pair the bg_code with choosing the correct image. Thank you for your time.