The Dink Network

Re: Multiple Sprites

October 26th 2007, 09:53 PM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
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?
October 26th 2007, 10:05 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
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.
October 26th 2007, 11:03 PM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
But what about after you change screens and the sprite is killed? Can you create another?
October 26th 2007, 11:28 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
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
October 26th 2007, 11:32 PM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
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?
October 26th 2007, 11:35 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
As long as it's after the screen change it should be fine.
October 27th 2007, 12:47 AM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
Oh, good. Thankyou! Heh, it seems our conversation went a bit awry.
October 27th 2007, 03:17 PM
dinkdead.gif
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.
October 27th 2007, 09:28 PM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
Okay. So if you attach a script to the sprite, you can use the &blah again?
October 27th 2007, 10:07 PM
dinkdead.gif
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.
October 27th 2007, 10:09 PM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
Thank you! That's exactly what I wanted to know! *Hugs Sparrowhawk*