iPad Typing Test (made with Codea of course)

function setup()
    showKeyboard()
    displayMode(FULLSCREEN)
    words = 0
    typos = 0
    game = 0
    
    str = ""
    wordsTyped = {}
    
    wordsList = {"hello", "room", "garden", "system", "repeat", "apple", "captain", "bug", "open", "closed", "manager", "yellow", "purple", "red", "green", "blue", "forum", "girl", "boy", "school", "pocket", "clothes", "phone", "smart", "white", "black", "key", "mister", "piano", "people", "oven", "illusion", "codea", "plane", "settings", "table", "tablet", "movie", "help", "hard", "enough", "word", "test", "developer", "moderator", "adminstrator", "english", "german", "russia", "turkey", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "dot", "row", "column", "application", "twelve", "thirteen", "fourteen", "fiveteen", "name", "semicolon", "pain", "laugh", "caps", "comma", "clock", "watch", "google", "pen", "run", "sleep", "dream", "nightmare", "orange", "purple", "swim", "premium", "business", "albert", "number", "digit"}
    
    wordToType = wordsList[math.random(1, #wordsList)]
    timeStarted = os.time()
    firstword = true
    backspace = 0
    thisIsTypo = false
end

function draw()
    background(0)
    
    -- Important Message
    font("ArialMT")
    fontSize(40)
    fill(125, 255)
    text("Touch to show the keyboard! Beware, time runs!", WIDTH/2, 150)
    
    -- Container
    fill(255, 255)
    rect(35, 440, WIDTH-70, HEIGHT-490)
    
    -- "str"
    font("ArialRoundedMTBold")
    fontSize(45)
    fill(0, 255)
    local a, b = textSize(str)
    text(str, WIDTH-45-a/2, 470)
    
    -- "wordToType"
    font("Arial-BoldMT")
    fontSize(35)
    fill(50, 255)
    local a, b = textSize(wordToType)
    text(wordToType, 40 + a/2, HEIGHT-70)
    
    -- table "wordsTyped"
    clip(35, 440, 500, 500)
    for c, d in ipairs(wordsTyped) do
        font("ArialMT")
        fontSize(20)
        fill(0, 0, 0, 255)
        if d[2] == 1 then
            fill(210, 41, 41, 255) -- Typo
        elseif d[2] == 2 then
            fill(202, 134, 49, 255) -- System Message
            font("Arial-BoldMT")
        end
        local a, b = textSize(d[1])
        text(d[1], 40 + a/2, HEIGHT-80-c*20)
    end
    clip()
    
    -- Score
    fill(150, 100, 50, 255)
    fontSize(30)
    font("AcademyEngravedLetPlain")
    text(words .. " words", WIDTH-100, HEIGHT-70)
    fill(150, 50, 50, 255)
    text(typos .. " typos", WIDTH-100, HEIGHT-100)
    fill(50, 200, 35, 255)
    
    local ti = os.time() - timeStarted
    if firstword then
        fill(175, 165, 135, 255)
        
    end
    text(ti, WIDTH-100, HEIGHT-130)
    
    -- Check local "ti" (listed and named above)
    if ti >= 60 and not firstword then
        endGame()
    end
    
    -- Check "nextWord()"
    if wordToType == str then
        nextWord()
    end
    
    if #wordToType == #str then
        thisIsTypo = true
        nextWord()
    end
end

function touched(t)
    if not isKeyboardShowing() then
        if t.state == ENDED then
            showKeyboard()
        end
    end
end

function keyboard(k)
    if k == BACKSPACE then
        backspace = backspace + 1
        if backspace >= 5 then
            thisIsTypo = true
            nextWord()
        end
        
        str = string.sub(str, 1, #str - 1)
    elseif k == RETURN then
        if wordToType == str then else
            thisIsTypo = true
        end
        nextWord()
    else
        str = str .. k
    end
    
    if firstword then
        firstword = false
        timeStarted = os.time()
    end
end

function nextWord()
    local lk = 0
    if thisIsTypo then
        typos = typos + 1
        lk = 1
    end
    table.insert(wordsTyped, 1, {wordToType, lk})
    wordToType = wordsList[math.random(1, #wordsList)]
    str = ""
    backspace = 0
    words = words + 1
    thisIsTypo = false
end

function endGame()
    -- Show score
    alert("Time ran out!\
\
You have written " .. words .. " Words, (but) you had " .. typos .. " mistake(s).\
Your final score is " .. (words-typos) .. " WPM. ", "Time ended!")
    
    -- Reset
    words = 0
    typos = 0
    wordToType = wordsList[math.random(1, #wordsList)]
    timeStarted = os.time()
    firstword = true
    str = ""
    
    -- Breakpoint in the list
    game = game + 1
    table.insert(wordsTyped, 1, {"GAME 1", 2})
    table.insert(wordsTyped, 1, {"", 2})
end

Copy the code, rate & share your score here.

Edit: My score is 29 WPM :slight_smile:

25WPM :confused:

Bump.

@Simeon, @John, @Ignatz, @yojimbo2000, @dave1707; active moderators, adminstrators and all users

C’mon; only one minute. Post your score!

I had 23 wpm, but then I only type with 1 finger. I don’t need to type fast when I code because I’m usually thinking about how to do something as I write the code.

@TokOut I got a solid 29 words per minute on my first try. I have to be honest tho, I thought it was a bit confusing, but while playing, i started getting the hang of it, Great Program!

I had 23 wpm, but then I only type with 1 finger. I don’t need to type fast when I code because I’m usually thinking about how to do something as I write the code.

Thank you for the feedback! When typing, of course, i don’t type that fast while coding. Only for fun!

@TokOut I got a solid 29 words per minute on my first try. I have to be honest tho, I thought it was a bit confusing, but while playing, i started getting the hang of it, Great Program!

Great! Thanks for the feedback, too!

@TokOut 29 WPM, first try :smiley:

54WPM

54WPM

Please clue!