91
double thisangle[MAXSTACK];
long curstack;
long stacknew;
long pensize[MAXSTACK];
long stack_x[MAXSTACK], stack_y[MAXSTACK];
} t_max_jit_turtle;
void *max_jit_turtle_new(t_symbol *s, long argc, t_atom *argv);
void max_jit_turtle_free(t_max_jit_turtle *x);
void max_jit_turtle_assist(t_max_jit_turtle *x, void *b, long m, long a, char *s);
void max_jit_turtle_bang(t_max_jit_turtle *x); // does nothing
void max_jit_turtle_int(t_max_jit_turtle *x, long n); // this is where the QD stuff is interpreted
void max_jit_turtle_reset(t_max_jit_turtle *x); // resets the turtle's state
void *max_jit_turtle_class;
void main(void)
{
long attrflags;
void *p,*attr;
setup(&max_jit_turtle_class, max_jit_turtle_new, (method)max_jit_turtle_free, (short)sizeof(t_max_jit_turtle),
0L, A_GIMME, 0);
p = max_jit_classex_setup(calcoffset(t_max_jit_turtle,obex));
attrflags = JIT_ATTR_GET_DEFER_LOW | JIT_ATTR_SET_USURP_LOW ;
// origin -- where to start drawing from (or reset to with a 'reset' message)
attr = jit_object_new(_jit_sym_jit_attr_offset_array,"origin",_jit_sym_long,2,attrflags,
(method)0,(method)0,calcoffset(t_max_jit_turtle,origincount),calcoffset(t_max_jit_turtle,origin));
max_jit_classex_addattr(p,attr);
// angle -- angle factor for turning the turtle
attr = jit_object_new(_jit_sym_jit_attr_offset,"angle",_jit_sym_long,attrflags,
(method)0,(method)0,calcoffset(t_max_jit_turtle,angle));
max_jit_classex_addattr(p,attr);
// scale -- stepsize for moving the turtle
attr = jit_object_new(_jit_sym_jit_attr_offset,"scale",_jit_sym_long,attrflags,
(method)0,(method)0,calcoffset(t_max_jit_turtle,scale));
max_jit_classex_addattr(p,attr);
// clearmode -- send a clear on reset or not
attr = jit_object_new(_jit_sym_jit_attr_offset,"clearmode",_jit_sym_long,attrflags,
(method)0,(method)0,calcoffset(t_max_jit_turtle,clearmode));
max_jit_classex_addattr(p,attr);
addmess((method)max_jit_turtle_reset, "reset", A_GIMME,0);
max_jit_classex_standard_wrap(p,NULL,0);
addmess((method)max_jit_turtle_assist, "assist", A_CANT,0);
addbang((method)max_jit_turtle_bang);
addint((method)max_jit_turtle_int);
max_jit_class_addmethods(jit_class_findbyname(gensym("jit_turtle")));
}
void max_jit_turtle_bang(t_max_jit_turtle *x)
{
// pontificate here...
post("HEY, YOU! STOP BANGING THE TURTLE!!!");
}
void max_jit_turtle_int(t_max_jit_turtle *x, long n)
{
t_atom a[16];
double tempangle;
double temp_x, temp_y;
long dest_x, dest_y;
long curstack = x->curstack;
x->command = n; // why do we do this? i can't remember...
// check to see if the integer received matches the ASCII code for one of these commands.
// if so, compute the appropriate QuickDraw response and pass it out the outlet as a Max message.
switch(n) {
case (35): // '#' - increase pen size
x->pensize[curstack] = x->pensize[curstack]+1;