Fly game

Tiny game about fly

function setup()
    pos = vec2(512,384)
    x = 1
    posm = {vec2(512,685), vec2(720,324),vec2(100,576),vec2(math.random(200,900), math.random(200,700)),vec2(math.random(200,900), math.random(200,700)),vec2(math.random(200,900), math.random(200,700)),vec2(math.random(200,900), math.random(200,700)),vec2(math.random(200,900), math.random(200,700)),vec2(math.random(200,900), math.random(200,700)),vec2(math.random(200,900), math.random(200,700)),vec2(math.random(200,900), math.random(200,700))}
    r = 0
    
end

function draw()
    background(107, 191, 218, 255)
    sprite("Platformer Art:Battor Flap 1",pos.x,pos.y,144,72)
    fill(0, 0, 0, 64)
    rect(65,90,100,100)
    rect(65,210,100,100)
    rect(690,80,100,100)
    rect(810,80,100,100)
    sprite("Platformer Art:Coin",posm[x].x, posm[x].y,45,45)
    sprite("Documents:pug",115,140,130,130)
    sprite("Documents:pug",115,260,130,130)
    sprite("Documents:pug",740,130,130,130)
    sprite("Documents:pug",860,130,130,130)
    if pos.x >= posm[x].x- 60 and pos.y >= posm[x].y - 60 and pos.x <= posm[x].x+ 60 and pos.y <= posm[x].y + 60 then
        x = x + 1 
        r = r + 1
    end
    if x == 11 then
        x = 1
        posm[4].x = math.random(150,900)
        posm[4].y = math.random(100,701)
        posm[5].x = math.random(150,900)
        posm[5].y = math.random(100,701)
        posm[6].x = math.random(150,900)
        posm[6].y = math.random(100,701)
        posm[7].x = math.random(150,900)
        posm[7].y = math.random(100,701)
        posm[8].x = math.random(150,900)
        posm[8].y = math.random(100,701)
        posm[9].x = math.random(150,900)
        posm[9].y = math.random(100,701)
        posm[10].x = math.random(150,900)
        posm[10].y = math.random(100,701)
        posm[11].x = math.random(150,900)
        posm[11].y = math.random(100,701)
    end
    
    font("AmericanTypewriter")
    fontSize(34)
    text(r,990,740)
end

function touched(touch)
    
        
    -- print(touch)
    if touch.x >= 55 and touch.x <= 165 and touch.y >= 80 and touch.y <= 190 then
        pos.y = pos.y - 4
    end
    if touch.x >= 55 and touch.x <= 165 and touch.y >= 200 and touch.y <= 310 then
        pos.y = pos.y + 4
    end
    if touch.x >= 680 and touch.x <= 790 and touch.y >= 80 and touch.y <= 190 then
        pos.x = pos.x - 8
    end
    if touch.x >= 800 and touch.x <= 910 and touch.y >= 80 and touch.y <= 190 then
        pos.x = pos.x + 8
    end
    if pos.x >= 1024 then 
        pos.x = pos.x - 1023
    end 
    if pos.x <= 0 then
        pos.x = 1023
    end
    if pos.y >= 768 then
        pos.y = pos.y - 767
    end
    if pos.y <= 0 then
        pos.y = 767
    end
end

@Apselon, we don’t have access to your documents, so we can’t see whatever sprites u use. Also, Avoid hardcoded values and try using a button class

Instead of

posm[4].x = math.random(150,900)
        posm[4].y = math.random(100,701)
        posm[5].x = math.random(150,900)
        posm[5].y = math.random(100,701)
        --etc

Try using loops

for i=4,11 do
    posm[i].x, posm[i].y  = math.random(150,900), math.random(100,701)
end

@Apselon Nice game. You can add things to up the stakes. Have a countdown timer. If you don’t get the coin before the timer is up, you loose a coin. A random coin appears and the timer is reset.

@Apselon Here’s a few things to change. Add the displayMode( FULLSCREEN) before setup() . Then replace your 4 pug sprites with these lines.

    sprite("Cargo Bot:Command Grab",115,140,130,130)
    sprite("Cargo Bot:Command Grab",115,260,130,-130)
    sprite("Cargo Bot:Command Left",740,130,130,130)
    sprite("Cargo Bot:Command Right",860,130,130,130)

EDIT: Also, add this line before setup()

supportedOrientations(LANDSCAPE_ANY)