Пример #1
0
static unsigned long
rocks_draw (Display *dpy, Window window, void *closure)
{
  struct state *st = (struct state *) closure;
  if (st->current_delta != st->new_delta)
    {
      if (st->dchange_tick++ == 5)
	{
	  st->dchange_tick = 0;
	  if (st->current_delta < st->new_delta)
	    st->current_delta++;
	  else
	    st->current_delta--;
	}
    }
  else
    {
      if (! (random() % 50))
	{
	  st->new_delta = ((random() % 11) - 5);
	  if (! (random() % 10))
	    st->new_delta *= 5;
	}
    }
  tick_rocks (st, st->current_delta);

  return st->delay;
}
Пример #2
0
void
drawrock(Window win)
{
  static int current_delta = 0;	/* observer Z rotation */
  static int window_tick = 50;
  static int new_delta = 0;
  static int dchange_tick = 0;

  if (window_tick++ == 50)
    window_tick = 0;
  if (current_delta != new_delta) {
    if (dchange_tick++ == 5) {
      dchange_tick = 0;
      if (current_delta < new_delta)
        current_delta++;
      else
        current_delta--;
    }
  } else {
    if ((LRAND() % 50) == 0) {
      new_delta = ((LRAND() % 11) - 5);
      if ((LRAND() % 10) == 0)
	new_delta *= 5;
    }
  }
  tick_rocks (win, current_delta);
}