Howdy, Stranger!

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

Something wrong with a metronome

I'm working on a project where when you try to touch the screen with the metronome beat and if you touch it at the right time then the screen turns green. It was working fine but I erased something and I don't know what it was but now it isn't checking if the start variable is true or something. Here's the code:

-- InteractiveMetronome

-- Use this function to perform your initial setup
function setup()
    displayMode(FULLSCREEN)
    fontSize(70)
    firstNum = 255
    secondNum = 255
    thirdNum = 255
    timer = 0
    start = false
    startx = WIDTH/1.2
    starty = HEIGHT/9
end

-- This function gets called once every frame
function draw()
    start = false
    -- This sets a dark background color
    background(firstNum, secondNum, thirdNum, 255)
    fill(255, 255, 255, 255)
    -- This sets the line thickness
    strokeWidth(5)

    -- Do your drawing here
    sprite("Cargo Bot:Dialogue Box",startx,starty,300,150)
    sprite("Cargo Bot:Dialogue Box",WIDTH/6,HEIGHT/9,300,150)
    text("START",WIDTH/1.2,HEIGHT/9)
    if start == true then
        timer = timer + 1
    end
    if timer >= 60 then
        sound(DATA, "ZgFAKgAhQEBAQEBAAAAAALlkiD4ceWk+QABAf0BHQEBAQEBA")
        timer = 0
    end
    fill(0, 0, 0, 255)
    if start == true then 
        text(timer,WIDTH/2,HEIGHT/2)
    end

end

--255, 22, 0, 255
--53, 255, 0, 255

function touched(t)
    if t.state == ENDED and vec2(t.x,t.y):dist(vec2(startx,starty)) < 100 then
        start = true
    end
     if t.state == BEGAN and start == true and timer == 55 or timer == 56 or timer == 57 or timer == 58 or timer == 59 or timer == 60 or timer == 1 or timer == 2 or timer == 3 or timer == 4 or timer == 5 then
        firstNum = 53
        secondNum = 255
        thirdNum = 0
     elseif t.state == BEGAN and start == false and timer == 55 or timer == 56 or timer == 57 or timer == 58 or timer == 59 or timer == 60 or timer == 1 or timer == 2 or timer == 3 or timer == 4 or timer == 5 then
        firstNum = 255
        secondNum = 255
        thirdNum = 255
     end
end

Comments

  • dave1707dave1707 Mod
    Posts: 7,472

    You're always setting start to false at the beginning of draw().

  • Posts: 9

    I just realized that, I kinda feel dumb for missing that

Sign In or Register to comment.