I’m working on a Ren’Py game where I want to create fights and I’m really stuck on a problem. My wish is to create a single function that will allow to start a fight by implementing the different parameters like, fight scene image, buttons etc, and the image that will return to the story. That way I will launch a fight and when it’s done, jump right back to the story.
I have tried to create a function which calls a screen “fight”. The function takes two strings in parameters (the background image of the fight AND the background to display after the fight’s end, when the history starts again).
Code: Select all
image img0 = "images/img0.jpg"
image img1 = "images/img1.jpg"
image img2 = "images/img2.jpg"
image fight = ConditionSwitch(
"fight_place == 1", "images/img1.jpg",
"fight_place == 2", "images/img2.jpg",
"True", "images/img0.jpg"
)
init python:
def start_fight(f,h):
fight_place = f
history_place = h
renpy.jump("fight")
label start:
scene img0
e "Blahblahblah"
$ start_fight(img1,img2)
In another script file:
Code: Select all
label fight:
scene fight
call screen fight_screen
screen fight_screen:
imagebutton idle "images/other_image.png" hover "images/other_image.png" xpos 500 ypos 500 focus_mask True action Jump('start')
scene history_place
I tested the choice function ATL (https://www.renpy.org/doc/html/atl.html ... -statement) also, but got the same result.
I’m trying to create a clean code for my game. Maybe I’m doing something wrong and not using the right Ren’Py or Python methods. If you have any ideas or solutions, I’m all ears!
Thank you for your help!