#include "lib.h" #define N 5 rect cabin(1,1,8,8); rect engine(9,5,4,4); rect back_wheel(2,9,2,2); rect front_wheel(10,9,2,2); text message( 6, 15, "press: return + ... + return + other ch + return" ); figure* part[N] = { &cabin, &engine, &back_wheel, &front_wheel, &message }; int main(){ int cnt = 0, distance = 4; clear_screen(); for(int i = 0; i < N; i++ ){ part[i]->draw(); } while( getch() == '\n' ){ if( distance > 0 ){ for(int i = N-2; i >= 0; i-- ){ part[i]->move(distance, 0); } } else { for(int i = 0; i < N-1; i++ ){ part[i]->move(distance, 0); } } if( ++cnt == 10 ){ cnt = 0; distance = -distance; } } return 0; }