Reply to Sight
If you don't have an account, just leave the password field blank.
Horray, the sprites can see!
Took me most of the day to rig up the self-refrencing sight box, but the applications are endless
The code below has the sprite exclaim when he sees Dink, but it could easily be adapted for enemies or NPC interaction. Could be made better if it didn't use the random callback, but works well enough otherwise.
void main ( void )
{
set_callback_random("target",100,500);
}
void target ( void )
{
set_callback_random("target",100,500);
//Dinks stuff int &dx = sp_x( 1, -1 ); int &dy = sp_y( 1, -1 );
//self info
int &x = sp_x(¤t_sprite, -1);
int &y = sp_y(¤t_sprite, -1);
//set up box
&x -= 200; int &selfxA = &x;
&y -= 200; int &selfyA = &y;
&x += 400; int &selfxB = &x;
&y += 400; int &selfyB = &y;
//reset x and y
&x -= 200;
&y -= 200;
//sight
int &in = inside_box( &dx, &dy, &selfxA,&selfyA, &selfxB,&selfyB );
if (&in == 1)
{
say("It's Dink", ¤t_sprite);
}
}
void talk ( void )
{
say("&x &y &dx &dy &selfxA &selfyA &selfxB &selfyB", ¤t_sprite);
set_callback_random("target",100,500);
}
Not sure if this has been done before, haven't seen anything describing it though.
Took me most of the day to rig up the self-refrencing sight box, but the applications are endless
The code below has the sprite exclaim when he sees Dink, but it could easily be adapted for enemies or NPC interaction. Could be made better if it didn't use the random callback, but works well enough otherwise.
void main ( void )
{
set_callback_random("target",100,500);
}
void target ( void )
{
set_callback_random("target",100,500);
//Dinks stuff int &dx = sp_x( 1, -1 ); int &dy = sp_y( 1, -1 );
//self info
int &x = sp_x(¤t_sprite, -1);
int &y = sp_y(¤t_sprite, -1);
//set up box
&x -= 200; int &selfxA = &x;
&y -= 200; int &selfyA = &y;
&x += 400; int &selfxB = &x;
&y += 400; int &selfyB = &y;
//reset x and y
&x -= 200;
&y -= 200;
//sight
int &in = inside_box( &dx, &dy, &selfxA,&selfyA, &selfxB,&selfyB );
if (&in == 1)
{
say("It's Dink", ¤t_sprite);
}
}
void talk ( void )
{
say("&x &y &dx &dy &selfxA &selfyA &selfxB &selfyB", ¤t_sprite);
set_callback_random("target",100,500);
}
Not sure if this has been done before, haven't seen anything describing it though.







