Allegro.cc - Online Community

Allegro.cc Forums » Game Design & Concepts » Hypnotic backgrounds

This thread is locked; no one can reply to it. rss feed Print
 1   2 
Hypnotic backgrounds
Kikaru
Member #7,616
August 2006
avatar

Well, the game I am currently working has... mesmerizing gameplay :o. 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?

Johan Halmén
Member #1,550
September 2001

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.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Years of thorough research have revealed that the red "x" that closes a window, really isn't red, but white on red background.

Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest.

Hard Rock
Member #1,547
September 2001
avatar

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.

_________________________________________________
Hard Rock
[ Stars Dev Company ][ Twitter ][Global Warming: ARA My TINS 07 Entry][Pong Ultra Website][GifAllegS Ver 1.07]
"Well there's also coolwebsearch but we'll let that be an IE exclusive feature" - arielb on the New Browser Plugins "What's better, HTML or Variables?"

Kikaru
Member #7,616
August 2006
avatar

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"?

Hard Rock
Member #1,547
September 2001
avatar

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.

_________________________________________________
Hard Rock
[ Stars Dev Company ][ Twitter ][Global Warming: ARA My TINS 07 Entry][Pong Ultra Website][GifAllegS Ver 1.07]
"Well there's also coolwebsearch but we'll let that be an IE exclusive feature" - arielb on the New Browser Plugins "What's better, HTML or Variables?"

Kikaru
Member #7,616
August 2006
avatar

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?

Erkle
Member #3,493
May 2003
avatar

I would probably do something similar to Worms' floating particle background.

If the writing above has offended you, you've read it wrong.....fool.
And if you read that wrong it means 'All of the above is opinion and is only to be treated as such.'

Kikaru
Member #7,616
August 2006
avatar

Do you have a screenshot of that? I don't remember exactly what it looked like.

Audric
Member #907
January 2001

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).

Johan Halmén
Member #1,550
September 2001

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.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Years of thorough research have revealed that the red "x" that closes a window, really isn't red, but white on red background.

Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest.

James Stanley
Member #7,275
May 2006
avatar

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 
4int 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 
14int randnum(int num) {
15 return rand()/(int)(((unsigned)RAND_MAX + 1) / (num+1));
16}

LennyLen
Member #5,313
December 2004
avatar

Quote:

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>

James Stanley
Member #7,275
May 2006
avatar

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.

Audric
Member #907
January 2001

The X / (Y / Z) has me worried because it's integer arithmetics.

Quote:

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:

Quote:

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!

Jonatan Hedborg
Member #4,886
July 2004
avatar

My mingw32 stdlib.h says:

#define  RAND_MAX  0x7FFF

Ie, 32767
:(

-------
Sweden: Free from the shackles of Democracy since 2008-06-18!

LennyLen
Member #5,313
December 2004
avatar

Quote:

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):

1#include <stdio.h>
2//#include <stdlib.h>
3 
4int randnum(int num) {
5 
6 return rand()/(int)(((unsigned)RAND_MAX + 1) / (num+1));
7 
8}
9 
10int main() {
11 
12 int n;
13
14 for (n = 0; n < 20; n++) printf("%d\n", randnum(100));
15 
16 return 0;
17 
18}

Quote:

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);
}

Quote:

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.

Audric
Member #907
January 2001

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.

Jonatan Hedborg
Member #4,886
July 2004
avatar

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.

-------
Sweden: Free from the shackles of Democracy since 2008-06-18!

James Stanley
Member #7,275
May 2006
avatar

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.

LennyLen
Member #5,313
December 2004
avatar

Quote:

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]

Quote:

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]

Quote:

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.

Quote:

I don't care about most of the errors since it was just a demonstration of my effect.

Great attitude. ::)

Audric
Member #907
January 2001

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.

LennyLen
Member #5,313
December 2004
avatar

Quote:

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.

Andrei Ellman
Member #3,434
April 2003

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.

--
Don't let the illegitimates turn you into carbon.

Kikaru
Member #7,616
August 2006
avatar

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. :))

Steve Terry
Member #1,989
March 2002
avatar

You can do some pretty nifty psychedelic backgrounds using the good 'ol 8-bit mode and cycling the palette :P

___________________________________
[ Facebook ]
Microsoft is not the Borg collective. The Borg collective has got proper networking. - planetspace.de
Bill Gates is in fact Shawn Hargreaves' ßî+çh. - Gideon Weems

 1   2 


Go to: