Drag and Drop

Hi,

I want to know if any of you has ever programmed a drag and drop
behaviour in something like card games, bacjgammon or chess…

In that case could you please tell me the way you did it and if you
have any source about this (URL, code sample…) it would be greatly
appreciated !

thanx

I want to know if any of you has ever programmed a drag and drop
behaviour in something like card games, bacjgammon or chess…

Yes, in http://www.mysterystudio.com/info.php?id=ps

init :
pDragPiece = NULL

on mouse button down :
pDragPiece = Piece under cursor (or a proxy)
Remove piece from board

on update :
if pDragPiece != NULL, draw the piece (or the proxy) under the cursor

on mouse button up :
if pDragPiece != NULL, get the board position under the cursor, try to
execute the move according to the game rules

Hi,

You should do something like this:

  • When you get a click event, check if the mouse
    if over a moveable object, say a card. Change into
    grabbing mode;

  • While in grabbing mode, when the user moves
    the mouse, update the object location to reflect the
    movement;

  • When the user releases the mouse button, return
    to normal mouse mode.

The refered normal/grabbing modes are something
that you have to keep track of.

Cheers,
Paulo

squale wrote:>Hi,

I want to know if any of you has ever programmed a drag and drop
behaviour in something like card games, bacjgammon or chess…

In that case could you please tell me the way you did it and if you
have any source about this (URL, code sample…) it would be greatly
appreciated !

thanx


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Another example is at http://drac.sf.net/

It’s a solitaire game, and card game programming framework.On Sep 29, 2004, at 10:54 AM, squale wrote:

Hi,

I want to know if any of you has ever programmed a drag and drop
behaviour in something like card games, bacjgammon or chess…

In that case could you please tell me the way you did it and if you
have any source about this (URL, code sample…) it would be greatly
appreciated !

thanx


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi there

i was wondering, it there was some simple SDL-like trick to get DnD
(Drag and Drop) running, so i can drop some file-links fron
konqueror/MS-Explorer/etc. into my SDL-app??

thanks for any hint in advance
benjamin


visit the worlds most furious open-source 3D-action game
http://www.orxonox.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iQIVAwUBQ5EAd63dUaw0Ln2OAQKh9BAAu/m880v+K4FzhAgTITwNxHDL+0psT4nc
1cptI1yROVjyvVDWuKYAFpyXS3O16nPYV4fpd2DhuW9t66WCo3wCGaA4DEirFoCo
D/VGWDGhRWpIUJGMJxIFFnQ//2gCzP0r3z5N2SymNZ0lPrSYLP/16MfYAxrs3pjr
X3aXbtDwMlY40a1cOd0PZs/2YVbhZ/HXyjIF7aH2JDq6UIgfhIBIi2llBSm1xQYP
M79BgWgVDq6Cs2pr7/m3VwCdTrEYcM30dH7bLxGvbLFo23D7PYY7Kb/w2WGaTTZ3
NBvKEdz+AKVDOrelqcVdT/7nL2WZp8zH2dtXWoZhu6jnpX+JUwAidHzI1MVmRMcU
yksgiDCbJ4v8zZjjFUuG6k/19UJ17bzOg/1VIXhJQGUhji2WMLh3PvK0HYJfoYWC
DTSINTWpiALOGL2RN07+2amYkl+8U3Ib9lqelfGAzq5fRlhSBx7s1y03eDy3Mvtc
98oz0GU7EXZA38yle94jWPc4pnZAUlchvV42WuixvD+kCxgNzgRxvO31PW92iz3q
4fDfadnP+nnlzagOu5Mq092molxblb6DeWzTdeK3iCbKicNymhJ6cJ684d6ucxnp
v7FOa3MZqJc2H5w6IiyJ8rmXE2Xub3Ul9fMxKOZ4c8gyv9f0IOFCDPVBvl5V8jCq
aS9dQQ+X/4k=
=bhsQ
-----END PGP SIGNATURE-----

Benjamin Grauer wrote:

Hi there

i was wondering, it there was some simple SDL-like trick to get DnD
(Drag and Drop) running, so i can drop some file-links fron
konqueror/MS-Explorer/etc. into my SDL-app??

Maybe this can help you ?

http://www.libsdl.org/projects/scrap/