Re: Drag and Drop Tutorial-ish thing
Posted: Sat Jun 22, 2013 11:44 pm
Nevermind, there is a fix on the way. Just wanted to mention that in case someone else is curious. And thanks for the reply KimiYoriBaka.
Supporting creators of visual novels and story-based games since 2003.
https://lemmasoft.renai.us/forums/
Code: Select all
python:
coorlistx = [10, 130, 250, 370]
coorlisty = [10, 217, 424]
piecelist = [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]]
for i in range(12):
x = renpy.random.randint(0, 59) + 621
y = renpy.random.randint(0, 480)
piecelist[i] = [x,y]
movedpiece = 0
movedplace = [0, 0]
Code: Select all
init python:
def piece_dragged(drags, drop):
if not drop:
store.piecelist[(int(drags[0].drag_name[0]) * 10 + int(drags[0].drag_name[1]))][0] = drags[0].x
store.piecelist[(int(drags[0].drag_name[0]) * 10 + int(drags[0].drag_name[1]))][1] = drags[0].y
return
store.movedpiece = int(drags[0].drag_name[0]) * 10 + int(drags[0].drag_name[1])
store.movedplace = [int(drop.drag_name[0]), int(drop.drag_name[1])]
return True
screen jigsaw:
draggroup:
drag:
drag_name "00"
child "empty space.png"
draggable False
xpos coorlistx[0] ypos coorlisty[0]
drag:
drag_name "01"
child "empty space.png"
draggable False
xpos coorlistx[0] ypos coorlisty[1]
drag:
drag_name "02"
child "empty space.png"
draggable False
xpos coorlistx[0] ypos coorlisty[2]
drag:
drag_name "00 piece"
child im.Crop("ShizukaClassroom_0001.jpg", 0,0, 120, 207)
droppable False
dragged piece_dragged
xpos piecelist[0][0] ypos piecelist[0][1]
drag:
drag_name "01 piece"
child im.Crop("ShizukaClassroom_0001.jpg", 120,0, 120, 207)
droppable False
dragged piece_dragged
xpos piecelist[1][0] ypos piecelist[1][1]
drag:
drag_name "02 piece"
child im.Crop("ShizukaClassroom_0001.jpg", 240,0, 120, 207)
droppable False
dragged piece_dragged
xpos piecelist[2][0] ypos piecelist[2][1]
drag:
drag_name "03 piece"
child im.Crop("ShizukaClassroom_0001.jpg", 360,0, 120, 207)
droppable False
dragged piece_dragged
xpos piecelist[3][0] ypos piecelist[3][1]
label puzzle:
call screen jigsaw
if ([coorlistx[movedplace[0]], coorlisty[movedplace[1]]] in piecelist):
python:
t1 = piecelist[movedpiece]
t2 = piecelist.index([coorlistx[movedplace[0]], coorlisty[movedplace[1]]])
piecelist[movedpiece] = [coorlistx[movedplace[0]],coorlisty[movedplace[1]]]
piecelist[t2] = t1
else:
$ piecelist[movedpiece] = [coorlistx[movedplace[0]],coorlisty[movedplace[1]]]
if piecelist == [[coorlistx[0],coorlisty[0]],
[coorlistx[0],coorlisty[1]],
[coorlistx[0],coorlisty[2]]]:
jump win
jump puzzle
label start:
scene black
#image whole = "ShizukaClassroom_0001.jpg"
image whole = "fur.png"
python:
coorlistx = [10, 130, 250,370]
#coorlistx = [10, 130, 250, 370]
coorlisty = [10, 217, 424]
#piecelist = [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]]
piecelist = [[0,0],[0,0],[0,0],[0,0]]
for i in range(4):
#for i in range(12):
x = renpy.random.randint(0, 59) + 621
y = renpy.random.randint(0, 480)
piecelist[i] = [x,y]
movedpiece = 0
movedplace = [0, 0]
jump puzzle
label win:
scene black
show whole
"you win"
menu:
"Play again?"
"yes":
jump start
"no":
return
return