lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi all-

This is one of the first programs I've built from scratch and am really excited about it, except that no one else at my school knows Lua to help me trouble shoot.  I'm using Xcode 7.3 beta 3.  I'm sure there are better ways to code it, I'm just a novice!  I've been looking for other tutorials that might be good to use with my students (who have Codea) but haven't found a lot that teach - more that are just references.

Anyhow, how it's working in the simulator is different from how it works on the iPad.  I have a rectangle printing each time to cover the prior score and in the simulator, it puts up one "cover rectangle" and then the new score.  But when I build it on the iPad mini itself, it seems to write 2 scores at the same time so it looks messy.  Any help/suggestions? Any reasons why it would work differently in the simulator than the iPad?

Thanks so much for your time.  I don't know any one else that knows Lua :)
~Esther


>From Main.lua



function setup()



    --Set the viewer to fullscreen

    displayMode( FULLSCREEN )



    total = 0



    perry = {points=50}

    bridge = {points=100}

    acadia = {points=150}


    print("Width ", WIDTH)

    print("Height ", HEIGHT)


end




function draw()



    fontSize(50)

    fill(150,0,0,255)

    --Score words

    text("Score", WIDTH/2, 650)





    fontSize(20)



    --Perry's Rectangle

    fill( 150, 0, 150,255)

    rect( 0, 0, 300, 500 )



    --Bridge Rectangle

    fill(0,150, 150, 255)

    rect(300,0,600,500)



    --Acadia Rectangle

    fill(150, 150, 0, 255)

    rect(600,0,WIDTH, 500)



    --Bridge Words

    fill(150,0,0,255)

    text("Perry's", 100, 450)

    text("Bridge", 450, 450)

    text("Acadia", 750, 450)








    fill(100, 100, 200, 255)

    ellipse (CurrentTouch.x, CurrentTouch.y, 100, 100)


    if CurrentTouch.state == BEGAN then


        if CurrentTouch.x <=300

            then total = total + perry.points

            else if CurrentTouch.x >=600

                then total = total + bridge.points

                else total = total + acadia.points

                end

        end



       --Rectangle to cover previous score

        fill(0,100,0,255)

        rect(WIDTH/2-100, 500, 200, 100)



        fill(255,255,255,250)

        fontSize(30)

        text(total, WIDTH/2, 550)

        print(total)


    end


end




---
Technology Integrator
Oceanside High School (East & West)
Owls Head Central School
Gilford Butler School
emckay@rsu13.org<mailto:emckay@rsu13.org>