-
Notifications
You must be signed in to change notification settings - Fork 2
/
stupidfox.c
178 lines (146 loc) · 6.04 KB
/
stupidfox.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
//////////////////////////////////////////////////////////
////// //////
////// AWFUL STUPID FUCKING FOX DESK PEST //////
////// //////
//////////////////////////////////////////////////////////
// no idea why i decided to write this as a win32 app but here u go
// in case you're wondering why it looks like shit its because i
// scrapped it together from tutorials and code from my other projects
// no i won't refactor it i'm too cute and sexy for that <3
#define UNICODE
#define _UNICODE
#include <windows.h>
#include <stdbool.h>
#include <stdint.h>
#include <wincon.h>
#include <stdio.h>
#include "pixeldata.h"
static bool quit = false;
static bool clicked = false;
static BITMAPINFO frame_bitmap_info;
static HBITMAP frame_bitmap = 0;
static HDC frame_device_context = 0;
#define IMWDTH 212
#define IMHGHT 219
struct {
int width;
int height;
uint32_t *pixels;
} frame = {0};
LRESULT CALLBACK WindowProcessMessage(HWND window_handle, UINT message, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pCmdLine, int nCmdShow) {
AttachConsole(ATTACH_PARENT_PROCESS);
freopen("CON", "w", stdout);
freopen("CON", "w", stderr);
freopen("CON", "r", stdin);
frame.width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
frame.height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
const wchar_t k_WndClassName[] = L"OverlayWindowClass";
// Register window class
WNDCLASSEXW wcex = { 0 };
wcex.cbSize = sizeof( wcex );
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WindowProcessMessage;
wcex.hInstance = hInstance;
wcex.hCursor = LoadCursorW( NULL, IDC_ARROW );
// wcex.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
wcex.lpszClassName = k_WndClassName;
RegisterClassExW( &wcex );
HWND window_handle = CreateWindowExW( WS_EX_TOPMOST | WS_EX_LAYERED,
k_WndClassName,
L"YEEP",
WS_POPUP | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT,
frame.width, frame.height,
NULL, NULL,
hInstance,
NULL );
// Make window semi-transparent, and mask out background color
SetLayeredWindowAttributes( window_handle, RGB( 0, 0, 0 ), 255, LWA_ALPHA | LWA_COLORKEY );
frame_bitmap_info.bmiHeader.biSize = sizeof(frame_bitmap_info.bmiHeader);
frame_bitmap_info.bmiHeader.biPlanes = 1;
frame_bitmap_info.bmiHeader.biBitCount = 32;
frame_bitmap_info.bmiHeader.biCompression = BI_RGB;
frame_device_context = CreateCompatibleDC(0);
frame_bitmap_info.bmiHeader.biWidth = frame.width;
frame_bitmap_info.bmiHeader.biHeight = frame.height;
frame_bitmap = CreateDIBSection(NULL, &frame_bitmap_info, DIB_RGB_COLORS, (void**)&frame.pixels, 0, 0);
SelectObject(frame_device_context, frame_bitmap);
int direction = 1;
int k = 0;
int kclick = 0;
int nextk = 200;
int yshift = 0;
int xshift = 0;
while(!quit)
{
k++;
static MSG message = { 0 };
while(PeekMessage(&message, NULL, 0, 0, PM_REMOVE)) { DispatchMessage(&message); }
Sleep(50);
if(k==nextk){
k = 0;
direction = -direction;
nextk = 100 + (rand()%100);
yshift = rand() % (frame.height-IMHGHT);
}
if(clicked){
kclick++;
if(kclick>=17){
kclick = 0;
clicked = false;
k = 100;
}
}
if(k>100){ continue; }
if(window_handle == NULL) { return -1; }
InvalidateRect(window_handle, NULL, FALSE);
int offset = clicked ? 4*((kclick%17)+8)*IMWDTH*IMHGHT : 4*(k%8)*IMWDTH*IMHGHT;
if(!clicked) { xshift = k*(frame.width+IMWDTH)/100 - IMWDTH; }
for (int i = 0; i < frame.height; ++i){
int ypos = (i-yshift);
for (int j = 0; j < frame.width; ++j){
int xpos = (direction > 0) ? (j-xshift) : frame.width - j - xshift;
frame.pixels[i*frame.width + j] = 0;
if((ypos<IMHGHT) && (ypos>0) && (xpos<IMWDTH) && (xpos>0)){
int pxidx = offset + 4*(ypos*IMWDTH + xpos);
if(data[pxidx + 3] < 10){
frame.pixels[i*frame.width + j] = 0;
} else {
frame.pixels[i*frame.width + j] =
(data[pxidx + 0] << (16)) +
(data[pxidx + 1] << (8)) +
(data[pxidx + 2]);
}
}
}
}
UpdateWindow(window_handle);
}
return 0;
}
LRESULT CALLBACK WindowProcessMessage(HWND window_handle, UINT message, WPARAM wParam, LPARAM lParam) {
switch(message) {
case WM_QUIT:
case WM_DESTROY:
quit = true;
break;
case WM_PAINT:
static PAINTSTRUCT paint;
static HDC device_context;
device_context = BeginPaint(window_handle, &paint);
BitBlt(device_context,
paint.rcPaint.left, paint.rcPaint.top,
paint.rcPaint.right - paint.rcPaint.left, paint.rcPaint.bottom - paint.rcPaint.top,
frame_device_context,
paint.rcPaint.left, paint.rcPaint.top,
SRCCOPY);
EndPaint(window_handle, &paint);
break;
case WM_LBUTTONDOWN:
clicked=true;
default:
return DefWindowProc(window_handle, message, wParam, lParam);
}
return 0;
}