I'm a bit rusty since I've put off work for about a year, but what I'm working on is a fight screen where the player clicks on the button to attack, rather than using what I have now to do so.
Here is an example of what I have now :
Code: Select all
label placeholder:
while (enemy_hp > 0) and (player_hp > 0):
menu:
"Attack":
$ player_damage = renpy.random.randint(1, 6)
$ enemy_hp -= player_damage
r "You attack [enemy] for [player_damage]!"
"([enemy] has [enemy_hp] HP.)"
"Rest":
$ player_hp = min(player_hp+5, player_max_hp)
r "You recovered 5 HP."
if enemy_hp <= 0:
"[enemy] has died."
return
if enemy_hp >= 0:
$ enemy_damage = renpy.random.randint(1, 6)
if enemy_damage > 3:
$ player_hp -= enemy_damage
w "[enemy] hits you(light). *[enemy_damage]*"
if enemy_damage == 3:
$ player_hp -= enemy_damage+2
w "[enemy] hits you 2(medium). *[enemy_damage]*"
if enemy_damage < 3:
$ player_hp -= enemy_damage+5
w "[enemy]hits you 3(heavy). *[enemy_damage]*"
if enemy_hp <= 0:
"[enemy] has died."
return
else:
"[enemy] defeats you"
$ player_hp = 0
return
Code: Select all
imagebutton auto "Graphics/GUI/Attack_%.png" xpos 1230 ypos 35 focus_mask True action [ SetVariable(player_damage = renpy.random.randint(1, 6)) SetVariable(enemy_hp -= player_damage)]
What I'd like is to have the imagebutton correspond to Attack and another for Rest, but I can't figure out how to get an imagebutton to pull multiple actions in one go like I described above. I thought maybe trying to make it correspond to a variable, like
SetVariable (variable1, 1)
If variable1 = 1
label attackscript : "attack script + $ variable1 = 0"
Or something along those lines which I know I could make work but it seems really clunky and I know there has to be a more straightforward and overall competent way of going about this.
Please forgive my ignorance and help me out with what I did wrong and what I should do, or at least give me an example of the proper way of going about this if you could. I looked around and read for a bit but couldn't find anything to meet my needs.
I thought I was on top of this for a while, but I'm totally out in unknown waters right now.
Thanks in advance for any help.