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 kwadrat {
- double x = 0;
- double y = 0;
- };
- int main()
- {
- kwadrat k;
- k.x = 0.5;
- k.y = 0.5;
- float ruch_y = 0.03;
- float ruch_x = 0.02;
- HANDLE h = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL);
- DWORD test;
- wchar_t*buffer = new wchar_t[120 * 60];
- SetConsoleActiveScreenBuffer(h);
- while (1) {
- for (int i = 0; i <= 100; i++) {
- if (k.x > 1 || k.x < 0 || k.y > 1 || k.y < 0) {
- ruch_x *= -1;
- ruch_y *= -1;
- }
- k.x += ruch_x;
- k.y += ruch_y;
- for (int i = 0; i < 60 * 120; i++)
- buffer[i] = ' ';
- int x = k.x * 100;
- int y = k.y * 100;
- buffer[x+y*60] = '*';
- WriteConsoleOutputCharacter(h, buffer, 120 * 60, { 0,0 }, &test);
- Sleep(50);
- }
- }
- std::cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement