Ghetto Number Pad
Posted: Wed Nov 19, 2014 1:45 am
Just some random stuff I wrote awhile back maybe someone can clean it up heh
Edit: I just tested it and it does not work as expect =(
Edit: I just tested it and it does not work as expect =(
Code: Select all
function numberPanel(size, x, y, line, fill)
local font = love.graphics.newFont(size / 2)
love.graphics.setFont(font) -- might not keep this in here, don't think its a good idea to set the font in a function
local buttonNumber = {}
local number = 1
local space = size / 10
love.graphics.setColor(fill)
love.graphics.rectangle("fill", x+size, y, (size * 3) + space, (size * 4) + space)
love.graphics.setColor(line)
for i = 1, 3 do -- these for loops create buttons 1- 9
buttonNumber[i] = {}
for j = 1, 3 do
buttonNumber[i][j] = {
x = (x + size) * j + space,
y = y + space,
w = size,
h = size,
label = {
text = number,
x = (x + size) * j + math.floor((x + size) / 3) + space,
y = y + math.floor(size / 5) + space
}
}
number = number + 1
end
y = y + size
end -- this is for button 0
buttonNumber[3][4] = { x = buttonNumber[3][2].x, y = buttonNumber[3][3].y + size, w = size, h = size,
label = {text = 0, x = buttonNumber[3][2].label.x, y = (buttonNumber[3][3].label.y + size)}
}
for k = 1, 3 do
for l = 1, 3 do
love.graphics.rectangle("line", buttonNumber[k][l].x, buttonNumber[k][l].y, buttonNumber[k][l].w-space, buttonNumber[k][l].h-space)
love.graphics.print(buttonNumber[k][l].label.text, buttonNumber[k][l].label.x, buttonNumber[k][l].label.y)
end
end -- this is also for button 0
love.graphics.rectangle("line", buttonNumber[3][4].x, buttonNumber[3][4].y, buttonNumber[3][4].w-space, buttonNumber[3][4].h-space)
love.graphics.print(buttonNumber[3][4].label.text, buttonNumber[3][4].label.x, buttonNumber[3][4].label.y)
end