The Dink Network

X y movement commands

May 31st 2012, 01:00 PM
knights.gif
merder
Peasant He/Him Netherlands
The Voice in the back of your head! 
been trying to work it out but sofar i just can't get the boss to get to the right place with the commands so i was wondering what is the best command setup to get a sprite to X:315 Y:100?(the rest of the boss works properly that is the only part i screwed up. so if anyone can help me getting those commands under control I know I can get the boss to work.
May 31st 2012, 02:21 PM
wizardg.gif
leprochaun
Peasant He/Him Japan bloop
Responsible for making things not look like ass 
Look for an sp_move(); command. I think there's something like that. Sorry I don't know these things off the top of my head.
May 31st 2012, 02:26 PM
pillbug.gif
pillbug
Peasant He/Him United States
Love! True love! 
I'm assuming the difficulty is coming from having the boss go to those coordinates from any point on the screen?
I would suggest creating a sprite at those coordinates and using sp_follow(&boss, &sprite); Something like this:

//Wherever you have the previous move() commands at
int &sprite = create_sprite(315, 100, 0, 80, 24);
//Above sprite is the stone statue head thingy
set_smooth_follow(1);
sp_follow(¤t_sprite, &sprite);


The boss won't go to those exact coordinates, it will go a bit off of the statue, so experiment with the statue's coordinates to get the boss right where you want him.

EDIT:
If I'm way off here and you're just trying to get him move, use:
freeze(&current_sprite);
move_stop(&current_sprite, <dir>, <coordinate>, 1);


<dir> is a number from 1-9, and it's based on the numpad. 2 is down, 4 is left, 6 is right, 8 is up, and the rest are diagonal directions.

<coordinate> is the X or Y coordinate you want him to move to. So if you have him move right (6), you would use an X coordinate.

The last number is whether or not the sprite can move through hardness, 1 being yes and 0 being no.
May 31st 2012, 05:04 PM
dinkdead.gif
"I would suggest creating a sprite at those coordinates and using sp_follow(&boss, &sprite);"

A probably better* way is just to move him in the right direction depending on where he is on the screen:

int &x = sp_x(&boss, -1);
int &y = sp_y(&boss, -1);

//might need adjusting if you need him to path around objects:

if (&x < 315)
{
 move_stop(&boss, 6, 315, 1);
}
else
{
 move_stop(&boss, 4, 315, 1);
}

if (&y < 100)
{
 move_stop(&boss, 2, 100, 1);
}
else
{
 move_stop(&boss, 8, 100, 1);
}

//and then if you need it to be exact:
sp_x(&boss, 315);
sp_y(&boss, 100);


Edit: *By better, I mean more accurate. Pillbug's way might look nicer
June 1st 2012, 12:01 AM
spike.gif
Also, you don't really need to bother with the if stuff... Just moving him in all directions will work fine:
move_stop(&boss, 6, 315, 1);
move_stop(&boss, 4, 315, 1);
move_stop(&boss, 2, 100, 1);
move_stop(&boss, 8, 100, 1);
June 1st 2012, 12:58 AM
pillbug.gif
pillbug
Peasant He/Him United States
Love! True love! 
Yeah, but simplicity is too complicated.
June 1st 2012, 02:39 AM
dinkdead.gif
Oh, yeah...
June 1st 2012, 05:41 AM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
Scratcher, does that actually work with a move_stop() command? Won't the script hang if it can't execute it since it's a command that pauses the script until the condition is reached? I haven't tried it though and have always done it the long, conditional way, but if that works, jeez, would have saved me a lot of time
June 1st 2012, 06:13 AM
dinkdead.gif
It does work, because move_stop() pauses the script until the condition is reached or exceeded. So if the x/y is already more than stated in the command, it just won't do anything.
June 1st 2012, 06:13 AM
custom_skull.gif
Skull
Peasant He/Him Finland bloop
A Disembodied Sod 
It works. I've always done it that way.

EDIT: Dammit, Sparrowhawk!!
June 1st 2012, 07:50 AM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
Oh wow xD Nice example of Dink's limits actually working in favor of the scripter
June 1st 2012, 01:21 PM
knights.gif
merder
Peasant He/Him Netherlands
The Voice in the back of your head! 
Thanks guys will try the suggestions later and see what works the best and when they work properly will do the finishing touches on boss no 3(second one is a summoner who'm is immune when minnions are spawned(simply using counters to check HP instead of HP system(upside noneed of defensive math downside no official way of telling the damage given)
June 2nd 2012, 05:00 PM
custom_iplaydink.gif
iplaydink
Peasant He/Him Sweden
Hmm.. 
"Also, you don't really need to bother with the if stuff... Just moving him in all directions will work fine:"

Duck! You tell me that NOW? XD