-void redraw() {\r
- press_down(VK_CONTROL);\r
- press('A');\r
- press_up(VK_CONTROL);\r
- Sleep(100);\r
- press(VK_DELETE);\r
- Sleep(100);\r
- int _x = x, _y = y;\r
- print_text(0, 0, map.c_str(), 1, false);\r
- for (int i = 0; i < 100; i++)\r
- press(VK_UP);\r
- for (int i = 0; i < 100; i++)\r
- press(VK_LEFT);\r
- x = y = 0;\r
- press(VK_DOWN);\r
- press(VK_RIGHT);\r
- press(VK_RIGHT);\r
- move_to(_x, _y);\r
-}\r
-\r
-int lvl = 0;\r
-\r
-void setup() {\r
- x = y = 0;\r
- press(VK_DOWN);\r
- press(VK_RIGHT);\r
- press(VK_RIGHT);\r
-\r
- for (int i = 0; i < WIDTH; i++)\r
- for (int j = 0; j < HEIGHT; j++)\r
- if (get_block(i, j) == 'S') {\r
- spawn_x = i;\r
- spawn_y = j;\r
- }\r
- \r
- move_to(spawn_x, spawn_y);\r
-}\r
-\r
-void load_level(int l, bool terminate = true) {\r
- lvl = l;\r
- map = read_map(lvl);\r
- if (terminate)\r
- TerminateProcess(pi.hProcess, 0);\r
-\r
- char cmd[100];\r
- sprintf(cmd, "notepad.exe lvl/%d.txt", lvl);\r
-\r
- if (!CreateProcessA(NULL, // No module name (use command line)\r
- cmd, // Command line\r
- NULL, // Process handle not inheritable\r
- NULL, // Thread handle not inheritable\r
- FALSE, // Set handle inheritance to FALSE\r
- 0, // No creation flags\r
- NULL, // Use parent's environment block\r
- NULL, // Use parent's starting directory\r
- &si, // Pointer to STARTUPINFO structure\r
- &pi) // Pointer to PROCESS_INFORMATION structure\r
- ) {\r
- printf("CreateProcess failed (%d).\n", GetLastError());\r
- return;\r
- }\r
-\r
- Sleep(100);\r
-\r
- char title[100];\r
- sprintf(title, "%d.txt - Editor", lvl);\r
- hwnd = FindWindowA(NULL, title);\r
-\r
- SetWindowPos(hwnd, HWND_TOP, 100, 100, 960, 905, SWP_SHOWWINDOW);\r
- SetFocus(hwnd);\r
-\r
- for (int i = 0; i < 10; i++) {\r
- press_down(VK_CONTROL);\r
- press(VK_OEM_PLUS);\r
- press_up(VK_CONTROL);\r
+void print_text(int x, int y, string text, int delay) {\r
+ for (int i = 0; i < text.size(); i++) {\r
+ select_length(get_pos(x + i, y), 1);\r
+ replace(text.substr(i, 1));\r
+ Sleep(delay);\r