Square Calculator


-- Square Calculator
-- Check out my Circle Calculator!
-- By: CodeaNoob

-- Use this function to perform your initial setup
BoxLength = HEIGHT
BoxWidth = WIDTH
BoxWidth = nil
BoxLength = nil
Length = BoxLength
Width = BoxWidth
function setup()
    saveProjectInfo("Description", "A Calculator that finds the Length and Width of a Square")
    parameter.watch("Area")
    parameter.watch("Length")
    parameter.watch("Width")
    parameter.number("BoxLength",1, 999)
    parameter.number("BoxWidth",1, 999)
    parameter.action("Clear Calculations", output.clear)

end

-- This function gets called once every frame
function draw()
    -- This sets a dark background color 
    fill(255, 255, 255, 255)
spriteMode(CENTER)
sprite("Cargo Bot:Opening Background",WIDTH/2,HEIGHT/2,WIDTH,HEIGHT)
fill(255, 0, 0, 255)

    textMode(CORNER)
    textAlign(CENTER)
    font("AmericanTypewriter-Light")
    fontSize(25)
    text("Double Tap to Calculate", 10, HEIGHT-50)
    rect(100,100, BoxLength, BoxWidth)
          Area = BoxLength*BoxWidth
        Width = BoxWidth
        Length = BoxLength
    -- This sets the line thickness
    strokeWidth(5)

    -- Do your drawing here
    
end

function touched(touch)
    if touch.tapCount == 2 and touch.state == ENDED then
        print("--------------------")
        print("Length: "..Length)
        print("Width: "..Width)
        print("Area: ".. Area)
        end
        end