Ghetto Number Pad

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
artofwork
Citizen
Posts: 91
Joined: Mon Sep 15, 2014 1:17 am
Location: East Coast USA

Ghetto Number Pad

Post by artofwork »

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 =(

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
Last edited by artofwork on Wed Nov 19, 2014 2:03 am, edited 1 time in total.
User avatar
undef
Party member
Posts: 438
Joined: Mon Jun 10, 2013 3:09 pm
Location: Berlin
Contact:

Re: Ghetto Number Pad

Post by undef »

I don't know what it was supposed to do, but I cleaned it up :P:

Code: Select all

function numberPanel()
end
twitter | steam | indieDB

Check out quadrant on Steam!
User avatar
artofwork
Citizen
Posts: 91
Joined: Mon Sep 15, 2014 1:17 am
Location: East Coast USA

Re: Ghetto Number Pad

Post by artofwork »

undef wrote:I don't know what it was supposed to do, but I cleaned it up :P:

Code: Select all

function numberPanel()
end
Funny :(
User avatar
undef
Party member
Posts: 438
Joined: Mon Jun 10, 2013 3:09 pm
Location: Berlin
Contact:

Re: Ghetto Number Pad

Post by undef »

No, but seriously, what is it?
twitter | steam | indieDB

Check out quadrant on Steam!
User avatar
artofwork
Citizen
Posts: 91
Joined: Mon Sep 15, 2014 1:17 am
Location: East Coast USA

Re: Ghetto Number Pad

Post by artofwork »

undef wrote:No, but seriously, what is it?
Its your phone number :p
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 7 guests