Page 151 - 완) I MDP 프로젝트 작품 보고서(전체과 1학년)1.6
P. 151
pin_change.attach_pin_change_int(9,HIGH,ri case 3:
ght); direction = 0;
} break;
}
button = 0;
unsigned long cnt = 0; }
void timer_func(unsigned char id) if ( button == 2 )
{ {
if( id == 200 ) switch (direction)
{ {
if ( playing == true ) case 0:
{ direction = 3;
if ( eat_display_on == true ) break;
{ case 1:
matrix.set_dot(eat_x, eat_y, LOW); direction = 2;
eat_display_on = false; break;
} case 2:
else direction = 0;
{ break;
matrix.set_dot(eat_x, eat_y, HIGH); case 3:
eat_display_on = true; direction = 1;
} break;
} }
MDP_timer.set_timer(200,100); button = 0;
} }
if( id == 100)
{ int new_x = snake_xy[0][0];
if ( button == 1 ) int new_y = snake_xy[0][1];
{
switch (direction) switch( direction )
{ {
case 0: case 0:
direction = 2; new_y--;
break; if( new_y < 0 ) new_y = 7;
case 1: break;
direction = 3; case 1:
break; new_y++;
case 2: if( new_y > 7 ) new_y = 0;
direction = 1; break;
break; case 2:
- 144 -