Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <Windows.h>
- using namespace std;
- struct punkt {
- double x = 0;
- double y = 0;
- };
- int w = 60;
- int h = 40;
- void rysuj(punkt *t) {
- HANDLE handle = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL);
- DWORD test;
- wchar_t * buffer = new wchar_t[w * h];
- SetConsoleActiveScreenBuffer(handle);
- for (int i = 0; i < w * h; i++) {
- buffer[i] = ' ';
- }
- int x = t->x * h;
- int y = t->y * w;
- buffer[x + y * h] = 'o';
- WriteConsoleOutputCharacter(handle, buffer, w * h, { 0,0 }, &test);
- Sleep(20);
- }
- int main()
- {
- punkt k;
- k.x = 0.5;
- k.y = 0.5;
- float ruch_y = 0.03;
- float ruch_x = 0.02;
- for (int i = 0; i <= 100; i++) {
- if (k.x >= 1 || k.x <= 0)
- ruch_x *= -1;
- if (k.y >= 1 || k.y <= 0)
- ruch_y *= -1;
- k.x += ruch_x;
- k.y += ruch_y;
- rysuj(&k);
- }
- std::cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement