So this is the first major creation I have made, checkers. There are only a few issues…
A. There is no king me function
B. if 2 checkers touch, they stick (which is good for jumping other checkers except black is on top no matter what)
C. No area to drag off checkers once jumped (refer to problem in B)
So basically don’t touch the checkers together and remember who gets knitted and you’re good!
--these are the placement of the red checkers
r1x=95
r1y=95
r2x=255
r2y=95
r3x=415
r3y=95
r4x=575
r4y=95
r5x=175
r5y=175
r6x=335
r6y=175
r7x=495
r7y=175
r8x=655
r8y=175
r9x=95
r9y=255
r10x=255
r10y=255
r11x=415
r11y=255
r12x=575
r12y=255
--this is the placement if the black checkers
b1x=175
b1y=655
b2x=335
b2y=655
b3x=495
b3y=655
b4x=655
b4y=655
b5x=95
b5y=575
b6x=255
b6y=575
b7x=415
b7y=575
b8x=575
b8y=575
b9x=175
b9y=495
b10x=335
b10y=495
b11x=495
b11y=495
b12x=655
b12y=495
--this function draws the board and checkers
function draw()
touch()
background(0, 0, 0, 255)
fill(255, 255, 255, 255)
--the game board
rect(55,55,80,80)
rect(215,55,80,80)
rect(375,55,80,80)
rect(535,55,80,80)
rect(135,135,80,80)
rect(295,135,80,80)
rect(455,135,80,80)
rect(615,135,80,80)
rect(55,215,80,80)
rect(215,215,80,80)
rect(375,215,80,80)
rect(535,215,80,80)
rect(135,295,80,80)
rect(295,295,80,80)
rect(455,295,80,80)
rect(615,295,80,80)
rect(55,375,80,80)
rect(215,375,80,80)
rect(375,375,80,80)
rect(535,375,80,80)
rect(135,455,80,80)
rect(295,455,80,80)
rect(455,455,80,80)
rect(615,455,80,80)
rect(55,535,80,80)
rect(215,535,80,80)
rect(375,535,80,80)
rect(535,535,80,80)
rect(135,615,80,80)
rect(295,615,80,80)
rect(455,615,80,80)
rect(615,615,80,80)
-- the checker pieces
touch()
--red checkers
fill(255, 0, 0, 255)
ellipse(r1x,r1y,50,50)
ellipse(r2x,r2y,50,50)
ellipse(r3x,r3y,50,50)
ellipse(r4x,r4y,50,50)
ellipse(r5x,r5y,50,50)
ellipse(r6x,r6y,50,50)
ellipse(r7x,r7y,50,50)
ellipse(r8x,r8y,50,50)
ellipse(r9x,r9y,50,50)
ellipse(r10x,r10y,50,50)
ellipse(r11x,r11y,50,50)
ellipse(r12x,r12y,50,50)
--black checkers
fill(0, 0, 0, 255)
ellipse(b1x,b1y,50,50)
ellipse(b2x,b2y,50,50)
ellipse(b3x,b3y,50,50)
ellipse(b4x,b4y,50,50)
ellipse(b5x,b5y,50,50)
ellipse(b6x,b6y,50,50)
ellipse(b7x,b7y,50,50)
ellipse(b8x,b8y,50,50)
ellipse(b9x,b9y,50,50)
ellipse(b10x,b10y,50,50)
ellipse(b11x,b11y,50,50)
ellipse(b12x,b12y,50,50)
end
--this function tracks the touch and then assigns current touch to the checker coordinates
function touch()
x=CurrentTouch.x
y=CurrentTouch.y
if CurrentTouch.state==BEGAN or CurrentTouch.state==MOVING then
if x>r1x-25 and x<r1x+25 and y>r1y-25 and y<r1y+25 then
r1x=CurrentTouch.x
r1y=CurrentTouch.y
end
if x>r2x-25 and x<r2x+25 and y>r2y-25 and y<r2y+25 then
r2x=CurrentTouch.x
r2y=CurrentTouch.y
end
if x>r3x-25 and x<r3x+25 and y>r3y-25 and y<r3y+25 then
r3x=CurrentTouch.x
r3y=CurrentTouch.y
end
if x>r4x-25 and x<r4x+25 and y>r4y-25 and y<r4y+25 then
r4x=CurrentTouch.x
r4y=CurrentTouch.y
end
if x>r5x-25 and x<r5x+25 and y>r5y-25 and y<r5y+25 then
r5x=CurrentTouch.x
r5y=CurrentTouch.y
end
if x>r6x-25 and x<r6x+25 and y>r6y-25 and y<r6y+25 then
r6x=CurrentTouch.x
r6y=CurrentTouch.y
end
if x>r7x-25 and x<r7x+25 and y>r7y-25 and y<r7y+25 then
r7x=CurrentTouch.x
r7y=CurrentTouch.y
end
if x>r8x-25 and x<r8x+25 and y>r8y-25 and y<r8y+25 then
r8x=CurrentTouch.x
r8y=CurrentTouch.y
end
if x>r9x-25 and x<r9x+25 and y>r9y-25 and y<r9y+25 then
r9x=CurrentTouch.x
r9y=CurrentTouch.y
end
if x>r10x-25 and x<r10x+25 and y>r10y-25 and y<r10y+25 then
r10x=CurrentTouch.x
r10y=CurrentTouch.y
end
if x>r11x-25 and x<r11x+25 and y>r11y-25 and y<r11y+25 then
r11x=CurrentTouch.x
r11y=CurrentTouch.y
end
if x>r12x-25 and x<r12x+25 and y>r12y-25 and y<r12y+25 then
r12x=CurrentTouch.x
r12y=CurrentTouch.y
end
if x>b1x-25 and x<b1x+25 and y>b1y-25 and y<b1y+25 then
b1x=CurrentTouch.x
b1y=CurrentTouch.y
end
if x>b2x-25 and x<b2x+25 and y>b2y-25 and y<b2y+25 then
b2x=CurrentTouch.x
b2y=CurrentTouch.y
end
if x>b3x-25 and x<b3x+25 and y>b3y-25 and y<b3y+25 then
b3x=CurrentTouch.x
b3y=CurrentTouch.y
end
if x>b4x-25 and x<b4x+25 and y>b4y-25 and y<b4y+25 then
b4x=CurrentTouch.x
b4y=CurrentTouch.y
end
if x>b5x-25 and x<b5x+25 and y>b5y-25 and y<b5y+25 then
b5x=CurrentTouch.x
b5y=CurrentTouch.y
end
if x>b6x-25 and x<b6x+25 and y>b6y-25 and y<b6y+25 then
b6x=CurrentTouch.x
b6y=CurrentTouch.y
end
if x>b7x-25 and x<b7x+25 and y>b7y-25 and y<b7y+25 then
b7x=CurrentTouch.x
b7y=CurrentTouch.y
end
if x>b8x-25 and x<b8x+25 and y>b8y-25 and y<b8y+25 then
b8x=CurrentTouch.x
b8y=CurrentTouch.y
end
if x>b9x-25 and x<b9x+25 and y>b9y-25 and y<b9y+25 then
b9x=CurrentTouch.x
b9y=CurrentTouch.y
end
if x>b10x-25 and x<b10x+25 and y>b10y-25 and y<b10y+25 then
b10x=CurrentTouch.x
b10y=CurrentTouch.y
end
if x>b11x-25 and x<b11x+25 and y>b11y-25 and y<b11y+25 then
b11x=CurrentTouch.x
b11y=CurrentTouch.y
end
if x>b12x-25 and x<b12x+25 and y>b12y-25 and y<b12y+25 then
b12x=CurrentTouch.x
b12y=CurrentTouch.y
end
end
if CurrentTouch.state==ENDED then
x=nil
y=nil
end
end