I'm just trying to draw a super simple grid of sprites using drawRect
. However, only the corner rects actually draw all four sides. Something happens with the other rects, making them appear 4x bigger than they actually (?) are.
Here's the code. I'm new to Lua (but old to programming)… this is just my first attempt at drawing something the code is "inspired" by the pachinko example.
function drawBlock(s, x, y, w, h)
gfx.setColor(gfx.kColorBlack)
gfx.setLineWidth(1)
gfx.setStrokeLocation(gfx.kStrokeInside)
gfx.drawRect(x, y, w, h)
end
function newBlock(x, y)
local w = 40
local h = 20
local block = gfx.sprite.new()
block.draw = drawBlock
block:moveTo(x, y)
block:setSize(w, h)
block:setCollideRect(1, 1, w-2, h-2)
block:add()
end
blocks = {}
local i = 0
local xs = {}
for x=0,400,40 do
for y=0,240,20 do
blocks[i] = newBlock(x, y)
i += 1
end
end
function playdate.update()
gfx.sprite.update()
end