Autor: Heinz Brill (---.dip0.t-ipconnect.de)
Datum: 27.03.21 10:17
Hallo, ich habe mal ein kleines Spiel gemacht, das wir früher in der Kneipe
mit 21 Groschen spielten :
Ziel ist es, daß die Spitze des Dreiecks nach unten statt nach oben zeigt.
Dabei dürfen nur maximal 7 Groschen bewegt werden.
$H Windows.ph
$H Commctrl.ph
Declare Handle 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", "GESICHT")) ' Das dient als Groschen
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, xy[&LOOP,0] - 10, xy[&LOOP, 1] - 10)
~ImageList_DragEnter(%HWnd, %MouseX, %MouseY)
DrawIcon icolist, 21, (xy[&LOOP,0]),(xy[&LOOP,1]) ' weißes Icon zum Verdecken
'~SetCursorPos(%MouseX, %MouseY)
While %mousepressed '--Maustaste wird gehalten
UseCursor 5
~ImageList_DragMove(%mousex, %mousey)
Endwhile
~ImageList_EndDrag()
DrawIcon icolist, &LOOP, %MouseX - 16, %MouseY - 16
UseCursor 0
Case Between(%MouseX, %MouseY, 340, 194, 372, 229) : MessageBox("Bravo", "Info", 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
End
Damit es nun schön aussieht, hätte ich gerne, daß das gedropte Icon
auch schön neben den anderen einrastet. Da hätte ich die Icons
wieder im gleichen Abstand zu den anderen. So 'Free Hand' klappt das
so ja nicht immer korrekt.
Auch sollte das gedragte Icon unter dem Cursor erscheinen. Im Moment
habe ich da ein 4fach-Kreuz mit UseIcon genommen.
Gibt es da auch eine Möglichkeit, das gedragte Icon zu moven ?
Ich behelfe mir damit, ein weißes Icon an die gedragte Stelle
drüber zu klatschen.
Als weiteres muß ich mir eine Strategie überlegen, wie ich ermitteln
kann, wann die Aufgabe gelöst ist. Mit Between() scheint das nicht zu
funktionieren.
Hat da jemand Vorschläge für mich.
H.Brill
XProfan X4 + FreeProfan
Nachricht bearbeitet (27.03.21 10:18)
|
|