Codea Timer

here you go :):


-- Codea timer

-- Use this function to perform your initial setup
function setup()
    function draw()
       
    displayMode(FULLSCREEN)
        fill(0, 3, 255, 255)
        background(43, 255, 0, 255)
    font("AmericanTypewriter-Bold")
    fontSize(70)
    text("Codea Timer", WIDTH/2, HEIGHT/2)
    text("Tap To Begin", WIDTH/2, HEIGHT/3)
    function touched(touch)
    text("Tap To Begin", WIDTH/2, HEIGHT/3) 
        color(124, 117, 117, 255)
         
    function draw()
                
  millisec = 1 


        
-- This function gets called once every frame
function draw()
    -- This sets a dark background color 
    

    -- This sets the line thickness
    sprite("SpaceCute:Background", 400, 400, 1400, 1200)
    noStroke()
    fill(255, 9, 0, 255)

    -- Do your drawing here
    
    millisec = millisec + 1  
    fontSize(50)
    text("milliseconds: " ..millisec, 400, 500)
                    sprite("Planet Cute:Character Boy", WIDTH/2, HEIGHT/3)
                    function touched(touch)
                        background(255, 0, 0, 255)
                        sprite("Documents:You Crack Me up (PhotoShop)", WIDTH/2, HEIGHT/2)
                        
                    end
end
end
end
        
        end
    end

:slight_smile:

@AwesomeCodeaKid Whenever you post code to the forum, put 3 ~'s on a line before and after the code. I added them to your code above.

@AwesomeCodeaKid I’m surprised your program even ran. You have 3 draw functions and 2 touched functions and everything is in the function setup. If you continue to code like this, you’re going to have a very hard time. Please read the tutorials.

@AwesomeCoderKid Something else you can do is look at the 4th discussion “FAQ - Please Read”. That will also give you information you can use.

I know but I’m only 9.

@AwesomeCodeaKid Welcome to the forum and you picked a great app to learn coding. But I’m still going to say read the tutorials.

I know, but I’ve had this for years and this code I made when I was 6 XD

@AwesomeCodeaKid that’s impressive! Thanks for sharing your work.

@AwesomeCodeaKid hell of a good job getting it to that stage. Have a look at some of the built-in examples in Codea to see how to better layout your code. Also using some of the examples for your own code would be a good way to start making some more complex ideas possible. I’ve changed the layout of your code below to show how you can make the code a bit neater which makes coding easier for you.


-- Codea timer

-- Use this function to perform your initial setup
function setup()
    displayMode(FULLSCREEN)
    millisec = 0
    --create a variable 't' to check for beginning tap
    t = false
end
-- This function gets called once every frame
function draw()
    sprite("SpaceCute:Background", 400, 400, 1400, 1200)
    noStroke()
    fill(255, 9, 0, 255)

    -- Do your drawing here
    if millisec>0 then
        millisec = millisec + 1  
    end
    fontSize(50)
    text("milliseconds: " ..millisec, 400, 500)
                    sprite("Planet Cute:Character Boy", WIDTH/2, HEIGHT/3)
    if not t then
        fill(0, 3, 255, 255)
        background(43, 255, 0, 255)
        font("AmericanTypewriter-Bold")
        fontSize(70)
        text("Codea Timer", WIDTH/2, HEIGHT/2)
        text("Tap To Begin", WIDTH/2, HEIGHT/3)
    end
    if t == 1 then
        background(255, 0, 0, 255)
        sprite("Documents:You Crack Me up (PhotoShop)", WIDTH/2, HEIGHT/2)
    end
end


function touched(touch)
    if millisec == 0 then
        --start the timer and change screen
        t = true
        millisec = 1
    end
    t = 1
    if touch.state == ENDED then
        --checks if you have stopped touching the screen and hides the (PhotoShop) sprite
        t = true
    end
end