Howdy, Stranger!

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

There seems to be an errror with my code, could you please help?

edited March 2013 in Questions Posts: 3
function setup()
    displayMode(FULLSCREEN)
    timerBlueA = 20
    timerBlueB = 300
    timerRedA = 300
    timerRedB = 300
    timerWolves = 60
    timerWraiths = 50
    timerBaron = 420
    timerDragon = 360
    timerGolems = 60
    timerFlashA = 300
    timerFlashB = 300
    timerWard = 180
    runBlueA = false
    runBlueB = false
    runRedA = false
    runRedB = false
    runWolves = false
    runWraiths = false
    runBaron = false
    runDragon = false
    runGolems = false
    runFlashA = false
    runFlashB = false
    runWard = false
end

function draw()
    sprite("Documents:BlueBox",128,640) -- Top Left
    sprite("Documents:BlueBox",128,128) -- Bottom Left
    sprite("Documents:PurpBox", 896,640) -- Top Right
    sprite("Documents:PurpBox",896,128) -- Bottom Right
    sprite("Documents:BlueBuff",128,640) -- Top Left
    sprite("Documents:BlueBuff",896,640) -- Top Right
    sprite("Documents:RedBuff",128,128) -- Bottom Left
    sprite("Documents:RedBuff",896,128) -- Bottom Right
    sprite("Documents:Baron 1",384,384)
    sprite("Documents:Background",512,384)

    if runBlueA == true then
        BlueA()
    end

    if runBlueB == true then
        BlueB()
    end

    if runRedA == true then
        RedA()
    end

    if runRedB == true then
        RedB()
    end

    if runWolves == true then
        Wolves()
    end

    if runWraiths == true then
        Wraiths()
    end

    if runBaron == true then
        Baron()
    end  

    if runDragon == true then
        Dragon()
    end

    if runGolems == true then
        Golems()
    end

    if runFlashA == true then
        FlashA()
    end

    if runFlashB == true then
       FlashB()
    end

    if runWard == true then
        Ward()
    end
end

function touched(t)
    if t.x < 256 and t.y > 512 then
        runBlueA = true
    end -- BlueA

    if t.x > 768 and t.y > 512 then
        runBlueB = true
    end --BlueB

    if t.x < 256 and t.y < 256 then
        runRedA = true
    end --RedA

    if t.x > 768 and t.y < 256 then
        runRedB = true
    end --RedB

-- ERRORS FOR EVERY BOX BELOW THIS LINE
    --[[if t.x > 256 and t.x < 512 and t.y > 512 then
        runWolves = true
    end -- Wolves

    if t.x > 256 and t.x < 512 and t.y < 256 then
        runWraiths = true
    end--]] --Wraiths

    if t.x > 256 and t.x < 512 and t.y > 256 and t.y < 512 then
        runBaron = true
    end --Baron

    --[[if t.x > 512 and t.x < 768 and t.y > 256 and t.y < 512 then
        runDragon = true
    end --Dragon

    if t.x < 256 and t.y > 256 and t.y < 512 then
        runGolems = true
    end --Golems

    if t.x > 512 and t.y > 512 then
        runFlashA = true
    end --FlashA

    if t.x > 512 and t.y < 256 then
        runFlashB = true
    end --FlashB

    if t.x > 768 and t.y > 256 and t.y < 512 then
        runWard = true
    end--]] --Ward
end

function BlueA()
    if timerBlueA > 0 then
        timerBlueA = timerBlueA - DeltaTime
        fontSize(25)
        text(math.ceil(timerBlueA),128,575)
        fill(57, 255, 0, 255) 
    else runBlueA = false
        timerBlueA = 3
    end
end

function BlueB()    
    if timerBlueB > 0 then  
        timerBlueB = timerBlueB - DeltaTime
        fontSize(25)
        text(math.ceil(timerBlueB),896,575)
        fill(57, 255, 0, 255)
    else
        timerBlueA = 300
    end
end

function RedA()
    if timerRedA > 0 then
        timerRedA = timerRedA - DeltaTime
        fontSize(25)
        text(math.ceil(timerRedA),128,63)
        fill(57, 255, 0, 255) 
    else
        timerRedA = 300
    end
end

function RedB()
    if timerRedB > 0 then
        timerRedB = timerRedB - DeltaTime
        fontSize(25)
        text(math.ceil(timerRedB),896,63)
        fill(57, 255, 0, 255) 
    else
        timerRedB = 300
    end
end

function Wolves()
    if timerWolves > 0 then
        timerWolves = timerWolves - DeltaTime
        fontSize(25)
        text(math.ceil(timerWolves),384,575)
        fill(57, 255, 0, 255) 
    else
        timerWolves = 60
    end
end

function Wraiths()
    if timerWraiths > 0 then
        timerWraiths = timerWraiths - DeltaTime
        fontSize(25)
        text(math.ceil(timerWraiths),384,63)
        fill(57, 255, 0, 255) 
    else
        timerWraiths = 50
    end
end

function Baron()
    if timerBaron > 0 then
        timerBaron = timerBaron - DeltaTime
        fontSize(25)
        text(math.ceil(timerBaron),384,319)
        fill(57, 255, 0, 255) 
    else
        timerBaron = 420
    end
end

function Dragon()
    if timerDragon > 0 then
        timerDragon = timerDragon - DeltaTime
        fontSize(25)
        text(math.ceil(timerDragon),640,319)
        fill(57, 255, 0, 255) 
    else
        timerDragon = 360
    end
end

function FlashA()
    if timerFlashA > 0 then
        timerFlashA = timerFlashA - DeltaTime
        fontSize(25)
        text(math.ceil(timerFlashA),640,575)
        fill(57, 255, 0, 255) 
    else
        timerFlashA = 300
    end
end

function FlashB()
    if timerFlashB > 0 then
        timerFlashB = timerFlashB - DeltaTime
        fontSize(25)
        text(math.ceil(timerFlashB),384,63)
        fill(57, 255, 0, 255) 
    else
        timerFlashB = 300
    end
end

function Ward()
    if timerWard > 0 then
        timerWard = timerWard - DeltaTime
        fontSize(25)
        text(math.ceil(timerWard),896,319)
        fill(57, 255, 0, 255) 
    else
        timerWard = 180
    end
end

function Golems()
    if timerGolems > 0 then
        timerGolems = timerGolems - DeltaTime
        fontSize(25)
        text(math.ceil(timerGolems),128,319)
        fill(57, 255, 0, 255) 
    else
        timerGolems = 60
    end
end

Anything besides blueA, blueB, RedA,RedB isnt working. Each has this error: the initial time comes up, then it counts down 1 second and puts that on top of that initial time. It's weird because its almost the same code for BlueA and Baron, yet Baron has the error. Thanks for helping, i look forward to your replies.

Comments

  • dave1707dave1707 Mod
    edited March 2013 Posts: 8,625

    Add backgroung(40,40,50) as the first statement in draw(). Also check the x,y values for the sprites in draw(), there are different sprites that have the same x,y values. Other than that it seemed to work as far as I could tell. Not sure what it's supposed to do.

    EDIT: Also, in function FlashB, I think the text x,y values should be 640,63, not 384,63. There is an overlap.

  • Posts: 3

    Thank you so much, that background thing worked very well. Love you boo.

Sign In or Register to comment.