Загрузка...

Матрица, Нео курит в сторонке

Тема в разделе C/C++ создана пользователем alsoso_guru 4 окт 2023. 114 просмотров

  1. alsoso_guru
    alsoso_guru Автор темы 4 окт 2023 12 30 сен 2023
    Как то надоели мне эти все мемы от суетологов от dis/s , что я решил создать реальную матрицу:BrainCosmic:
    Становитесь хакерами в чужих глазах - на здоровье:duck_like:

    (Далее C++)Сама матрица (ТЫК) в виде приложения готового.

    C
    #include <Windows.h>
    #include <vector>
    #include <string>
    #include <random>


    const int DIGIT_SIZE = 20;
    const int MAX_DIGITS = 200; //количество на экране
    const float DISTANCE_THRESHOLD = 150.0f;
    const float INTERPOLATION_FACTOR = 0.1f;
    int screenWidth = GetSystemMetrics(SM_CXSCREEN);
    int screenHeight = GetSystemMetrics(SM_CYSCREEN);
    struct DigitInfo {
    int x;
    int y;
    int speed;
    std::wstring text;
    };

    std::vector<DigitInfo> digits;
    POINT cursorPos;

    LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
    switch (msg) {
    case WM_CREATE: {
    SetTimer(hwnd, 1, 30, NULL);
    break;
    }
    case WM_PAINT: {
    PAINTSTRUCT ps;
    HDC hdc = BeginPaint(hwnd, &ps);

    // Получение размеров клиентской области окна
    RECT clientRect;
    GetClientRect(hwnd, &clientRect);
    int screenWidth = clientRect.right - clientRect.left;
    int screenHeight = clientRect.bottom - clientRect.top;

    // Установка черного фона
    HBRUSH hBrush = CreateSolidBrush(RGB(0, 0, 0));
    FillRect(hdc, &ps.rcPaint, hBrush);
    DeleteObject(hBrush);

    // Установка темно-зеленого цвета для цифр
    SetTextColor(hdc, RGB(0, 128, 0));

    // Отрисовка цифры
    for (const auto& digit : digits) {
    if (digit.y < screenHeight) {
    SetBkMode(hdc, TRANSPARENT);
    TextOut(hdc, digit.x, digit.y, digit.text.c_str(), digit.text.length());
    }
    }

    EndPaint(hwnd, &ps);
    break;
    }

    case WM_TIMER: {
    // Получение текущих координат курсора
    GetCursorPos(&cursorPos);
    ScreenToClient(hwnd, &cursorPos);

    // Генерация новой цифры при необходимости
    if (digits.size() < MAX_DIGITS) {
    DigitInfo digit;
    digit.x = rand() % (screenWidth - DIGIT_SIZE);
    digit.y = -(rand() % (screenHeight - DIGIT_SIZE));

    digit.speed = rand() % 3 + 1;
    digit.text = std::to_wstring(rand() % 10);

    digits.push_back(digit);
    }

    // Обновление позиции и скорости цифры
    for (auto& digit : digits) {
    digit.y += digit.speed;
    if (digit.y >= screenHeight) {
    // Удаление цифры, если она достигла или превысила нижнюю границу экрана
    digits.erase(digits.begin());
    }

    else {
    // Отталкивание от курсора
    float dx = digit.x - cursorPos.x;
    float dy = digit.y - cursorPos.y;
    float distance = sqrt(dx * dx + dy * dy);
    if (distance < DISTANCE_THRESHOLD) {
    float directionX = dx / distance;
    float directionY = dy / distance;
    digit.x += static_cast<int>(directionX * (DISTANCE_THRESHOLD - distance) * INTERPOLATION_FACTOR);
    digit.y += static_cast<int>(directionY * (DISTANCE_THRESHOLD - distance) * INTERPOLATION_FACTOR);
    }
    }
    }
    // Перерисовка окна
    InvalidateRect(hwnd, NULL, FALSE);
    break;
    }
    case WM_DESTROY: {
    PostQuitMessage(0);
    break;
    }
    default: {
    return DefWindowProc(hwnd, msg, wParam, lParam);
    }
    }

    return 0;
    }

    int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) {
    // Регистрация класса окна
    const wchar_t CLASS_NAME[] = L"MyWindowClass";

    WNDCLASS wc{};
    wc.hInstance = hInstance;
    wc.lpszClassName = CLASS_NAME;
    wc.lpfnWndProc = WndProc;
    wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); // Устанавливаем черный фон

    RegisterClass(&wc);

    // Создание окна
    HWND hwnd = CreateWindowEx(
    0,
    CLASS_NAME,
    L"Digits",
    WS_POPUP | WS_VISIBLE, // Полноэкранный безрамочный режим
    0, 0, screenWidth, screenHeight,
    nullptr,
    nullptr,
    hInstance,
    nullptr
    );



    if (hwnd == nullptr) {
    return 0;
    }

    ShowWindow(hwnd, nCmdShow);

    // Цикл обработки сообщений
    MSG msg{};
    while (GetMessage(&msg, nullptr, 0, 0)) {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }

    return 0;
    }
     
    4 окт 2023 Изменено
  2. Фугу
    Фугу 4 окт 2023 Не верю ни Богу,ни людям Ни рыбам, ни сукам, я верю в бабло 2538 29 мар 2020
    Если я установлю, я смогу взломать Вучаева? :pepeHacker:
     
    1. lovemef
      Фугу, его пароль vuchaev2010
    2. Vkcom
      lovemef, восклицательный знак в конце
Загрузка...
Top