Well, the game I am currently working has... mesmerizing gameplay
. But, it doesn't have a background yet.
Anyone have advice on creating hypnotic backgrounds that don't burn your eyes out of their sockets?
Depends on the game. If it is a side scroller, try the attached image (or a similar but better quality, this one is jpg) and use parallax scrolling. If the front game field is very pixelsharp, the effect is at its best very hypnotic. Even when the background doesn't scroll, it seems to "live" or something.
Why dont you apply a demo scene type effect to the background? Such as plamsa, fractal renderer etc. They wont add to file size, but they will look cool and definetly qualify for hypnotic, albiet very distracting.
JH: Thanks for the background, but it doesn't quite fit. I attached a screenshot of the game with a placeholder backround (placeholder character and blocks, too) so you can see the type of game it is.
P.S. it does not scroll
HR: and how might I do these "demo effects"?
There are tons of tutorials on them, in varying languages, each one is different, and will require learning some lines of code. The good news is that since most of these effects are incredibly old someone will have found some way to optimize it incredibly so it runs lightning quick on say a 486.
Some example tutorials:
Fractals:
http://www.geocities.com/CapeCanaveral/2854/
http://www.mandelbrot-dazibao.com/ (this one is made primarily in qbasic, source should be available and ive actually used some of his images in game before, with permission of course. Some tutorials and what not)
Plasma fractal:
http://www.ic.sunysb.edu/Stu/jseyster/plasma/ (Web applet and java source available).
Also theres tons of other effects, fire. Look around the demo scene and youll see what i mean, the tunel effect etc.
Most of those effects don't work to well with this game... I was wondering if I could use an image, tile it, and make it scroll diagonally or something. Would that work?
I would probably do something similar to Worms' floating particle background.
Do you have a screenshot of that? I don't remember exactly what it looked like.
Judging from the screenshot, are you sure "hypnotic" is the way to go?
Otherwise, you could just use Terragen to create a nice background (or a dozen of them).
If you want the hypnotic background where you have the blue sky now, you can indeed put my image there (not my image, nor my avatar. The attachment!)
Or better up, a plasma thing. The plasma thing (or my image, enhanced) gives a spooky depth to the background.
You could just place a random coloured pixel at a random place on the background every frame. That could look quite cool.
EDIT:
I don't know if there are any random number routines in C, I've never found any, but:
| 1 | #include <allegro.h> |
| 2 | #include <time.h> |
| 3 | |
| 4 | int main() { |
| 5 | srand((unsigned)time(NULL)); |
| 6 | allegro_init(); |
| 7 | set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 640, 480, 0, 0); |
| 8 | install_keyboard(); |
| 9 | while(!key[KEY_ESC]) { |
| 10 | putpixel(screen, randnum(640), randnum(480), makecol(randnum(255),randnum(255),randnum(255)));//Change the numbers in randnum to get different shades. |
| 11 | } |
| 12 | } |
| 13 | |
| 14 | int randnum(int num) { |
| 15 | return rand()/(int)(((unsigned)RAND_MAX + 1) / (num+1)); |
| 16 | } |
I don't know if there are any random number routines in C, I've never found any, but:
So you've never found them, yet you use one of them in your code... interesting.
[edit]Oh, and I didn't test it, but your code won't compile unless you include <stdlib.h>
Compiled fine on my machine. By my statement about random numbers, I meant I didn't know of any as simple to use as my 'randnum'.
randnum is out of my 'useful.cpp', a bunch of functions to reduce the amount of typing I need to do.
The X / (Y / Z) has me worried because it's integer arithmetics.
return rand()/(int)(((unsigned)RAND_MAX + 1) / (num+1));
With a low RAND_MAX and a high num, you wouldn't get numbers in the [0 - num[ range.
Ex: RAND_MAX 32767, and you pass num==1000, you expect a result from 0 to 999.
If rand() returns 32000 or above, you'll get 1000 or more instead. A "roll" of exactly 32767 will give you 1023. oops!.
The GNU C manual says:
In the GNU library, it is 2147483647, which is the largest signed integer representable in 32 bits. In other libraries, it may be as low as 32767.
So maybe I'm over-paranoid (being paranoid is ok for programmers)
edit: "google msvc RAND_MAX" says MSVC has 32767. no comment!
My mingw32 stdlib.h says:
#define RAND_MAX 0x7FFF
Ie, 32767
Compiled fine on my machine.
This is because you were including allegro.h, which in turn includes stdlib.h
Try compiling the following (first with the comment, then after uncommenting the line):
I meant I didn't know of any as simple to use as my 'randnum'.
The reason for this is simple (and it's why C doesn't have a double_number() or halve_number() function). If they were to implement a function for every trivial task that people wanted to perform, the language would become too bloated. Instead they give you the tools to make such functions yourself.
And a simpler way of writing your function is:
int randnum(int num) { return rand() % (num+1); }
randnum is out of my 'useful.cpp'
I'm guessing you didn't try compiling your previous code with a C++ compiler then, since C++ doesn't allow implicit declarations. Though, if you compiled it with just a C compiler, it should have still warned you about doing this.
Jonatan Hedborg:
indeed
LennyLen: Your code is not merely "a simpler way of writing (your) function": it is better, but the algorithm is quite different.
And sorry for the off-topic.
return rand() % (num+1);
Doesent that favor lower results unless MAX_RAND max is evenly divisible by (num+1)?
For example; Say num+1 = 50, and rand() returns the highest possible value:
32767 % 50 = 17
So the values 0-17 will have a slightly higher chance of coming up compared to 18-49.
If num+1 is, say, 256;
32767 % 256 = 255. So No problem 
Of course, the difference is small enough to ignore.
If i've done any mistakes, please correct them..
EDIT:
Actually, if we have a very high num+1, near max_rand, the results could be more obvious.
32767 % 32700 = 67
In this case, numbers 0-67 will have a 2/32767 chance while 68-32699 only 1/32767.
Well, surely, if Allegro includes stdlib.h there's no need for me to include it? I've never had any problems with my randnum function. The 'algorithm' I was using is just something I found somewhere on the internet. I should really have declared randnum before main, I forgot about that, I wonder why it still ran.
EDIT:
I was using a C compiler, and it didn't give me any warnings.
EDIT2:
Normally I do everything in C++, and I just #include "useful.cpp". I don't care about most of the errors since it was just a demonstration of my effect.
Well, surely, if Allegro includes stdlib.h there's no need for me to include it?
That depends on whether or not you intend to use allegro with every program you ever write.
[edit]
I should really have declared randnum before main, I forgot about that, I wonder why it still ran.
Because C does allow implicit declaration of functions.
[/edit]
I was using a C compiler, and it didn't give me any warnings.
Then you should have the warnings turned on. They exist for a reason.
I don't care about most of the errors since it was just a demonstration of my effect.
Great attitude.
Just a word to defend James as he took the trouble to write code: the program is a clear explaination of the effect he had in mind, and the only bad effect of rand() is a few pixels darker than average, and a few more drawn offscreen. Nothing worth losing sleep over.
His randnum function gives bad results ONLY when linked with a lousy RNG, anyway.
Nothing worth losing sleep over.
The problems with the code aren't, no. Admitting you don't care if there are errors in the code your trying to show someone is though.
There's some source for a plasma-effect in ChromaPlas. Although applying the plasma to the 8-bit pixel-value (add a palette-changing effect for added goodness) or one of the R,G, or B values does not take up much CPU-time, applying it to values in the HSV or HLS colour-spaces could risk grinding your game to a halt.
AE.
Wow, I never expected so much... discusson about this. Anyway, my brother is doing the backround now, as well as the characters and blocks, so my problem is solved for now. (He's really good at art.
)
You can do some pretty nifty psychedelic backgrounds using the good 'ol 8-bit mode and cycling the palette
Most of those effects don't work to well with this game... I was wondering if I could use an image, tile it, and make it scroll diagonally or something. Would that work?
You can use the attached image, tile it and scroll it diagonally. I made it some time ago for the same purpose.
Wow, thank you! It fits the theme too!