Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Take a bottle

in Code Sharing Posts: 76

-- Bottle on iPad

-- Use this function to perform your initial setup
function setup()
    displayMode(FULLSCREEN)
    print("Hello World!")
    b=math.random(10)
    spriteMode(CORNER)
    rectMode(CORNER)
    textMode(CORNER)
    fontSize(36)
    br=0
    bt=0
    bm=0
    g=false
    x=0
    y=0


end

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

    -- This sets the line thickness
    strokeWidth(5)
    --fill(255,255,255,255)
    -- Do your drawing here
    fill(0, 0, 0, 255)
    rect(900,100,100,100)
    rect(0,250,WIDTH,50)
    text("Click on the bottles -- but",150, 700)
    text("Attention!! A bottle is fragile  !!!",150,650)
    text("You took "..br.." bottles",100,160)
    bm=br-1
    bt=11-br
    if g==true then
        text("You drunk "..bm.. " bottles",100,120)
        text("You have broken "..bt.." bottles",100,80)
    end
    text("again --->", 700,130)
    fill(255, 143, 0, 255)
      rect(0,288,WIDTH,110)
    fill(255,255,255,255)
    for n = 1,10 do
        sprite("Dropbox:Bier1",90*n,380) end

    if f1 == true  then  rect(90,380,80,240) end
    if f2 == true then  rect(180,380,80,240) end
    if f3 == true then  rect(260,380,80,240) end
    if f4 == true then  rect(350,380,80,240) end
    if f5 == true then  rect(440,380,80,240) end
    if f6 == true then  rect(530,380,80,240) end
    if f7 == true then  rect(620,380,80,240) end
    if f8 == true then  rect(710,380,80,240) end
    if f9 == true then  rect(800,380,80,240) end
    if f10 == true then  rect(890,380,80,240) end

     if f1 == true and b == 1 then sprite("Dropbox:Crash",10,380,1050,250) g=true end
     if f2 == true and b == 2 then sprite("Dropbox:Crash",10,380,1050,250) g=true end
     if f3 == true and b == 3 then sprite("Dropbox:Crash",10,380,1050,250) g=true end
     if f4 == true and b == 4 then sprite("Dropbox:Crash",10,380,1050,250) g=true end
     if f5 == true and b == 5 then sprite("Dropbox:Crash",10,380,1050,250) g=true end
     if f6 == true and b == 6 then sprite("Dropbox:Crash",10,380,1050,250) g=true end
     if f7 == true and b == 7 then sprite("Dropbox:Crash",10,380,1050,250) g=true end
     if f8 == true and b == 8 then sprite("Dropbox:Crash",10,380,1050,250) g=true end
     if f9 == true and b == 9 then sprite("Dropbox:Crash",10,380,1050,250) g=true end
     if f10 == true and b == 10 then sprite("Dropbox:Crash",10,380,1050,250) g=true end   
end   

function touched(t)
    if t.state == BEGAN then 
            if t.x >  100 and t.x < 140 and t.y < 580 and t.y > 380 then f1=true 
            br=br+1
        elseif t.x >  190 and t.x < 230 and t.y < 580 and t.y > 380 then f2=true 
            br=br+1
        elseif t.x >  280 and t.x < 320 and t.y < 580 and t.y > 380 then f3=true  
             br=br+1
        elseif t.x >  370 and t.x < 410 and t.y < 580 and t.y > 380 then f4=true 
             br=br+1
        elseif t.x >  460 and t.x < 500 and t.y < 580 and t.y > 380 then f5=true 
             br=br+1
        elseif t.x >  550 and t.x < 590 and t.y < 580 and t.y > 380 then f6=true 
             br=br+1
        elseif t.x >  640 and t.x < 680 and t.y < 580 and t.y > 380 then f7=true   
             br=br+1
        elseif t.x >  730 and t.x < 770 and t.y < 580 and t.y > 380 then f8=true 
             br=br+1
        elseif t.x >  820 and t.x < 860  and t.y < 580 and t.y > 380 then f9=true   
             br=br+1 
        elseif t.x >  910 and t.x < 950  and t.y < 580 and t.y > 380 then f10=true  
            br=br+1
        elseif t.x > 900 and t.x < 1000 and t.y > 100 and t.y < 200 then restart()
     end
    end
end    
Bier1.jpg 2.5K
Crash.jpg 43.9K

Comments

  • dave1707dave1707 Mod
    Posts: 6,993

    @matox Nice game and thanks for supplying the jpg files that go with it. One suggestion would be to have a high bottle count. If you can pick 9 bottles without a crash, then you get all the bottles to show again and the count increases until you cause a crash where you then save the high bottle count. Another suggestion is to use tables to cut down on the number of ‘if‘ statements.

Sign In or Register to comment.