The Dink Network

Reply to Re: Mkbul's code error thread

If you don't have an account, just leave the password field blank.
Username:
Password:
Subject:
Antispam: Enter Dink Smallwood's last name (surname) below.
Formatting: :) :( ;( :P ;) :D >( : :s :O evil cat blood
Bold font Italic font hyperlink Code tags
Message:
 
 
March 25th 2010, 07:47 AM
dinkdead.gif
It's worth a try doing it in a different script rather than in the touch procedure. Or a different part of the same script. Make a new global, for example &splashing, and try this:

void main (void)
{
  int &crap;
  sp_touch_damage(&current_sprite, -1);
}

void touch (void)
{
  if (&splashing == 0)
  {
    goto startsplash;
  }
}

void splash (void)
{
startsplash:
  &splashing = 1;
  //changing this variable makes sure that you won't start several loops running at the same time
  //change your graphics (init) etc here too
loop:
  &crap = random(10, 1);
  if (&crap == 5)
  {
    playsound(35, 17000, 0, 0, 0);
  }
  wait(100);
  if (&splashing == 1)
  {
    goto loop;
  }
  //change the graphics back to normal here
}


Doing it like this means you would need another sprite at the edge of the water to turn the global back to 0 so the splashing effect stops. Just this would do:

void main (void)
{
  sp_touch_damage(&current_sprite, -1);
}
void touch (void)
{
  &splashing = 0;
}