Example #1
0
File: score.c Project: Angeldude/pd
static void *score_new(t_symbol *s, t_floatarg fskipindex, t_floatarg fskiptime)
{
	int i;

    t_score *x = (t_score *)pd_new(score_class);
    x->x_invelo = inlet_new(&x->x_ob, &x->x_ob.ob_pd, gensym("float"), gensym("ft1"));
    x->x_inreset = inlet_new(&x->x_ob, &x->x_ob.ob_pd, gensym("bang"), gensym("reset"));
	x->x_outindex = outlet_new(&x->x_ob, gensym("float"));
	x->x_outerror = outlet_new(&x->x_ob, gensym("float"));

	x->x_sym = s;				/* get name of array */
	score_set(x,x->x_sym);      /* set array */
	if(!fskipindex)fskipindex = 2;
	if(!fskiptime)fskiptime = 300.0;
	x->x_skipindex = (t_int)fskipindex;
	x->x_skiptime = (t_float)fskiptime;
	post("score: skipindex set to %d, skiptime set to %g milliseconds", x->x_skipindex, x->x_skiptime);

	x->x_state = 0;				/* don't follow */
	x->x_error = 0;
	x->x_index = -1;
	x->x_notecount = 0;
	x->x_pitch = x->x_lastpitch = -1;
	for(i = 0; i < MAX_NOTES; i++)x->x_alloctable[i] = -1;

    return (void *)x;
}
Example #2
0
static void
leave_crash_mode (game_time t, void *client_data)
/* This function is a possible callback argument to `add_event'.
 * It switch control back to either `game_mode' or `highscore_mode'.
 * The arguments T and CLIENT_DATA are ignored.  */
{
  if (lives > 0) {
    mode_change (game_mode, 1);
  } else {
    score_set (score, level+1);
    mode_change (highscore_mode, 0);
  }
}