Image bug

I’m making a slide puzzle, but i already ran into a problem, I made a variable that holds a resized image of the cargo bot opening screen. However when it is sprited on the screen, it only shows a quarter of the image. img:copy() isn’t used. How would one fix this.


--# Main
-- Slide Puzzlez
displayMode(FULLSCREEN)
-- Use this function to perform your initial setup
function setup()
    --[[pos = {
    {vec2(WIDTH/2-200,HEIGHT/2+200),vec2(WIDTH/2,HEIGHT/2+200),vec2(WIDTH/2+200,HEIGHT/2+200)},
    {vec2(WIDTH/2-200,HEIGHT/2),vec2(WIDTH/2,HEIGHT/2),vec2(WIDTH/2+200,HEIGHT/2)},
    {vec2(WIDTH/2-200,HEIGHT/2-200),vec2(WIDTH/2,HEIGHT/2-200),vec2(WIDTH/2+200,HEIGHT/2-200)}
    }--]]
    boardImg = image(600,600)
    
    setContext(boardImg)
    background(115, 84, 84, 255)
    setContext()
    puzzle_img=readImage("Cargo Bot:Startup Screen")
    img = image(600,600)
    setContext(img)
    sprite(puzzle_img,0,0,600,600)
    setContext()
    pieces = {}
    --cutImages(3)
    --random_pieces = pieces--tblrandom(pieces)
end

function draw()
    background(40, 40, 50)

    sprite(boardImg,WIDTH/2,HEIGHT/2)
   -- for i=1,#random_pieces do
        --sprite(random_pieces[i],WIDTH/2,HEIGHT/2)
    --end
    
    local n = 1
    for x = 1,3 do
        for y = 1,3 do
            
               -- sprite(random_pieces[n],pos[x][y].x,pos[x][y].y)
                n = n + 1
            
        end
    end
    sprite(img,WIDTH/2,HEIGHT/2)
end

--# Utils
--------------------------
-- Start Game Utilities --
--------------------------
function cutImages(side)
    local w,h = img.width/side,img.height/side
    local n = 1
    for x = 1,side do
        for y = 1,side do
            pieces[n] = img:copy(w*(x-1),h*(y-1),w,h)
            n = n + 1
        end
    end
    --table.remove(pieces,#pieces)
end

function tblrandom(tbl)
    local tab = tbl
    
    for a,b in pairs(tab) do
        local n = math.random(#tab)
        tab[#tab+1] = tab[n]
        table.remove(tab,n)
        
    end
    
    return tab
end

Whoops I meant to put sprite(puzzle_img,width/2,height/2,600,600), and that’s what doesn’t work

Make it sprite(puzzle_img,300,300,600,600).

I was trying sprite(puzzle_img,width/2,height/2,600,600). I haven’t looked at everything yet.

Do you mean sprite(puzzle_img,0,0,600,600) because that doesn’t work.

Also I’ve seen that post, but mine will be resized 600x600

@Doge Here’s an example of a puzzle program I made back in March using the Cargo bot screen.

http://codea.io/talk/discussion/4844/puzzle-example#Item_1

Use center of the screen values for sprite( puzzle_image).