Re: Multiple Sprites
Okay, you know how you do the int &blah = create_sprite(blah); or &blah = create_sprite(blah); thing? Well, is it possible to have multiple sprites active on the same integer?
i.e.
void main ( void )
{
int &blah = create_sprite(200, 200, 16, 341, 1);
&blah = create_sprite(200, 200, 16, 343, 1);
}
Or, what if you do something like this:
void main ( void )
{
int &blah = create_sprite(200, 200, 16, 341, 1);
// Conversation
fade_down();
&player_map = 601
load_screen();
draw_screen();
wait(100);
fade_up();
&blah = create_sprite(250, 250, 16, 343, 1);
}
Will the first sprite just carry over screens? Will the second sprite show up?
i.e.
void main ( void )
{
int &blah = create_sprite(200, 200, 16, 341, 1);
&blah = create_sprite(200, 200, 16, 343, 1);
}
Or, what if you do something like this:
void main ( void )
{
int &blah = create_sprite(200, 200, 16, 341, 1);
// Conversation
fade_down();
&player_map = 601
load_screen();
draw_screen();
wait(100);
fade_up();
&blah = create_sprite(250, 250, 16, 343, 1);
}
Will the first sprite just carry over screens? Will the second sprite show up?
Any sprite you make will not carry over screens, you have to do the thing I did with my summon file.
void main ()
{
script_attach(1000);
int &oldscreen = &player_map;
loop:
if (&oldscreen != &player_map)
{
//changed screens: remake the sprite
}
wait(1);
&oldmap = &player_map;
goto loop;
}
As for having sprites on the same integer.. No. The variable will take the number of the last created sprite. You can, however, use the variable to make one sprite, assign its properties and then create the next sprite using that variable. If you want to do something to that sprite, you can always give it a unique sp_gold() and use the get_sprite_with_this_brain(); in conjunction with checking its sp_gold amount.
void main ()
{
script_attach(1000);
int &oldscreen = &player_map;
loop:
if (&oldscreen != &player_map)
{
//changed screens: remake the sprite
}
wait(1);
&oldmap = &player_map;
goto loop;
}
As for having sprites on the same integer.. No. The variable will take the number of the last created sprite. You can, however, use the variable to make one sprite, assign its properties and then create the next sprite using that variable. If you want to do something to that sprite, you can always give it a unique sp_gold() and use the get_sprite_with_this_brain(); in conjunction with checking its sp_gold amount.
But what about after you change screens and the sprite is killed? Can you create another?
When you change screens, all sprites on that screen are killed including Dink's sprite.
I'm not sure what you mean, but you can do this:
int &crap;
//sprite 1
&crap = create_sprite(x,y,brain,seq,frame);
sp_script(&crap,"sample");
//sprite 2
&crap = create_sprite(x,y,brain,seq,frame);
sp_script(&crap,"sample2");
//note that if you try to call on the sprites using the &crap variable,
//only sprite 2 would be affected since it is the last
I'm not sure what you mean, but you can do this:
int &crap;
//sprite 1
&crap = create_sprite(x,y,brain,seq,frame);
sp_script(&crap,"sample");
//sprite 2
&crap = create_sprite(x,y,brain,seq,frame);
sp_script(&crap,"sample2");
//note that if you try to call on the sprites using the &crap variable,
//only sprite 2 would be affected since it is the last
That's not it. When the screen changes, the sprites don't go with it. So can I do this:
int &blah
&blah = create_sprite(x, y, brain, seq, frame);
// Fade down, screen change etc.
&blah = create_sprite(x, y, brain, seq, frame);
Since the first &blah sprite died with the screen change, will the second sprite show?
int &blah
&blah = create_sprite(x, y, brain, seq, frame);
// Fade down, screen change etc.
&blah = create_sprite(x, y, brain, seq, frame);
Since the first &blah sprite died with the screen change, will the second sprite show?
As long as it's after the screen change it should be fine.
Oh, good. Thankyou! Heh, it seems our conversation went a bit awry.

Every time you do "&var = number" the variable is now that number and "forgets" what it was before, so you can use it for different things but if you create a few sprites the variable will only refer to the last one.
Example from my D-Mod:
void main(void)
{
int &bug;
&bug = create_sprite(120, 99, 9, 131, 1);
sp_script(&bug, "v23-bug");
&bug = create_sprite(63, 147, 9, 133, 1);
sp_script(&bug, "v23-bug");
&bug = create_sprite(101, 233, 9, 131, 1);
sp_script(&bug, "v23-bug");
&bug = create_sprite(111, 316, 9, 131, 1);
sp_script(&bug, "v23-bug");
&bug = create_sprite(182, 185, 9, 133, 1);
sp_script(&bug, "v23-bug");
//etc...
}
That makes a load of different bugs all with the same script attached but I'd have to give each it's own variable if I wanted to do something with them later.
Example from my D-Mod:
void main(void)
{
int &bug;
&bug = create_sprite(120, 99, 9, 131, 1);
sp_script(&bug, "v23-bug");
&bug = create_sprite(63, 147, 9, 133, 1);
sp_script(&bug, "v23-bug");
&bug = create_sprite(101, 233, 9, 131, 1);
sp_script(&bug, "v23-bug");
&bug = create_sprite(111, 316, 9, 131, 1);
sp_script(&bug, "v23-bug");
&bug = create_sprite(182, 185, 9, 133, 1);
sp_script(&bug, "v23-bug");
//etc...
}
That makes a load of different bugs all with the same script attached but I'd have to give each it's own variable if I wanted to do something with them later.
Okay. So if you attach a script to the sprite, you can use the &blah again?
Yep. &blah has no actual connection to the sprite itself, it just stores the sprite number so if you create another sprite using &blah it will store the new number and only affect that new sprite when you use sp_whatever. You can use it later for anything else you'd use a variable for, as well.
Thank you! That's exactly what I wanted to know!
*Hugs Sparrowhawk*
