Project Issues

What exact error are you getting (always tell us this)

‘}’ expected to close ‘{’ at line 12 (The very first line, imgs) near ‘)’

Well, if you use my example above, it should work.

I would check the code on line 11, in case that is where the problem is

That is extremely strange. I copied the code exactly like yours, it didn’t work, but when I C+Ped it, it worked. Either way, thank you again for your expertise.

Updated.

@Treshure When you have new questions please post them as a reply as well. It helps the thread make more sense for those that might stumble upon the thread and have similar questions.

@Treshure Create a physics object and then translate, rotate your image based on the physics objects location.

Here is a physics example with letters being drawn.

function setup()
    displayMode(FULLSCREEN)
    bodies = {}
    walls = {}
    colors = {}
    parameter.integer("GravityInt",-300,300,0)
    
    
    txtTbl = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}
    createWalls()
    createBalls(18)
    createBallColor()
    
end

function draw()
    background(250, 250, 250, 255)
    physics.gravity(vec2(0,GravityInt))
    for i=1,#bodies do
        pushMatrix()
        translate(bodies[i].x,bodies[i].y)
        rotate(bodies[i].angle)
    fontSize(bodies[i].radius *2)
        fill(colors[i])
        textMode(CENTER)
        if i > 26 then 
        text(string.lower(txtTbl[i-26]),0,0)
        else
            text(txtTbl[i],0,0)
        end 
        popMatrix()
    end
end

function createWalls()
    local bot = physics.body(EDGE,vec2(1,1),vec2(WIDTH,1))
    bot.restitution = 1
    table.insert(walls,bot)
    local right = physics.body(EDGE,vec2(WIDTH,1),vec2(WIDTH,HEIGHT))
    right.restitution = 1
    table.insert(walls,right)
    local top = physics.body(EDGE,vec2(1,HEIGHT),vec2(WIDTH,HEIGHT))
    top.restitution = 1
    table.insert(walls,top)
    local left = physics.body(EDGE,vec2(1,1),vec2(1,HEIGHT))
    left.restitution = 1
    table.insert(walls,left)
    
end

function createBalls(size)
    for i=1,52 do
        local ball = physics.body(CIRCLE,size)
        ball.restitution = 1.1
        ball.x = math.random(0,WIDTH)
        ball.y = math.random(0,HEIGHT)
        --ball.mass = .01
        ball.linearVelocity = vec2(100+math.random(-400,400),100+math.random(-400,400))
        --ball.gravityScale = -1
        table.insert(bodies,ball)
        
        
    end
end

function createBallColor()
    for i=1,52 do
        table.insert(colors,color(math.random(0,255),math.random(0,255),math.random(0,255),255))
    end
end