// Frantick.cmm - silly CEnvi program to bounce an asterisk around the screen // find out how big the screen is MaxRow = ScreenSize().row - 1; MaxCol = ScreenSize().col - 1; // get a random initial position for the bouncy asterisk srand(); OldRow = rand() % (MaxRow + 1); OldCol = rand() % (MaxCol + 1); // clear the screen to start with a fesh slate ScreenClear(); while ( !kbhit() ) { // draw new dots and erase old ones forever do { // calculate new row, so long as it is in bounds Row = OldRow + (rand() % 3) - 1; } while( Row < 0 || MaxRow < Row ); do { // calculate new column, so long as it is in bounds Col = OldCol + (rand() % 3) - 1; } while( Col < 0 || MaxCol < Col ); SafePutchar(' ',OldRow,OldCol); SafePutchar('*',OldRow = Row,OldCol = Col); } SafePutchar(c,row,col) // just like putchar, but won't write into lower-right corner { // so we don't get accidental scrolling ScreenCursor(col,row); if ( row != MaxRow || col != MaxCol ) { putchar(c); } ScreenCursor(col,row); } // flush the keyboard while( kbhit() ) getch();