Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <conio.h>
- #include <graphics.h>
- #include <stdlib.h>
- #include <time.h>
- void Draw (int x,int y){
- setcolor(8);
- // Îòðèñîâêà îêíà
- moveto(x+6,y+8);
- lineto(x+10,y+8);
- lineto(x+10,y+14);
- lineto(x+6,y+14);
- lineto(x+6,y+8);
- moveto(x+8,y+8);
- lineto(x+8,y+14);
- moveto(x+8,y+10);
- lineto(x+10,y+10);
- // Îòðèñîâêà ñòåí
- moveto(x+2,y+6);
- lineto(x+14,y+6);
- lineto(x+14,y+16);
- lineto(x+2,y+16);
- lineto(x+2,y+6);
- // Îòðèñîâêà êðûøè
- moveto(x,y+8);
- lineto(x+8,y);
- lineto(x+16,y+8);
- }
- void Move() {
- int x=5,y=10;
- initwindow(500,500);
- while(1){
- Draw(x,y);
- switch (getch()) {
- case 72: y-=2; break; // Ââåðõ
- case 75: x-=2; break; // Âëåâî
- case 77: x+=2; break; // Âïðàâî
- case 80: y+=2; break; // Âíèç
- }
- cleardevice();
- }
- }
- /*void AutoMove() {
- int x=5,y=10;
- initwindow(500,500);
- srand(time(NULL));
- Draw(x,y);
- while (1) {
- switch (rand()%1) {
- case 0:
- Draw(x,y);
- delay(5);
- x++;
- cleardevice();
- case 1:
- Draw(x,y);
- delay(5);
- y++;
- cleardevice();
- }
- }
- }*/
- main() {
- initwindow(325,105);
- setcolor(15);
- outtextxy(5,10,"1. Ñâîáîäíîå äâèæåíèå îáúåêòà");
- outtextxy(5,42,"2. Äâèæåíèå îáúåêòà ñ ïîìîùüþ êëàâèàòóðû");
- outtextxy(5,74,"3. Âûõîä èç ïðîãðàììû");
- while(1){
- switch(getch()){
- // case 49: AutoMove(); break;
- case 50: Move(); break;
- case 51: closegraph();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement