Re: Building a Board Game

2020-04-10 Thread Roger Guay via use-livecode
Thank you, Quentin. I’ll give it a try.

Roger

> On Apr 10, 2020, at 4:03 PM, Quentin Long via use-livecode 
>  wrote:
> 
> On 7.04.20 22:24, Roger Guay via use-livecode wrote:
>> Hi all,
>> 
>> I know there must be a simple way to do this but it is escaping me at the 
>> moment. How can I move an object (grab me on mouseDown) and have it snap to 
>> a grid (square on a board game) on mouseUp?
> There are any number of ways to do this thing. Try giving this script to the 
> object you want to move:
> local DisX, DisYlocal GridSize = 20-- if grid uses different sizes for X and 
> Y, make GridSizeX and GridSizeYlocal OriginGridX = 10local OriginGridY = 10
> on mouseDown  send "TrackDaMouse" to meend mouseDown
> on TrackDaMouse  put the mouseLoc into Fred  put GridSize * ((item 1 of Fred 
> - OriginGridX) div GridSize) + OriginGridX into DisX  put GridSize * ((item 2 
> of Fred - OriginGridY) div GridSize) + OriginGridY into DisY  set the loc of 
> me to Fred  if the mouse is down thensend "TrackDaMouse" to me in 20 msec 
>  elsemove me to (DisX, DisY) in .5 seconds  end ifend TrackDaMouse
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Building a Board Game

2020-04-10 Thread Quentin Long via use-livecode
On 7.04.20 22:24, Roger Guay via use-livecode wrote:
> Hi all,
>
> I know there must be a simple way to do this but it is escaping me at the 
> moment. How can I move an object (grab me on mouseDown) and have it snap to a 
> grid (square on a board game) on mouseUp?
There are any number of ways to do this thing. Try giving this script to the 
object you want to move:
local DisX, DisYlocal GridSize = 20-- if grid uses different sizes for X and Y, 
make GridSizeX and GridSizeYlocal OriginGridX = 10local OriginGridY = 10
on mouseDown  send "TrackDaMouse" to meend mouseDown
on TrackDaMouse  put the mouseLoc into Fred  put GridSize * ((item 1 of Fred - 
OriginGridX) div GridSize) + OriginGridX into DisX  put GridSize * ((item 2 of 
Fred - OriginGridY) div GridSize) + OriginGridY into DisY  set the loc of me to 
Fred  if the mouse is down then    send "TrackDaMouse" to me in 20 msec  else   
 move me to (DisX, DisY) in .5 seconds  end ifend TrackDaMouse
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Building a Board Game

2020-04-08 Thread Bob Sneidar via use-livecode
If you decide on that method, check out dragImageOffset. 

Bob S


> On Apr 8, 2020, at 7:22 AM, Roger Guay via use-livecode 
>  wrote:
> 
> I like it! Thanks!!
> 
> Roger
> 
> 


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Building a Board Game

2020-04-08 Thread Roger Guay via use-livecode
I like it! Thanks!!

Roger

> On Apr 8, 2020, at 7:10 AM, Bob Sneidar via use-livecode 
>  wrote:
> 
> I was also thinking that hiding the object and using the dragImage might be 
> better, because if a the player drops a piece on an illegal position, you 
> could simply cancel the drag operation and show the original object. 
> 
> Bob S
> 
> 
>> On Apr 7, 2020, at 12:36 PM, Bob Sneidar  wrote:
>> 
>> Just brainstorming, you would have to intercept mouseMove and then have a 
>> tolerance of points to your grid. Say three points. Assuming your grid 
>> starts at the top left of the window, you would div the top of the object 
>> with the vertical grid width, check for tolerance above and below, then set 
>> the object’s top to the nearest gridline. You will also need to set the 
>> mouseLoc by the same amount, or else capture the mouseLoc on mouseDown, 
>> record the distance from the top left of the object, then after setting the 
>> top left of the object, opined the mouseLoc to the object again. Do the same 
>> with left, and also with bottom and right if need be. 
>> 
>> Bob S
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Building a Board Game

2020-04-08 Thread Bob Sneidar via use-livecode
I was also thinking that hiding the object and using the dragImage might be 
better, because if a the player drops a piece on an illegal position, you could 
simply cancel the drag operation and show the original object. 

Bob S


> On Apr 7, 2020, at 12:36 PM, Bob Sneidar  wrote:
> 
> Just brainstorming, you would have to intercept mouseMove and then have a 
> tolerance of points to your grid. Say three points. Assuming your grid starts 
> at the top left of the window, you would div the top of the object with the 
> vertical grid width, check for tolerance above and below, then set the 
> object’s top to the nearest gridline. You will also need to set the mouseLoc 
> by the same amount, or else capture the mouseLoc on mouseDown, record the 
> distance from the top left of the object, then after setting the top left of 
> the object, opined the mouseLoc to the object again. Do the same with left, 
> and also with bottom and right if need be. 
> 
> Bob S

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Building a Board Game

2020-04-08 Thread Richmond via use-livecode

That could be a hexagon instead of a square.

On 7.04.20 22:24, Roger Guay via use-livecode wrote:

Hi all,

I know there must be a simple way to do this but it is escaping me at the 
moment. How can I move an object (grab me on mouseDown) and have it snap to a 
grid (square on a board game) on mouseUp?

Thanks much,

Roger
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Building a Board Game

2020-04-08 Thread Richmond via use-livecode

Um . . . http://forums.livecode.com/viewtopic.php?f=7=33886

Rough morning!

Best, Richmond.

On 7.04.20 22:24, Roger Guay via use-livecode wrote:

Hi all,

I know there must be a simple way to do this but it is escaping me at the 
moment. How can I move an object (grab me on mouseDown) and have it snap to a 
grid (square on a board game) on mouseUp?

Thanks much,

Roger
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Building a Board Game

2020-04-07 Thread Roger Guay via use-livecode
Thanks to Tore, Bob and Devin for your suggestions. You have pushed back my 
frontiers of ignorance!

Cheers,
Roger

> On Apr 7, 2020, at 12:24 PM, Roger Guay via use-livecode 
>  wrote:
> 
> Hi all, 
> 
> I know there must be a simple way to do this but it is escaping me at the 
> moment. How can I move an object (grab me on mouseDown) and have it snap to a 
> grid (square on a board game) on mouseUp?
> 
> Thanks much,
> 
> Roger
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Building a Board Game

2020-04-07 Thread Devin Asay via use-livecode
Roger,

Rather than moving an object, think about using button icons.  This is the 
basic process:

- on mouseDown: check the icon of the target, set the icon of a hidden, moving 
button to the same icon, set the icon of the target to 0, set a 
flag—isDragging--to true, show the hidden button

- on mouseMove: if isDragging is true, set the loc of the moving button to the 
mouseLoc

- on mouseUp: figure out which square you’re over, set the icon of that button 
to the icon of the moving button, hide moving button, set isDragging to false.

I made a rudimentary chess game that uses this technique, check it out here:

http://dight310.byu.edu/lesson_materials/07-arrays/chessGame-final-key.livecode

Click the Clear Board and Setup Game buttons first to set up the game board 
array. Game state handlers are in the card script; game piece moving handlers 
are in the game board group script.

Hope this helps.

Devin


On Apr 7, 2020, at 1:24 PM, Roger Guay via use-livecode 
mailto:use-livecode@lists.runrev.com>> wrote:

Hi all,

I know there must be a simple way to do this but it is escaping me at the 
moment. How can I move an object (grab me on mouseDown) and have it snap to a 
grid (square on a board game) on mouseUp?

Thanks much,

Roger
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Devin Asay
Director
Office of Digital Humanities
Brigham Young University

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Building a Board Game

2020-04-07 Thread Bob Sneidar via use-livecode
Just brainstorming, you would have to intercept mouseMove and then have a 
tolerance of points to your grid. Say three points. Assuming your grid starts 
at the top left of the window, you would div the top of the object with the 
vertical grid width, check for tolerance above and below, then set the object’s 
top to the nearest gridline. You will also need to set the mouseLoc by the same 
amount, or else capture the mouseLoc on mouseDown, record the distance from the 
top left of the object, then after setting the top left of the object, opined 
the mouseLoc to the object again. Do the same with left, and also with bottom 
and right if need be. 

Bob S


> On Apr 7, 2020, at 12:24 PM, Roger Guay via use-livecode 
>  wrote:
> 
> Hi all, 
> 
> I know there must be a simple way to do this but it is escaping me at the 
> moment. How can I move an object (grab me on mouseDown) and have it snap to a 
> grid (square on a board game) on mouseUp?
> 
> Thanks much,
> 
> Roger

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Building a Board Game

2020-04-07 Thread Tore Nilsen via use-livecode
What I do is to make a grid of named rectangles (they may or may not be 
visible). I put the names of these into a variable or an array. On mouseUp I 
traverse the variabel/array to check if the mouseLoc is within any of the 
rectangles. When there is a match I set the loc of the grabbed control to the 
loc of the matching rectangle. 


Regards
Tore Nilsen
> 7. apr. 2020 kl. 21:24 skrev Roger Guay via use-livecode 
> :
> 
> Hi all, 
> 
> I know there must be a simple way to do this but it is escaping me at the 
> moment. How can I move an object (grab me on mouseDown) and have it snap to a 
> grid (square on a board game) on mouseUp?
> 
> Thanks much,
> 
> Roger
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Building a Board Game

2020-04-07 Thread Roger Guay via use-livecode
Hi all, 

I know there must be a simple way to do this but it is escaping me at the 
moment. How can I move an object (grab me on mouseDown) and have it snap to a 
grid (square on a board game) on mouseUp?

Thanks much,

Roger
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode