I am happy to say I got the snow to work wonderfully and this script, (attach to and decorative object on the screen), and a 600x400 bmp of randomly placed 2x2 white squares:
void main(void)
{
if (&snow == 1)
{
sp_size(¤t_sprite, 1);
sp_que(¤t_sprite, -2000);
int &direct
int &speed
int &asnow = create_sprite(420, -110, 9, 37, 1);
int &bsnow = create_sprite(420, 290, 9, 37, 1);
sp_que(&asnow, 500);
sp_que(&bsnow, 500);
freeze(&asnow);
freeze(&bsnow);
&speed = random(4,2);
sp_speed(&asnow, &speed);
sp_speed(&bsnow, &speed);
loop:
move(&asnow, 2, 290, 1);
move_stop(&bsnow, 2, 690, 1);
sp_y(&bsnow, -110);
move(&bsnow, 2, 290, 1);
move_stop(&asnow, 2, 690, 1);
sp_y(&asnow, -110);
goto loop;
}
}
The problem with this is that the snow can't move diagonally but I have solved that too for north-west movement, so for those that care I will show you:
first I hope you know that diag movement is as follows:
south-west 1
south-east 3
north-east 5
north-west 7
next is the placement of the 600x400 bmps which should go at both the start and mid locations then the mid bmp should move to the end place while the start one moves to the mid place. Then what is now the end bmp should be reoriented at the start point and then moved to the mid place while the current mid bmp is moved to the end and reoriented at star etc...
The locations are as follows:
Left Mid Diag
start x=1020 y=-110
mid x=620 y=290
end x=220 y=690
Left Bottom Diag
start x=1020 y=290
mid x=620 y=690
Left Top Diag
start x=420 y=-110
mid x=20 y=290
end x=-380 y=690
I hope some people understood and can use this. I can't claim credit for the scrolling 2 bmp scrolling snow thing because that is Dan Walma's ingenious idea, but the diagonal scrolling idea was mine please write "//by bdjnk" in the script any time you use this concept.
I hope this was worth the time it took to write, thanks for reading this far.
Even if you get this script to work I have a feeling that this would slow the processor down to a crawl. I've noticed that using create_sprite in rapid succession will do that. The fact that there is no wait() command in your loop and that would further complicate things.
If it turns out I'm right and the processor goes to crap, just stick with a single bitmap.
Sorry to point out, but I think your idea won't work.
First of all, there are several obvious mistakes in your script, such as
missing ";"
"==" instead of "=" in if statement
space before and after a = or < or >...
But the main problem of your idea is due to the restriction of Dink engine. You can only have at most 99 sprites in a certain screen. I believe your sp_seq(&ssprite, 37) is a small snow flake. Even 99 pieces of snow flake won't look any real. :( Maybe I was wrong about this... ;)
Even you correct all the obvious mistakes, your snow won't fall, because you create new snow flake in your loop at y=0. It will not get any time to fall.
Since I am also planning to have snowing scene in my DMOD-in-develop, I decided to exercise the possibility for more realistic snow. Here is my half-baked solution.
I'm using two 900x150 bmp for snow. Each bmp file has random white dots on a black backgroung.
put the following on dink.ini
load_sequence_now graphics\snow- 37 BLACK
SET_SPRITE_INFO 37 1 450 150 -225 -15 225 15
SET_SPRITE_INFO 37 2 450 150 -225 -15 225 15
I use two global : &snow and &wind
&snow (0 or 1) to decide snow or not
&wind (0 1 2) to add wind
The first script is for calling snow (snow.c), and the second script is for snow to fall (snow1.c). You and everyone else who is interested can use and/or modify the scripts. Just make sure to give mimifish his credit. :p ;)
// snow.c
void main( void )
{
int &crapnum;
// x starting place
int &randx;
int &ssprite;
&wind = random(3, 0);
snowing:
wait(1);
if (&snow == 0)
{
kill_this_task();
}
pending:
&crapnum = scripts_used();
if (&crapnum > 80)
{
wait(100);
goto pending;
}
wait(1);
&randx = random(400,200);
&ssprite = create_sprite(&randx, 0, 9, 37, 1);
sp_script(&ssprite, "snow1");
wait(1);
goto snowing;
kill_this_task();
}
-------------------------------------------------
// snow1.c
void main( void )
{
// wondering direction
int &randd;
// ending place
int &randy;
// wind
int &windmove;
// snow direction
int &snowdirec;
int &desty;
if (&snow == 1)
{
wait(1);
&randy = random(400,150);
sp_que(¤t_sprite, &randy);
sp_seq(¤t_sprite, 37);
sp_brain(¤t_sprite, 6);
sp_speed(¤t_sprite, 1);
sp_timing(¤t_sprite, 10);
sp_move_nohard(¤t_sprite, 1);
loop:
&randd = random(2,1);
if (&randd > 1)
{
move(¤t_sprite, 2, &randy, 1);
wait(1);
}
else
{
if (&wind == 1)
goto keepgoing;
&windmove = &wind;
&windmove * 300;
&randd = random(5,1);
if (&randd == 1)
{
// against wind
&windmove += 600;
if (&windmove > 600)
&windmove -= 1200;
}
&snowdirec = &windmove;
&snowdirec / 300;
&snowdirec += 4;
move(¤t_sprite, &snowdirec, &windmove, 1);
}
keepgoing:
if (&snow == 0)
{
sp_brain(¤t_sprite, 7);
wait(1);
kill_this_task();
}
&desty = sp_y(¤t_sprite, -1);
&desty += 10;
wait(1);
if (&desty > &randy)
{
sp_brain(¤t_sprite, 7);
wait(1);
kill_this_task();
}
goto loop;
}
kill_this_task();
}
: I made a script for snow that doesn't work, need help with it, here it is:
: void main(void)
: {
: if (&snow == 1)
: {
: //x starting place
: int &randx;
: //direction
: int &d
: //starting direction
: int &randd;
: //direction change
: int &randdc
: //direction change time
: int &randdct
: //ending place
: int &randy;
: //current sprite
: int &ssprite;
: wait(500);
: loop:
: &randy = random(400,100)
: &randx = random(640,0);
: &ssprite = create_sprite(&randx, 0, 0, 37, 1);
: sp_que(&ssprite, &randy);
: sp_seq(&ssprite, 37);
: sp_brain(&ssprite, 7);
: &randd = random(4,1);
: if(&randd=1)&d=4;
: if(&randd=2)&d=6;
: if(&randd>2)&d=8;
: move(&ssprite, &d, &randy, 1);
: if(&snow = 0) kill_this_task();
: goto loop;
: }
: }
: I did this because I didn't want to make one large set of bmp with lots of different flakes like redink1 did in his weather demonstration in his Weather Effects Demonstration because it looks unreal. if anyone has any other ideas on how to make snow or a reason why mine doesn't work tell me.
I din't bother reading over your whole script, but I notice that you have &randd and &randdc. There is a bug with the varriables that sometimes happens if one varriable (say &NO) and there is another that starts with the same letters/numbers as the previous variable( &NO1), one of the two won't work, don't ask which though. :) Just changing the name might help you, if theres nothing else is wrong. Also, put the int. varib's at the top I think... And don't forget, no more than one opperation per line. you can't go:
5-4+2=&rand
Have to do it this way:
5-4=&rann
&rann+2=&rand
Hope this helps.
Chrispy
Ps: Don't berate me on the signs :)