Page 1 of 1

Random Colour Madness

Posted: Fri Jul 05, 2013 4:43 pm
by Davidobot
Hello, today I present to you my latest 10-minute project: Random Colour Madness!
Basicly it generate alot of different colours onto the screen. And it fits into a compact 1-2KB .love file!
Press any key to generate a new image. Have fun! :awesome:

Re: Random Colour Madness

Posted: Fri Jul 05, 2013 4:53 pm
by jjmafiae
this is so cool, great job chuvak :cool:

Re: Random Colour Madness

Posted: Fri Jul 05, 2013 5:35 pm
by Darky
I think using two loops to make a matrix is an overkill.

instead of

Code: Select all

	for x = 0, map.height do
		for y = 0, map.width do
			love.graphics.setColor(map[x][y].red, map[x][y].green, map[x][y].blue)
			love.graphics.rectangle("fill", x * 12, y * 12, 12, 12)
		end
	end
and

Code: Select all

for x = 0, map.height do
		map[x] = {}
		for y = 0, map.width do
			map[x][y] = {}
			map[x][y].red   = math.random(0, 255)
			map[x][y].blue  = math.random(0, 255)
			map[x][y].green = math.random(0, 255)
		end
	end
you should use :

Code: Select all

for x = 0, map.height*map.width -1 do
			love.graphics.setColor(map[x].red, map[x].green, map[x].blue)
			love.graphics.rectangle("fill", (x  % map.width)*12 , math.floor(x/map.height) * 12, 12, 12)
	end
and :

Code: Select all

for x = 0, map.height*map.width -1 do
			map[x] = {}
			map[x].red   = math.random(0, 255)
			map[x].blue  = math.random(0, 255)
			map[x].green = math.random(0, 255)
	end