function drawLevel() {
    ctx.clearRect(0, 0, canvas.width, canvas.height)
    firstWord = false
    // draw words!
    for (l = 0; l < lineCount; l++) {
        wordPadding = 0
        var lineY = (l * (lineHeight + linePadding)) + lineOffsetTop
        for (w = 0; w < wordsInRow; w++) {
            if (lineY < height * 0.7 + lineHeight) {
                if (w > 0) {
                    wordPadding += ctx.measureText(currentLevel[0][w - 1] + ' ').width
                }
                // this hides 'not' during the last levels
                if (currentLevel.length == 4 && w == 3) {
                    ctx.clearRect(wordPadding + lineOffsetLeft - (ctx.measureText(currentLevel[0][2] + ' ').width / 7) * finalCount, lineOffsetTop-lineHeight, ctx.measureText(currentLevel[0][2] + ' ').width, lineHeight+5)
                    // this moves 'die' closer to 'will'; not sure which way is better
                    // wordPadding -= (ctx.measureText(currentLevel[0][2] + ' ').width / 9) * finalCount
                }
                if (words[l][w].status == 1) {
                    // if there's only one word in the row
                    if (wordsInRow == 1) {
                        var textPosition = 'center'
                        var wordX = width / 2
                    } else {
                        textPosition = 'left'
                        wordX = wordPadding + lineOffsetLeft
                    }
                    if (firstWord == false) {
                        firstWord = [l, w]
                    }
                    ctx.font = lineHeight + 'px IM Fell French Canon'
                    ctx.textAlign = textPosition
                    ctx.fillStyle = '#000000'
                    ctx.fillText(currentLevel[0][w], wordX, lineY)
                }
            }
        }
    }
    if (words[lineCount - 1][wordsInRow - 1].status == 0) {
        startNextLevel()
    }
    // if the level consists of several lines
    else if (currentLevel[1] > 1 && isRunning == true) {
        if (Date.now() - timeAtLevelStart < currentLevel[2] * 1000) {
            lineOffsetTop -= lineSpeed
        } else {
            startNextLevel()
        }
    }
    requestAnimationFrame(function () {
        drawLevel()
    })
}
// renders text, moves it around, starts next level
renders text, moves it around, starts next level
renders text moves it around starts next level
function drawLevel() {
    ctx.clearRect(0, 0, canvas.width, canvas.height)
    firstWord = false
    for (l = 0; l < lineCount; l++) {
        wordPadding = 0
        var lineY = (l * (lineHeight + linePadding)) + lineOffsetTop
        for (w = 0; w < wordsInRow; w++) {
            if (lineY < height * 0.7 + lineHeight) {
                if (w > 0) {
                    wordPadding += ctx.measureText(currentLevel[0][w - 1] + ' ').width
                }
                if (currentLevel.length == 4 && w == 3) {
                    ctx.clearRect(wordPadding + lineOffsetLeft - (ctx.measureText(currentLevel[0][2] + ' ').width / 7) * finalCount, lineOffsetTop-lineHeight, ctx.measureText(currentLevel[0][2] + ' ').width, lineHeight+5)
                }
                if (words[l][w].status == 1) {
                    if (wordsInRow == 1) {
                        var textPosition = 'center'
                        var wordX = width / 2
                    } else {
                        textPosition = 'left'
                        wordX = wordPadding + lineOffsetLeft
                    }
                    if (firstWord == false) {
                        firstWord = [l, w]
                    }
                    ctx.font = lineHeight + 'px IM Fell French Canon'
                    ctx.textAlign = textPosition
                    ctx.fillStyle = '#000000'
                    ctx.fillText(currentLevel[0][w], wordX, lineY)
                }
            }
        }
    }
    if (words[lineCount - 1][wordsInRow - 1].status == 0) {
        startNextLevel()
    }
    else if (currentLevel[1] > 1 && isRunning == true) {
        if (Date.now() - timeAtLevelStart < currentLevel[2] * 1000) {
            lineOffsetTop -= lineSpeed
        } else {
            startNextLevel()
        }
    }
    requestAnimationFrame(function () {
        drawLevel()
    })
}
function drawLevel ( ) { ctx . clearRect ( 0 , 0 , canvas . width , canvas . height ) firstWord = false for ( l = 0 ; l < lineCount ; l ++ ) { wordPadding = 0 var lineY = ( l * ( lineHeight + linePadding ) ) + lineOffsetTop for ( w = 0 ; w < wordsInRow ; w ++ ) { if ( lineY < height * 0.7 + lineHeight ) { if ( w > 0 ) { wordPadding += ctx . measureText ( currentLevel [ 0 ] [ w - 1 ] + ' ' ) . width } if ( currentLevel . length == 4 && w == 3 ) { ctx . clearRect ( wordPadding + lineOffsetLeft - ( ctx . measureText ( currentLevel [ 0 ] [ 2 ] + ' ' ) . width / 7 ) * finalCount , lineOffsetTop - lineHeight , ctx . measureText ( currentLevel [ 0 ] [ 2 ] + ' ' ) . width , lineHeight + 5 ) } if ( words [ l ] [ w ] . status == 1 ) { if ( wordsInRow == 1 ) { var textPosition = 'center' var wordX = width / 2 } else { textPosition = 'left' wordX = wordPadding + lineOffsetLeft } if ( firstWord == false ) { firstWord = [ l , w ] } ctx . font = lineHeight + 'px IM Fell French Canon' ctx . textAlign = textPosition ctx . fillStyle = '#000000' ctx . fillText ( currentLevel [ 0 ] [ w ] , wordX , lineY ) } } } } if ( words [ lineCount - 1 ] [ wordsInRow - 1 ] . status == 0 ) { startNextLevel ( ) } else if ( currentLevel [ 1 ] > 1 && isRunning == true ) { if ( Date . now ( ) - timeAtLevelStart < currentLevel [ 2 ] * 1000 ) { lineOffsetTop -= lineSpeed } else { startNextLevel ( ) } } requestAnimationFrame ( function ( ) { drawLevel ( ) } ) }
renders text, moves it around, starts next level
renders text moves it around starts next level
// draw words! // this hides 'not' during the last levels // this moves 'die' closer to 'will'; not sure which way is better // wordPadding -= (ctx.measureText(currentLevel[0][2] + ' ').width / 9) * finalCount // if there's only one word in the row // if the level consists of several lines