Hallo,
früher spielten wir das mit 21 Groschen in der Kneipe.
Es dürfen maximal 7 Groschen verschoben werden.
Dann muß die Spitze des Dreiecks nach unten zeigen.
Das Dreieck muß aber wieder komplett sein.
Code
$H Windows.ph
$H Commctrl.ph
Declare Handle bild1, icolist, btn1, btn2, text, Long x, y, ende
Declare Long xy[21, 21]
ende = 0
WindowTitle "ICON - PUZZLE"
Window 600, 480
btn1 = Create("Button", %HWnd, "NEU", 10, 10, 60, 25)
btn2 = Create("Button", %HWnd, "ENDE", 10, 50, 60, 25)
DrawText 380, 100, "Du kannst maximal 7 Icons"
DrawText 380, 120, "bewegen. Die Spitze des"
DrawText 380, 140, "Dreiecks muß dann nach"
DrawText 380, 160, "unten zeigen."
icolist = Create("ImageList", 32, 32)
WhileLoop 0, 20
ImageList("AddIcon", icolist, Create("hIcon", "A"))
EndWhile
ImageList("Add", icolist, Create("hNewPic", 32, 32, RGB(255, 255, 255)))
Spielaufbau()
WhileNot ende
WaitInput
Case %KEY = 2 : ende = 1
If Clicked(btn1)
Spielaufbau
ElseIf Clicked(btn2)
ende = 1
EndIf
WhileLoop 0, 20
If Mouse(xy[&LOOP,0], xy[&LOOP, 1] - xy[&LOOP,0] + 32, xy[&LOOP, 1] + 32)'--- Icon angeklickt?
~ImageList_BeginDrag(IcoList,0, (%MouseX - 10),(%MouseY - 10))
~ImageList_DragEnter(%HWnd, %MouseX, %MouseY)
DrawIcon icolist, 21, (xy[&LOOP,0]),(xy[&LOOP,1]) ' weißes Icon zum Verdecken
While %mousepressed '--Maustaste wird gehalten
UseCursor 5
~ImageList_DragMove(%mousex, %mousey)
Endwhile
~ImageList_EndDrag()
DrawIcon icolist, &LOOP, %MouseX - 16, %MouseY - 16
UseCursor 0
Endif
EndWhile
EndWhile
Proc Spielaufbau
RoundRect 110, 2 - 360, 380; 0, 0
x = 216
y = 13
xy[0, 0] = x : xy[0, 1] = y
DrawIcon icolist, 0, x, y
x = 200
y = 48
WhileLoop 1, 2
xy[&LOOP, 0] = x : xy[&LOOP, 1] = y
DrawIcon icolist, &LOOP, x, y
Inc x, 35
EndWhile
x = 200 - 16
y = 83
WhileLoop 3, 5
xy[&LOOP, 0] = x : xy[&LOOP, 1] = y
DrawIcon icolist, 0, x, y
Inc x, 35
EndWhile
x = 200 - 35
y = 120
WhileLoop 6, 9
xy[&LOOP, 0] = x : xy[&LOOP, 1] = y
DrawIcon icolist, 0, x, y
Inc x, 35
EndWhile
x = 200 - 51
y = 157
WhileLoop 10, 14
xy[&LOOP, 0] = x : xy[&LOOP, 1] = y
DrawIcon icolist, 0, x, y
Inc x, 35
EndWhile
x = 200 - 71
y = 194
WhileLoop 15, 20
xy[&LOOP, 0] = x : xy[&LOOP, 1] = y
DrawIcon icolist, 0, x, y
Inc x, 35
EndWhile
EndProc
DeleteObject icolist, bild1
End
Alles anzeigen
Zwei Probleme habe ich noch :
Wie bekomme ich das Icon als Cursor beim Drag&Drop an die richtige Stelle ?
Hab hier mal UseCursor verwendet.
Wie kann ich ein Icon beim Drop einrasten lassen, damit es schöner aussieht ?
Also gerade Zeile der Icons und gleicher Abstand zueinander ?
Muß dann nur noch rausfinden, wenn das Spiel gewonnen (also die Icons richtig sitzen)
ist, um eine Meldung auszugeben.