Skip to content

Instantly share code, notes, and snippets.

@MaratB
Created September 22, 2013 21:23
Show Gist options
  • Save MaratB/6663945 to your computer and use it in GitHub Desktop.
Save MaratB/6663945 to your computer and use it in GitHub Desktop.
#include <conio.h>
#include <graphics.h>
void Draw ( int x, int y, int color )
{
setfillstyle ( 1, color ); //сплошная заливка, цвет color
bar ( x, y, x+20, y+20 ); // залитый прямоугольник
}
main()
{
float x,y; // координаты квадрата
initwindow (400, 400);
setfillstyle(1, COLOR(0,0,255));
bar (0, 0, 400, 400);
x = 0; y = 0; // нач. координаты квадрата
while ( y + 20 < 400 || x+20 < 400 ) // пока не коснулся границы окна
{
if ( kbhit() ) // если нажата клавиша
if ( getch() == 27 ) break; // если Esc, выход из цикла
Draw ( x, y, COLOR(255,255,0) ); // рисуем желтый квадрат
delay ( 10 ); // смотрим на него (задержка)
Draw ( x, y, COLOR(0,0,255) ); // стираем
y ++;
x ++; // перемещаем
}
getch();
closegraph();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment