I have a screen where the player can put runes into different sockets. If they put those runes in the correct order, something happens.
Drag works and the pieces snaps correctly when dragged into a socket. Problem is, I can only get 1 variable working at the time. If I drag another rune to its correct socket, the first rune's variable gets back to False.
Code is a mash-up of several threads, so sorry about that. >__>
Right now, I'm trying to make it work with 2 runes.
Code: Select all
init python:
def piece_dragged(drags, drop):
global correct_position_1, correct_position_2
correct_position_1 = False
correct_position_2 = False
global rune_1, rune_2, rune_3, rune_4, rune_5
if not drop:
return
drag_name = drags[0].drag_name
drop_name = drop.drag_name
store.draggable = drag_name
store.droppable = drop_name
if drag_name == "rune_1" and (drop_name == "socle_1" or drop_name == "socle_2" or drop_name == "socle_3" or drop_name == "socle_4" or drop_name == "socle_5"):
drags[0].snap(drop.x, drop.y, delay=0.1)
elif drag_name == "rune_2" and (drop_name == "socle_1" or drop_name == "socle_2" or drop_name == "socle_3" or drop_name == "socle_4" or drop_name == "socle_5"):
drags[0].snap(drop.x, drop.y, delay=0.1)
if drag_name == "rune_1" and drop_name == "socle_1":
correct_position_1 = True
if drag_name == "rune_2" and drop_name == "socle_2":
correct_position_2 = True
if correct_position_1 and correct_position_2:
return True
Code: Select all
screen forest_chaumiere_armoire():
imagebutton: #Bouton retour
focus_mask True
xpos 20
ypos 20
idle "imagebutton_retour.png"
action Jump("ruben_chaumière_int_2")
draggroup:
drag:
drag_name "socle_1"
xpos 0.15
ypos 0.22
child "imagebuttons/socle_rune.png"
draggable False
droppable True
drag:
drag_name "socle_2"
xpos 0.29
ypos 0.22
child "imagebuttons/socle_rune.png"
draggable False
droppable True
drag:
drag_name "socle_3"
xpos 0.43
ypos 0.22
child "imagebuttons/socle_rune.png"
draggable False
droppable True
drag:
drag_name "socle_4"
xpos 0.57
ypos 0.22
child "imagebuttons/socle_rune.png"
draggable False
droppable True
drag:
drag_name "socle_5"
xpos 0.71
ypos 0.22
child "imagebuttons/socle_rune.png"
draggable False
droppable True
drag:
drag_name "rune_1"
xpos 300
ypos 400
child "imagebuttons/rune_1.png"
draggable True
droppable False
dragged piece_dragged
drag_raise True
drag:
drag_name "rune_2"
xpos 500
ypos 500
child "imagebuttons/rune_2.png"
draggable True
droppable False
dragged piece_dragged
drag_raise True