The Dink Network

Pushing and hardness.

January 10th 2006, 05:16 PM
bonca.gif
Christiaan
Bard They/Them Netherlands
Lazy bum 
This is the script:

void main( void )
{
sp_speed(&current_sprite, 1);
int &mydir;

if(&stonem == 1)
{
sp_x(&current_sprite, 344);
}
}

if(&stonem == 2)
{
sp_x(&current_sprite, 435);
}
}

void push( void )
{
if (&strength < 3)
{
say("This rock is loose, but I can't seem to push it!", 1);
}
}

if (&strength > 2)
{
&mydir = sp_dir(1, -1);

if (&stonem == 1)
{
//rock is over hole

if (&mydir == 6)
{
freeze(1);
&save_x = sp_x(&current_sprite, -1);
&save_y = sp_y(&current_sprite, -1);
Playsound(59,11025,0,0,0);
move_stop(&current_sprite, 6, 435, 1);
unfreeze(1);
draw_hard_map();
&stonem = 2;

return;
}
}

if (&stonem == 2)
{
//rock has already been pushed, can we push it back?

if (&mydir == 4)
{
freeze(1);
&save_x = sp_x(&current_sprite, -1);
&save_y = sp_y(&current_sprite, -1);
Playsound(59,11025,0,0,0);
move_stop(&current_sprite, 4, 343, 1);
unfreeze(1);
draw_hard_map();
&stonem = 1;
return;
}
}
}
}

And this is my problem: When I push the rock in direction 6, the rock gets his new hardness. But when I leave the screen, en re-enter the screen, the hardness of the old location of the rock is there, and the new rock-location has no hardness. How can I fix this?

hehe... rock... hard... hehehehe.
January 10th 2006, 05:30 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
Make the rock "not hard" in the editor, then

sp_hard(&current_sprite, 0);
draw_hard_sprite(&current_sprite);

after sp_x() has been changed.

Instead of using &stonem (which I assume is a global), you might want to learn the editor_seq/editor_frame trick, unless the state of the rock matters in other scripts, of course

LATE ADDITION:

void main( void )
{
//that opened main()
sp_speed(&current_sprite, 1);
int &mydir;

if(&stonem == 1)
{
//that opened the if()
sp_x(&current_sprite, 344);
}
//that closed the if()
}
//that closed main()

You might want to check the brackets also.
January 10th 2006, 05:40 PM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
void main( void )
{
sp_speed(&current_sprite, 1);
int &mydir;

if(&stonem == 1)
{
sp_x(&current_sprite, 344);
}

if(&stonem == 2)
{
sp_x(&current_sprite, 435);
}
draw_hard_map();
}

Edit: There was an extra bracket in there, didn't notice that at first (grr magicman). Otherwise, I think my solution would work.
January 10th 2006, 05:45 PM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
Magicman: sort of. The problem is draw_hard_sprite() only affects hardness on the sprite's current location, so to properly work, you'd need to have a lot of overhead:

void main( void )
{
sp_speed(&current_sprite, 1);
int &mydir;

// Remove current hardness
sp_hard(&current_sprite, 1);
draw_hard_sprite(&current_sprite);

if(&stonem == 1)
{
sp_x(&current_sprite, 344);
}

if(&stonem == 2)
{
sp_x(&current_sprite, 435);
}

// Draw new hardness
sp_hard(&current_sprite, 0);
draw_hard_sprite(&current_sprite);
}
January 10th 2006, 05:58 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
Well, no. I suggested to remove the hardness in the editor ((Win)DinkEdit), and set the hardness after the x-coord has been changed. Since there's no hardness to begin with, changing sp_x() won't bring any hardness difficulties. Then making it hard, and draw_hard_sprite() would work.

(That's lots of "hardness" in just a few sentences)
January 10th 2006, 06:15 PM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
Ah... I thought you said to set hardness in the editor. Whoops, sorry 'bout that.