Random Colour Madness

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Random Colour Madness

Post 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:
Attachments
ColourMadness.love
(1 KiB) Downloaded 298 times
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
jjmafiae
Party member
Posts: 1331
Joined: Tue Jul 24, 2012 8:22 am

Re: Random Colour Madness

Post by jjmafiae »

this is so cool, great job chuvak :cool:
User avatar
Darky
Citizen
Posts: 66
Joined: Sat Jun 02, 2012 1:41 pm
Contact:

Re: Random Colour Madness

Post 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
Attachments
cmr.love
(1.76 KiB) Downloaded 185 times
http://darky-ben.fr/Xut my webcomic (french)
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests