int main() { rConnect("/dev/rfcomm0"); int numMoves = 8; // the number of moves that the Scribbler will do. int i; // the various speeds and times in two seperate arrays double speed[] = {.3, .2, .4, 1, 1, .3, .2, .5}; double time[] = {.3, 1, .6, .1, 1, .9, .3, .8}; // go forward and turn for the various speeds and times given by the two arrays for (i = 0; i < numMoves; i++) { rForward (speed[i], time[i]); rTurn (speed[i], time[i]); } // beep when done rBeep (1, 500); rDisconnect(); return 0; } // main
void game(int sock) { int i; char *cmd[5]; for(i = 0; i < 5; i++){ cmd[i] = (char *)malloc(sizeof(char) * 50); } char buf[SIZE_BUF]; while(cmd[1] != CMD_EXIT){ read(sock, buf, SIZE_BUF); split(buf, cmd); if(!strcmp(cmd[0], "MSG")){ printf("%s\n", cmd[1]); }else{ switch(cmd[1][0]){ case ISET: rSet(cmd); break; case IEMPTY: rEmpty(cmd); break; case IHIT: rHit(cmd); break; case ITURN: rTurn(sock); break; } } } }