+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
+ }\r
+\r
+ setup();\r
+}\r
+\r