Pushing and hardness.
This is the script:
void main( void )
{
sp_speed(¤t_sprite, 1);
int &mydir;
if(&stonem == 1)
{
sp_x(¤t_sprite, 344);
}
}
if(&stonem == 2)
{
sp_x(¤t_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(¤t_sprite, -1);
&save_y = sp_y(¤t_sprite, -1);
Playsound(59,11025,0,0,0);
move_stop(¤t_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(¤t_sprite, -1);
&save_y = sp_y(¤t_sprite, -1);
Playsound(59,11025,0,0,0);
move_stop(¤t_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.
void main( void )
{
sp_speed(¤t_sprite, 1);
int &mydir;
if(&stonem == 1)
{
sp_x(¤t_sprite, 344);
}
}
if(&stonem == 2)
{
sp_x(¤t_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(¤t_sprite, -1);
&save_y = sp_y(¤t_sprite, -1);
Playsound(59,11025,0,0,0);
move_stop(¤t_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(¤t_sprite, -1);
&save_y = sp_y(¤t_sprite, -1);
Playsound(59,11025,0,0,0);
move_stop(¤t_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.
Make the rock "not hard" in the editor, then
sp_hard(¤t_sprite, 0);
draw_hard_sprite(¤t_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(¤t_sprite, 1);
int &mydir;
if(&stonem == 1)
{
//that opened the if()
sp_x(¤t_sprite, 344);
}
//that closed the if()
}
//that closed main()
You might want to check the brackets also.
sp_hard(¤t_sprite, 0);
draw_hard_sprite(¤t_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(¤t_sprite, 1);
int &mydir;
if(&stonem == 1)
{
//that opened the if()
sp_x(¤t_sprite, 344);
}
//that closed the if()
}
//that closed main()
You might want to check the brackets also.
void main( void )
{
sp_speed(¤t_sprite, 1);
int &mydir;
if(&stonem == 1)
{
sp_x(¤t_sprite, 344);
}
if(&stonem == 2)
{
sp_x(¤t_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.
{
sp_speed(¤t_sprite, 1);
int &mydir;
if(&stonem == 1)
{
sp_x(¤t_sprite, 344);
}
if(&stonem == 2)
{
sp_x(¤t_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.
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(¤t_sprite, 1);
int &mydir;
// Remove current hardness
sp_hard(¤t_sprite, 1);
draw_hard_sprite(¤t_sprite);
if(&stonem == 1)
{
sp_x(¤t_sprite, 344);
}
if(&stonem == 2)
{
sp_x(¤t_sprite, 435);
}
// Draw new hardness
sp_hard(¤t_sprite, 0);
draw_hard_sprite(¤t_sprite);
}
void main( void )
{
sp_speed(¤t_sprite, 1);
int &mydir;
// Remove current hardness
sp_hard(¤t_sprite, 1);
draw_hard_sprite(¤t_sprite);
if(&stonem == 1)
{
sp_x(¤t_sprite, 344);
}
if(&stonem == 2)
{
sp_x(¤t_sprite, 435);
}
// Draw new hardness
sp_hard(¤t_sprite, 0);
draw_hard_sprite(¤t_sprite);
}
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)
(That's lots of "hardness" in just a few sentences)