PDA

View Full Version : Rain



pkmnfrk
04-25-2009, 09:44 PM
To prove that I'm not all washed up, here's something wetter than normal:


int rain_drops[600];
ffc script Rain {
void run(int density, int col, int lay) {

init(density);

for(int i = 0; i < 200; i++) {
update(density);
}

while(true) {
update(density);
draw(density, col, lay);
Waitframe();
}

}

void init(int density) {
for(int i = 0; i < 3 * density; i+=3) {
rain_drops[i] = Rand(256); //x position
rain_drops[i + 1] = 0; //y position
rain_drops[i + 2] = Rand(176); //"z" (actually y termination)
}
}

void update(int density) {
for(int i = 0; i < 3 * density; i+=3) {
if(rain_drops[i + 2] == -1) {
rain_drops[i] = Rand(256);
rain_drops[i + 1] = 0;
rain_drops[i + 2] = Rand(176);
} else if(rain_drops[i + 1] >= rain_drops[i + 2]) {
rain_drops[i + 2] = -1;
} else {
rain_drops[i + 1] += 2;
}
}
}

void draw(int density, int col, int lay) {
for(int i = 0; i < 3 * density; i+=3) {
if(rain_drops[i + 2] == -1) {
Screen->Line(lay, rain_drops[i] - 1, rain_drops[i + 1] - 1, rain_drops[i] - 2, rain_drops[i + 1] - 2, col, 1, 0, 0, 0, 128);
Screen->Line(lay, rain_drops[i] + 1, rain_drops[i + 1] - 1, rain_drops[i] + 2, rain_drops[i + 1] - 2, col, 1, 0, 0, 0, 128);
} else {
Screen->Line(lay, rain_drops[i], rain_drops[i + 1], rain_drops[i], rain_drops[i + 1] + 1, col, 1, 0, 0, 0, 128);
}
}
}
}

- D0: density of rain. The higher this number, the more rain drops there will be on screen (and the more lag, etc). Max is 200, but if you're brave, you can increase the size of that array and add more (the array must be at least 3 times the number of rain drops you want)
- D1: colour. Looks best with white drops, which is usually palette entry #1.
- D2: layer. Probably looks best on Layer 5 or 6, so that it appears on top of everything.

Combine with the Lightning script (http://armageddongames.net/forums/showthread.php?t=105566) and suitable music (http://www.vgmusic.com/music/console/nintendo/snes/Night798.mid) for maximum effect.

Archangel
04-25-2009, 11:10 PM
Nice, I can use this in the intro for my current quest which needs a sad atmosphere.

On a related note, I figured out a way to fix armos2 script of yours. Change it to an look alike armos combo that is a normal combo and cycles to the next combo when the armos is fully activated. Just come up with the timing right, and it should work.