Colour wars [0 player game]

Feel free to showcase your own projects!
Post Reply
User avatar
trosh
Posts: 1594
Joined: 03 Feb 2012, 08:36

Post » 28 Feb 2012, 11:00

Sadly, this isn't made with love2d [see link in post below]. I was forced by my university to work with C programming and their graphics library (which just gives french names for sdl functions), but I realised simple graphics can be much faster with SDL than with love2d. So I made this simple enough algorithm yesterday (among other things), which makes some cool colour animation.
the (simplified) idea is : you get a 30x25 grid of blocks with random colours, and then you have a pixel running around the screen randomly mixing the r,g and b values of two adjacent colours. this happens so fast you don't see it (it actually happens 5000 times per frame, with 15ms wait between each frame). eventually one colour "wins", after an epic fight with all the other colours. it's pretty fun to watch.
Also on the right there's a visualisation of what part of the grid each colour takes up, and their r, g and b parts for logical interpretation.
you can pause by placing the mouse over that area of the window, unpause by going on another part of the window at least once.
There is a pause button now, just hover over it.

here's a screenshot
here's a newer screenshot yay pause button.

Colour Wars V1
Colour Wars V1.1
the LINUX (as in not windows and probably not mac, though feel free to try) executable (please tell me if it works with other distros than ubuntu, if you're running one)
To execute, run

Code: Select all

$ chmod +x random_colours
$ ./random_colours
in the directory you downloaded it (or use whatever you like to enable the executable bit)
http://www.mediafire.com/?7xi6ugkhidlv4g6 the source code, for whatever use you might have (don't try to compile as is, this needs its own graphics library)
feel free to use the source code as you please, however if you use a consequent amount please quote me (John Gliksberg) (I'll leave the interpretation of "consequent" to you).
I guess I could probably find a way to make this run on windows but it would be a major pain, and who cares about mac users anyway (though the executable might - probably won't - work out of the box on mac, seeing as it's *NIX and shit)
thank you.
Last edited by trosh on 01 Mar 2012, 13:49, edited 2 times in total.

User avatar
rokit
Posts: 2095
Joined: 03 Feb 2012, 00:47

Post » 28 Feb 2012, 23:20

oh shit i'm on PC (WIN7) can all the UNIX-like OS's have exe executables.
I ALSO THINK THAT A .JAR FILE SHOULD BE COULD .JEXE!

User avatar
trosh
Posts: 1594
Joined: 03 Feb 2012, 08:36

Post » 29 Feb 2012, 00:05

what ?
are you drunk ? I am, but I can still tell the difference between "could" and "called".
also what ? .jexe ? the name exe is very specific to windows executables, while jar is for java i think, and so much more open to different types of os's, devices etc.

User avatar
slime
Shaders guy
Posts: 148
Joined: 02 Feb 2012, 21:37

Post » 29 Feb 2012, 01:10

I realised simple graphics can be much faster with SDL than with love2d
Considering SDL 1.2 does pure software rendering (it doesn't deal with the GPU), whereas LÖVE utilizes the GPU through OpenGL, I have a hard time believing that. ;)

User avatar
trosh
Posts: 1594
Joined: 03 Feb 2012, 08:36

Post » 29 Feb 2012, 10:43

Taking into account what you said, I made a basic love2d version : http://www.mediafire.com/?f4ox15bbqzjnllr
Maybe I'm just not dealing well with the programming, but not only does this usually max out the cpu usage, but also (as for several love games I made) it takes up quite a lot of memory (more and more for the few first seconds), until it starts lagging a bit. the only successful way I've found to control cpu usage is by adding a fucking love.timer.sleep() at the end of love.update() -> I shouldn't have to do that.
I'll admit the "algorithm" part of the program is more adapted to love2d structure, but other than that, the sdl program has no problem parsing tables several times per frame, and I can control quite precisely memory / cpu usage. Also maybe the key is in love.draw(), and I don't think it's that adapted to this kind of programs.
Oh and btw I had some trouble working with two tables, and it worked even when it shouldn't have, until I realised I had used a T2 = T1 instruction. So as we had talked about in another forum with maurice, I had to change to table element wide instructions, because that didn't copy T1 into T2, but linked T2 to T1.
Anyway thanks for your feedback

User avatar
slime
Shaders guy
Posts: 148
Joined: 02 Feb 2012, 21:37

Post » 29 Feb 2012, 14:58

It sounds like the LÖVE games you played had memory leaks in their code - not caused by LÖVE, but the person who created the game. I took a look at your Lua code and you're doing a lot of useless and/or redundant things, I don't even know where to start. From what I can tell you could put the entire thing on a shader, too.

User avatar
trosh
Posts: 1594
Joined: 03 Feb 2012, 08:36

Post » 29 Feb 2012, 21:03

no ! bad ! shaders are eviiil. My graphic card is not in agreement. where do you see redundancy ?
also slightly more morish version. not useful, just wanted to add this : http://www.mediafire.com/?4uggtf2fccbokyh
haha i just ran the program, and it gets faster and faster when the number of colours decreases, but at the same time I was listening to some deadmau5 with accelerating rate, so it fitted perfectly well. my life is incredible.

User avatar
i-be-hungry
Posts: 37
Joined: 16 Feb 2012, 01:02

Post » 01 Mar 2012, 05:12

I am sorry, I have a old computer with the linux on it now (newly installed) and am new to linux. is there a special place to place the file? it tells me

Code: Select all

chmod: cannot access `random_colours': No such file or directory
I come from whindows where you just point and click on the things. How to make this work?

User avatar
trosh
Posts: 1594
Joined: 03 Feb 2012, 08:36

Post » 01 Mar 2012, 09:29

oh, you have to change directory to where the file was downloaded. you could use a file manager to look around your home folder, or use "cd something/Download/" to change directories and "ls" to list files in the directory. Nearly there :)
Or if you use the gnome file manager, I think you can right clic on the program -> properties -> permissions tab -> check "allow executing file" box.
then double clic on the file (just like in windows)

ReaxkuTheFox
Posts: 1
Joined: 14 Mar 2012, 22:27

Post » 14 Mar 2012, 22:32

While you're not likely to continue development, I'd like to let you know that it's quite a neat little app (reminds me of Conway's Game of Life for some odd reason)
If on the off chance you do decide to continue improving colour wars, a few suggestions.
Chose the 'playing grid' size
Allow users to customize the grid with their own colors
(and possibly a way to record a 'game', who knows, some unique color choices could render some nice designs)

User avatar
trosh
Posts: 1594
Joined: 03 Feb 2012, 08:36

Post » 14 Mar 2012, 22:57

thanks for the suggestion. I didn't really try to make this user-oriented, but I guess it would be a good thing to make the grid resizable (maybe simply with command line arguments :P)
reminds me of Conway's Game of Life for some odd reason
lol I showed it to a programation teacher yesterday who said the same thing. However this relies massively on a random function while the game of life works with basic logical rules.

I don't see what you mean by customize the grid, and recording a game is just not possible. A starting map wouldn't lead twice to the same result, and recording the whole animation in a nice usable file would be too stupidly fat for my mind.
Maybe you mean the user could have a recorded "starting point" map they would customize and look at the results it could bring ? I think the logic of the game is not expandable enough for specific maps to be really interesting. I'll think about it but I probably won't work in that direction :P

Also did you use the .love or linux version ? If you used the linux executable, please tell me on what distro.

Post Reply