Leaf Dodge! - Codea Cook Off Entry [Update #5]

#The Idea:

Dodge the leaves falling from the tree, while gathering LeafPoints to buy things from the store to help last longer!

#The Objective:

  • Tilt the Device to dodge!

  • Maybe discover some Easter Eggs along the way

#Update #1

Rough Draft of the Menu:

PicPaste: image-GLeOEow8.jpg

#Update #1

New, but still rough menu:

PicPaste: image_6.jpg

#Update #3

A Wiki! It’s currently empty, but that will change!

#Update #4

More added to the Wiki

Another coverage thread (more in depth) of LeafDodge on the Wiki

#Public Response #1

I can’t decide between this and the old background, so I decided to go to the public for their opinion. Which one should I go with?

PicPaste: image-9341XQI8.jpg

Or the old Background?(Shown above)

@CodeaNoob tbh I’d take this one, the new one

I prefer this one, although I’m wondering… Are you making these backgrounds yourself?

It’s a Free PC Wallpaper found from a google search, link for the creator is in the bottom left

EDIT: You have to click the image and look closely at the picpaste image as the forum format makes it harder to see

I like the second one.

#Announcment #1

The background is now the second of the two choices

Thank you for participating!

#RESOLVED

@CodaNoob I thought http.request are against the rules?

@Prynok my guess the http.request is for image loading :wink:

@stevon8ter, yes it is

I’m having trouble reading your code as everything is un-formatted. I did notice however, that you have a different class for every button. Why not use one class that takes the name, size, position, and callback. Then you can make as many buttons as you want

I found the issue: you were looping through a table but you had an extra end that closed the loop before you tried to do more stuff with the object stored in the table. This is where formatting comes in handy. This only became obvious after I formatted everything properly. (Not everything, I did everything up to the touched function and am leaving the rest for you to sift through) I also noticed you had an if state == GAME_OVER embedded in your if state == GAME_PLAYING which is impossible, so I moved it out for you.

Here is the chunk I fixed:

function setup()
    --[[
    if readLocalData("Hero") == nil then
        CreateHero()
        saveImage("Documents:LeafDodgeHero")
    end
    --]]
    
    if readLocalData("Leaves") == nil then
        saveLocalData("Leaves",0)
    end
    
    parameter.watch("Lives")
    parameter.text("Console","",callBack)
    
    Button:init()
    ShopButton:init()
    Website:init()
    
    Lives = 3
    
    GAME_PLAYING = 0
    GAME_DEAD = 1
    GAME_OVER = 2
    SHOP = 3
    
    state = GAME_DEAD
    
    objectTable = {}
    
    lastGenerated = ElapsedTime-2
    interval = 0.11
    num = 7
    
    table.insert(objectTable, Objects(math.random(1,WIDTH-1),math.random(1,4),num))
    
    pColor = color(0, 0, 0, 255)
    
    paddle = Paddle(WIDTH/2,5,80,15,pColor)
    
    Angle1 = math.random(-360,360)
    Angle2 = math.random(-360,360)
    Angle3 = math.random(-360,360)
    Angle4 = math.random(-360,360)
    
    if state == SHOP then
        ShopClass:init()
    end
end

function draw()
    spriteMode(CENTER)
    sprite("Documents:BG2",WIDTH/2,HEIGHT/2,WIDTH,HEIGHT)
    
    if state == GAME_DEAD then
        pushStyle()    
        spriteMode(CENTER)
        fill(0, 0, 0, 255)
        textMode(CENTER)
        textAlign(CENTER)
        font("AmericanTypewriter")
        fontSize(30)
        ShopButton:draw()
        Button:draw()
        Website:draw()
        fill(255, 255, 255, 255)
        text("Version 1.0",500,750)
        text("LeafPoints: "..math.floor(readLocalData("Leaves")),WIDTH/2,50)
        fontSize(50)
        text("Leaf Dodge!", 500, 600)
        fontSize(35)
        text("Tilt the device to dodge the falling Leaves!", 500, 500)
        text("The longer you live, the more leaf points you get!",500,460)
    end
    
    if CurrentTouch.state == MOVING then
        pushStyle()
        fill(0, 0, 0, 255)
        ellipse(CurrentTouch.x,CurrentTouch.y,50)
        popStyle()
        
        if state == GAME_PLAYING then
            spriteMode(CENTER)
            sprite("Documents:BG2",WIDTH/2,HEIGHT/2,WIDTH,HEIGHT)
            pushStyle()
            randomObjectGenerate()   
            popStyle()       
            score = ElapsedTime 
            fill(255)
            font("Futura-CondensedExtraBold")
            fontSize(30)
            textMode(CORNER)
            score = ElapsedTime - start
            fill(255, 255, 255, 255)
            text("LeafPoints: "..string.format("%.0f",score),10,HEIGHT-50)
            text("Lives: "..Lives,900,HEIGHT-50)
            
            drawPaddle()
        end
        
        if state == GAME_OVER then
            alert("You have recieved "..math.floor(score).." LeafPoints!","Epic!")
            saveLocalData("Leaves",readLocalData("Leaves") + math.floor(score))
            state = GAME_DEAD
        end
        
        if state == SHOP then
            background(0, 0, 0, 255)
            ShopClass:draw()
        end
    end
end

function randomObjectGenerate()
    for k,v in pairs(objectTable) do 
        v:draw()    
    end
    
    if ElapsedTime - lastGenerated > interval then
        lastGenerated = ElapsedTime
        num = num + 1
        table.insert(objectTable,Objects(math.random(1,WIDTH-1),math.random(1,4),num))  
    end
    for k,v in pairs(objectTable) do 
        if paddle:collide(v.a.x,v.a.y) and v.a.info.id > 0 then
            sound(SOUND_HIT, 46295)
            v.a.info.id=0
            Lives=Lives-1
            if Lives<1 then
                state=GAME_OVER
            end
        end
    
        if v.a.y < 0 or (v.a.x > WIDTH or v.a.x< 0) or v.a.info.id == 0 then
            table.remove(objectTable,k)
            v.a:destroy()
            v.a = nil
            v=nil
        end
    end
end
    
function drawPaddle()
    paddle:draw()
end

function touched(touch)
    if state == GAME_DEAD then
        Button:touched(touch)
        ShopButton:touched(touch)
        Website:touched(touch)
    end
end

Happy Coding!

#Update #5

Ok, I have kept this thread pretty bare for documentation, going more in depth on the Leaf Dodge Wiki: http://leafdodge.wikia.com
But now I have decided to beef up this thread to help the Reporting category of the judging.

  1. Basic Store with ONE Item so far… I hope to have at LEAST three with launch with ONE Bonus Content Pack.

  2. “More Games” button to see more games by me!

  3. New Easter Eggs!

#Update #6

With the help of @JakAttak, Image downloading has been implemented. Game must be connected to the internet to have the background images.