Skip to content

Instantly share code, notes, and snippets.

@JustinPallo

JustinPallo/SpaceCheckers.codea Secret

Created Jan 10, 2012
Embed
What would you like to do?
Space checkers
-- Space Checkers
-- =======================
-- Version 1.1
-- January 9, 2012
-- Justin Pallo
-- justinpallo@gmail.com
-- =======================
--this shows where the red checkers go
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 of 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(21, 0, 255, 255)
    fill(203, 255, 0, 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
    sprite("Tyrian Remastered:Boss D",r1x,r1y,50,50)
    sprite("Tyrian Remastered:Boss D",r2x,r2y,50,50)
    sprite("Tyrian Remastered:Boss D",r3x,r3y,50,50)
    sprite("Tyrian Remastered:Boss D",r4x,r4y,50,50)
    sprite("Tyrian Remastered:Boss D",r5x,r5y,50,50)
    sprite("Tyrian Remastered:Boss D",r6x,r6y,50,50)
    sprite("Tyrian Remastered:Boss D",r7x,r7y,50,50)
    sprite("Tyrian Remastered:Boss D",r8x,r8y,50,50)
    sprite("Tyrian Remastered:Boss D",r9x,r9y,50,50)
    sprite("Tyrian Remastered:Boss D",r10x,r10y,50,50)
    sprite("Tyrian Remastered:Boss D",r11x,r11y,50,50)
    sprite("Tyrian Remastered:Boss D",r12x,r12y,50,50)
    --black checkers
    sprite("Tyrian Remastered:Blimp Boss",b1x,b1y,50,50)
    sprite("Tyrian Remastered:Blimp Boss",b2x,b2y,50,50)
    sprite("Tyrian Remastered:Blimp Boss",b3x,b3y,50,50)
    sprite("Tyrian Remastered:Blimp Boss",b4x,b4y,50,50)
    sprite("Tyrian Remastered:Blimp Boss",b5x,b5y,50,50)
    sprite("Tyrian Remastered:Blimp Boss",b6x,b6y,50,50)
    sprite("Tyrian Remastered:Blimp Boss",b7x,b7y,50,50)
    sprite("Tyrian Remastered:Blimp Boss",b8x,b8y,50,50)
    sprite("Tyrian Remastered:Blimp Boss",b9x,b9y,50,50)
    sprite("Tyrian Remastered:Blimp Boss",b10x,b10y,50,50)
    sprite("Tyrian Remastered:Blimp Boss",b11x,b11y,50,50)
    sprite("Tyrian Remastered:Blimp Boss",b12x,b12y,50,50)
    --this is the king me function
    if r1y>630 and r1y<680 then
        sprite("Tyrian Remastered:Boss D Destroyed",r1x,r1y,50,50)
        end
    if r2y>630 and r2y<680 then
        sprite("Tyrian Remastered:Boss D Destroyed",r2x,r2y,50,50)
        end
    if r3y>630 and r3y<680 then
        sprite("Tyrian Remastered:Boss D Destroyed",r3x,r3y,50,50)
        end
    if r4y>630 and r4y<680 then
        sprite("Tyrian Remastered:Boss D Destroyed",r4x,r4y,50,50)
        end
    if r5y>630 and r5y<680 then
        sprite("Tyrian Remastered:Boss D Destroyed",r5x,r5y,50,50)
        end
    if r6y>630 and r6y<680 then
        sprite("Tyrian Remastered:Boss D Destroyed",r6x,r6y,50,50)
        end
    if r7y>630 and r7y<680 then
        sprite("Tyrian Remastered:Boss D Destroyed",r7x,r7y,50,50)
        end
    if r8y>630 and r8y<680 then
        sprite("Tyrian Remastered:Boss D Destroyed",r8x,r8y,50,50)
        end
    if r9y>630 and r9y<680 then
        sprite("Tyrian Remastered:Boss D Destroyed",r9x,r9y,50,50)
        end
    if r10y>630 and r10y<680 then
        sprite("Tyrian Remastered:Boss D Destroyed",r10x,r10y,50,50)
        end
    if r11y>630 and r11y<680 then
        sprite("Tyrian Remastered:Boss D Destroyed",r11x,r11y,50,50)
        end
    if r12y>630 and r12y<680 then
        sprite("Tyrian Remastered:Boss D Destroyed",r12x,r12y,50,50)
        end
    if b1y>70 and b1y<120 then
        sprite("Tyrian Remastered:Blimp Boss Destroyed",b1x,b1y,50,50)
        end
    if b2y>70 and b2y<120 then
        sprite("Tyrian Remastered:Blimp Boss Destroyed",b1x,b1y,50,50)
        end
    if b3y>70 and b3y<120 then
        sprite("Tyrian Remastered:Blimp Boss Destroyed",b3x,b3y,50,50)
        end
    if b4y>70 and b4y<120 then
        sprite("Tyrian Remastered:Blimp Boss Destroyed",b4x,b4y,50,50)
        end
    if b5y>70 and b5y<120 then
        sprite("Tyrian Remastered:Blimp Boss Destroyed",b5x,b5y,50,50)
        end
    if b6y>70 and b6y<120 then
        sprite("Tyrian Remastered:Blimp Boss Destroyed",b6x,b6y,50,50)
        end
    if b7y>70 and b7y<120 then
        sprite("Tyrian Remastered:Blimp Boss Destroyed",b7x,b7y,50,50)
        end
    if b8y>70 and b8y<120 then
        sprite("Tyrian Remastered:Blimp Boss Destroyed",b8x,b8y,50,50)
        end
    if b9y>70 and b9y<120 then
        sprite("Tyrian Remastered:Blimp Boss Destroyed",b9x,b9y,50,50)
        end
    if b10y>70 and b10y<120 then
        sprite("Tyrian Remastered:Blimp Boss Destroyed",b10x,b10y,50,50)
        end
    if b11y>70 and b11y<120 then
        sprite("Tyrian Remastered:Blimp Boss Destroyed",b11x,b11y,50,50)
        end
    if b12y>70 and b12y<120 then
        sprite("Tyrian Remastered:Blimp Boss Destroyed",b12x,b12y,50,50)
        end
    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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment