Moving checkers/draughts pieces?

Creating Games? Developing something for fun?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
applepie
Posts: 3
Joined: Thu May 09, 2013 6:05 pm

Moving checkers/draughts pieces?

Post by applepie » Tue May 14, 2013 4:03 pm

Hi, I'm trying to find out how to move the checkers/draughts pieces on a specific square and how to make them set up as in setting out the checkers/draughts board. I don't understand how to use LC fully yet so if you can, please can you tell me how each step work for example on line 1 this code does this. Thank you!

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: Moving checkers/draughts pieces?

Post by BvG » Tue May 14, 2013 4:21 pm

What you want is to work with the location of objects. For example:

Code: Select all

put the location of button 1
So if you want to change an objects location you'd not use "put" but instead you'd use "set":

Code: Select all

set the location of button 1 to 100,100
When you want to move a button you can use the move command to move it between two points:

Code: Select all

move button 1 from 45,60 to 80,120
Because the location works with a cartesian x,y coordination system, you can also create a virtual grid:

Code: Select all

put 45 into xMargin --we use this later to make sure our grid doesn't start at 0
put 40 into yMargin --same for y
repeat with x = 1 to 12 --x starts with 0 at the left and then goes up towards the right
   repeat with y = 1 to 12 --y starts with 0 at the top and goes up towards the bottom
      put x,y && x*10,y*10 & return after theResult
   end repeat
end repeat
put theResult
now that you have a grid, you can set the location of a button to one of the coordinates, or use two from the list as a start to move the button.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

applepie
Posts: 3
Joined: Thu May 09, 2013 6:05 pm

Re: Moving checkers/draughts pieces?

Post by applepie » Wed May 15, 2013 9:05 pm

Thank you BvG

Post Reply