flappy game

Here is a game that I am working on for a class project. It would be great to get some feedback on how I could improve it in any way. Thank you!

-- flappy game
--Kyle Wood
supportedOrientations(PORTRAIT_ANY)--can only be used in portrait position
function setup() 
    displayMode(FULLSCREEN)
    game=0
    timer=0
    highscore=readLocalData("highscore",0)--saves highscore for device
    score=0
    dead=0
    lastscore=0
    waterX=0
end

function draw()
if game==0 and dead==0 then
--Displaying the start screen and performing initial setups
    if score>lastscore then lastscore=score end
    if score>highscore then 
        highscore=score
        saveLocalData("highscore",highscore) end
    scorechange=0
    score=0
    speedY=1
    pipeX1=WIDTH
    pipeY1=math.random((200),(HEIGHT-200))
    pipeX2=WIDTH
    pipeY2=math.random(200,(HEIGHT-200))
    flapX=WIDTH/2
    flapY=HEIGHT/2
        background(80, 131, 58, 255)  
        font("Futura-Medium")
        fill(84, 62, 45, 255)
        fontSize(50)
        text("Sinking MattyBoo",WIDTH/2, HEIGHT-200)
        fontSize(20)
        text("Tap to Play",WIDTH/2, HEIGHT-270)
        font("Futura-Medium")
        fill(143, 131, 122, 255)
        fontSize(50)
        text("Sinking MattyBoo",WIDTH/2+2, HEIGHT-200)
        fontSize(20)
        text("Tap to Play",WIDTH/2+2, HEIGHT-270)
        sprite("Documents:MATTYBOO",WIDTH/2,HEIGHT/2,50)--MattyBoosprite is from codea
        font("Futura-Medium")
        fill(84, 62, 45, 255)
        fontSize(30)
        text("Highscore:",WIDTH/2, HEIGHT-1000)
        text(math.ceil(highscore),WIDTH/2+102,HEIGHT-1000)
        fill(143, 131, 122, 255)
        fontSize(30)
        text("Highscore:",WIDTH/2+2, HEIGHT-1000)
        text(math.ceil(highscore),WIDTH/2+104, HEIGHT-1000)
        font("Futura-Medium")
        fill(84, 62, 45, 255)
        fontSize(35)
        text("Score:",WIDTH/2-50,HEIGHT/2-100)
        text(lastscore,WIDTH/2+20, HEIGHT/2-100)
        fill(143, 131, 122, 255)
        fontSize(35)
        text("Score:",WIDTH/2-48,HEIGHT/2-100)
        text(lastscore,WIDTH/2+22, HEIGHT/2-100)
        sprite("Documents:MATTYBOO",flapX,flapY,50)
 end
if dead==1 then 
    --the animation for when the flap dies
        background(34, 115, 188, 255)
        fill(170, 170, 170, 255) 
        rect(pipeX1,pipeY1, 50,HEIGHT)
        rect(pipeX1,pipeY1-HEIGHT-120,50,HEIGHT)
        rect(pipeX2,pipeY2, 50,HEIGHT)
        rect(pipeX2,pipeY2-HEIGHT-120,50,HEIGHT) 
        sprite("Documents:MATTYBOO",flapX,flapY,50)
        font("Futura-Medium")
        fill(0, 51, 255, 255)
        fontSize(50)
        text("You let the MattyBoo sink...",WIDTH/2, HEIGHT/2)
        speedY=speedY+0.2
        if flapY>0 then 
            flapY=flapY-speedY
            elseif flapY<=0 then game=0 dead=0 end
        end
    
if game==1 and dead==0 then
        
        flapY=flapY+speedY--giving the bird physics and motion depending om the flapY variable
        --detecting the pipes
    if flapX+25>= pipeX1 and flapX<=pipeX1+50 and flapY+10>=pipeY1 then
                 dead=1 speedY=1 sound(SOUND_EXPLODE, 22971)
            
        end
    if flapX+25>= pipeX1 and flapX<=pipeX1+50 and flapY-25<=pipeY1-120 then
                 dead=1 speedY=1 sound(SOUND_EXPLODE, 22971)
            
        end
    if flapX+25>= pipeX2 and flapX<=pipeX2+50 and flapY+10>=pipeY2 then
                 dead=1 speedY=1 sound(SOUND_EXPLODE, 22971)
            
        end
    if flapX+25>= pipeX2 and flapX<=pipeX2+50 and flapY-25<=pipeY2-120 then
                 dead=1 speedY=1 sound(SOUND_EXPLODE, 22971)
            
        end
    if flapY>HEIGHT and flapX+25>=pipeX2 then dead=1 speedY=1 sound(SOUND_EXPLODE, 22971) end
    if flapY>HEIGHT and flapX+25>=pipeX2 then dead=1 speedY=1 sound(SOUND_EXPLODE, 22971) end
        --detecting a score change
        if pipeX1<flapX-50 and scorechange==0 then 
            score=score+1
            scorechange=1
            sound(SOUND_PICKUP, 3156)
        end
        if pipeX2<flapX-50 and scorechange==1 then 
            score=score+1
            scorechange=0
            sound(SOUND_PICKUP, 3156)
        end
        --setting up the display
        background(34, 115, 188, 255)
        
        speedY=speedY-.2--decreasing the Y position of the sprite
        if flapY<0 then game=0 end
       fill(170, 170, 170, 255) 
--pipe 1
    rect(pipeX1,pipeY1, 50,HEIGHT)
    rect(pipeX1,pipeY1-HEIGHT-120,50,HEIGHT)     
    pipeX1=pipeX1-2
    timer=timer+.01
        if pipeX1<-50 then
            pipeX1=WIDTH 
            pipeY1=math.random(200,(HEIGHT-200))
            
        end
--pipe 2
    if timer>2 then     
        rect(pipeX2,pipeY2, 50,HEIGHT)
        rect(pipeX2,pipeY2-HEIGHT-120,50,HEIGHT)     
        pipeX2=pipeX2-2
    if pipeX2<-50 then
            pipeX2=WIDTH
            pipeY2=math.random(200,(HEIGHT-200))
            
            end       
        end--end of pipe 2
--showing the score
        font("Futura-Medium")
        fill(84, 62, 45, 255)
        fontSize(50)
        text(score,WIDTH/2, HEIGHT-50)
        fill(143, 131, 122, 255)
        fontSize(50)
        text(score,WIDTH/2+2, HEIGHT-50)
        sprite("Documents:MATTYBOO",flapX,flapY,50)
end-- end of "game==1"
    sprite("Documents:namelogo",WIDTH-25,HEIGHT/100)--my own personal touch (initials in bottom right corner)
end
function touched(touch)
    --detecting the start of the game
    if touch.state==BEGAN and game==0 and dead==0 then
        timer=0
        flapX=WIDTH/4
        flapY=HEIGHT-100
        game=game+1
        
    end
    --detecting the flap when the game is running
    if touch.state==BEGAN and game==1 then
            speedY=5--increasing the Y position of the sprite
            speech.pitch=2.0
            speech.rate=0.6
            speech.preDelay=0.0
        
            speech.say("MattyBoo")
     end   
end

@kylewood - welcome to the forum.

If this is your first project, you’ve done pretty well, and it is just as frustrating as the original game.

There are some programming improvements you could make, but unless you are going to build more Codea projects, I won’t bother you with them.

@kylewood Isn’t there an flappy bird?