Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <conio.h>
- #include <math.h>
- #include <time.h>
- #include "windows.h"
- using namespace std;
- void Tresc_projektu();
- void wczyt_dane();
- void rysuj(int x , int y);
- void sterowanie(int x, int y, int klawisz);
- void gotoxy(int x, int y)
- {
- COORD c;
- c.X = x;
- c.Y = y;
- SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c);
- }
- int wherex()
- {
- CONSOLE_SCREEN_BUFFER_INFO csbi;
- GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
- return csbi.dwCursorPosition.X;
- }
- int wherey()
- {
- CONSOLE_SCREEN_BUFFER_INFO csbi;
- GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
- return csbi.dwCursorPosition.Y;
- }
- void HideCursor()
- {
- ::HANDLE hConsoleOut = ::GetStdHandle(STD_OUTPUT_HANDLE);
- ::CONSOLE_CURSOR_INFO hCCI;
- ::GetConsoleCursorInfo(hConsoleOut, &hCCI);
- hCCI.bVisible = FALSE;
- ::SetConsoleCursorInfo(hConsoleOut, &hCCI);
- }
- void Tresc_projektu()
- {
- cout << endl;
- cout << endl;
- cout << "Napisz program rysowania znakiem ASCII ponizszej figury." << endl;
- cout << "Program powinien umozliwic:" << endl;
- cout << "- Wybor znaku kodu ASCII;" << endl;
- cout << "- wczytanie poczatkowych rozmiarow figury;" << endl;
- cout << "- przesuwanie figury za pomoca strzalek;" << endl;
- cout << "- powiekszanie oraz zmniejszanie rozmiaru " << endl;
- cout << " figury za pomoca klawiszy + i -;" << endl;
- cout << "- ograniczenie przesuwania i rozmiarow figury" << endl;
- cout << " do obszaru ekranu;" << endl;
- cout << endl;
- cout << endl;
- cout << endl;
- cout << endl;
- }
- void rysuj(int x, int y)
- {
- int wysokosc,x,y;
- char znak;
- system("cls");
- int W, i, j;
- for (i = wysokosc; i >= 1; i--)
- {
- for (j = wysokosc; j >= 1 + i; j--)
- {
- cout << " ";
- }
- cout << znak;
- for (W = 1; W < i; W++)
- {
- cout << " ";
- }
- cout << znak;
- cout << "\n";
- }
- for (i = 1; i <= wysokosc; i++)
- {
- for (j = 1; j <= wysokosc - i; j++)
- {
- cout << " ";
- }
- cout << znak;
- for (W = 1; W < i; W++)
- {
- cout << " ";
- }
- cout << znak;
- cout << "\n";
- }
- }
- void sterowanie(int x, int y , char klawisz)
- {
- int x, y, esq = EXIT_SUCCESS;
- char klawisz;
- do{
- _getch();
- switch (klawisz)
- {
- case 75: { x--; break; } // przesuniecie w lewo
- case 77: { x++; break; } // przesuniecie w prawo
- case 72: { y--; break; } // przesuniecie do gory
- case 80: { y++; break; } // przesuniecie do dolu
- }
- } while (klawisz != esq);
- rysuj(x,y);
- }
- void wczyt_dane(char znak, int wysokosc)
- {
- char znak;
- int wysokosc;
- cout << "podaj znak ktorym chcesz rysowac figure : \n";
- cin >> znak;
- cout << endl;
- cout << "Podaj poczatkowa wyskosc figory (minimalnie 3) : \n"; //prosba o wprowadzenie poczatkowej wysokosci figury. minimalnie 3 ze wzgledow estetycznych. gdyby było mniej niz 3 to figura by nie przypominala odwroconej litery "k".
- cin >> wysokosc;
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- char znak;
- int wysokosc , x ,y;
- Tresc_projektu();
- cout << "\n\n\n";
- wczyt_dane(znak, wysokosc);
- HideCursor();
- rysuj(x, y);
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement