So I'm a newbie in this community and a complete noob at Ren'py and especially Python, so I crossed a problem while trying to code a drag and drop game.
The screen looks like this (the 16 drops' area is grey for visibility purpose):
The aim of the game is simple: One has to get the jewels on the left on the correct positions using the hints provided by the grid.
The code currently looks like this:
Code: Select all
init python:
p1place1 = "false"
p1place2 = "false"
def bdragged(drags, drop):
if not drop:
return
store.butt = drags[0].drag_name
store.place = drop.drag_name
if butt == "jewel" and place == "01":
p1place1 = "true"
else:
p1place1 = "false"
if butt == "jewel" and place == "03":
p1place2 = "true"
else:
p1place2 = "false"
if p1place1 == "true" and p1place2 == "true":
return True
else:
pass
screen puzzle1:
tag menu
window:
background "Puzzle/Puzzle_01.png" xpos -16 ypos 0.0 xanchor 0.0 yanchor 0.0
draggroup:
drag:
drag_name "jewel"
child "Button/Button_Jewell.png"
droppable False
dragged bdragged
xpos 68
ypos 100
xanchor 0.5
yanchor 0.5
drag:
drag_name "jewel"
child "Button/Button_Jewell.png"
droppable False
dragged bdragged
xpos 68
ypos 160
xanchor 0.5
yanchor 0.5
# Repeated until there are 6 drags
drag:
drag_name "01"
child "Button/Empty2.png"
draggable False
xpos 348
ypos 77
xanchor 0.0
yanchor 0.0
drag:
drag_name "02"
child "Button/Empty2.png"
draggable False
xpos 299
ypos 163
xanchor 0.0
yanchor 0.0
# Repeated until there are 16 drops
While this works and get me back to the story mode:
Code: Select all
def bdragged(drags, drop):
if not drop:
return
store.butt = drags[0].drag_name
store.place = drop.drag_name
if butt == "jewel" and place == "01":
p1place1 = "true"
else:
p1place1 = "false"
if p1place1 == "true":
return True
else:
pass
What am I doing wrong? Knowing I have to make ALL six conditions "true" TOGETHER for the game to be won.
Here is a link to a zip of the game with the assets: https://www.dropbox.com/s/ic1ofiplkzitw ... 2.zip?dl=0