#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <windows.h>
Go to the source code of this file.
|
static BOOL | InitApplication (HINSTANCE hInstance) |
|
static BOOL | InitInstance (HINSTANCE hInstance, int nCmdShow) |
|
LRESULT CALLBACK | WndProc (HWND hWnd, UINT message, WPARAM uParam, LPARAM lParam) |
|
static void | set_maze_sizes (int width, int height) |
|
static void | initialize_maze () |
|
static int | choose_door () |
|
static long | backup () |
|
static void | draw_wall () |
|
static void | draw_solid_square (int, int, int, HDC, HBRUSH) |
|
static void | enter_square (int, HDC, HBRUSH) |
|
static void | create_maze () |
|
static int | choose_door (HDC hDC) |
|
static void | draw_maze_border (HWND hWnd, HDC hDC) |
|
static void | draw_wall (int i, int j, int dir, HDC hDC) |
|
static void | begin_solve_maze () |
|
static int | solve_maze () |
|
static void | start_timer (HWND hWnd, int iTimeout) |
|
int APIENTRY | WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) |
|
static BOOL | OnCreate (HWND hWnd, LPCREATESTRUCT lpCreateStruct) |
|
void | OnTimer (HWND hwnd, UINT id) |
|
◆ APIENTRY
◆ border_x
◆ border_y
◆ DLGPROC
◆ DOOR_IN_ANY
◆ DOOR_IN_BOTTOM
◆ DOOR_IN_LEFT
◆ DOOR_IN_RIGHT
◆ DOOR_IN_TOP
◆ DOOR_OUT_BOTTOM
◆ DOOR_OUT_LEFT
◆ DOOR_OUT_RIGHT
◆ DOOR_OUT_TOP
◆ END_SQUARE
◆ get_random
◆ MAX_MAZE_SIZE_X
◆ MAX_MAZE_SIZE_Y
◆ MOVE_LIST_SIZE
◆ START_SQUARE
◆ STRICT
◆ WALL_BOTTOM
◆ WALL_LEFT
◆ WALL_RIGHT
◆ WALL_TOP
◆ backup()
Definition at line 367 of file maze.c.
368{
373 }
375}
static struct @1561 move_list[MOVE_LIST_SIZE]
◆ begin_solve_maze()
static void begin_solve_maze |
( |
| ) |
|
|
static |
Definition at line 487 of file maze.c.
488{
489 static long grayPattern[] = {
490 0x55555555,
491 0xaaaaaaaa,
492 0x55555555,
493 0xaaaaaaaa,
494 0x55555555,
495 0xaaaaaaaa,
496 0x55555555,
497 0xaaaaaaaa
498 };
500 { 0, 0, 255, 0 },
501 { 255, 255, 255, 0 }
502 };
504
515#if 0
516
518#else
520#endif
521
524
525
528
529
534}
static unsigned short maze[MAX_MAZE_SIZE_X][MAX_MAZE_SIZE_Y]
#define memcpy(s1, s2, n)
_In_ HBITMAP _In_ UINT _In_ UINT _Inout_ LPBITMAPINFO pbmi
BITMAPINFOHEADER bmiHeader
HBRUSH WINAPI CreateDIBPatternBrushPt(_In_ const VOID *pvPackedDIB, _In_ UINT uUsage)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
HDC WINAPI GetDC(_In_opt_ HWND)
Referenced by ScreenSaverProc(), and WinMain().
◆ choose_door() [1/2]
static int choose_door |
( |
| ) |
|
|
static |
◆ choose_door() [2/2]
static int choose_door |
( |
HDC |
hDC | ) |
|
|
static |
Definition at line 286 of file maze.c.
287{
288 int candidates[3];
289 register int num_candidates;
290
291 num_candidates = 0;
292
293
295 goto rightwall;
297 goto rightwall;
299 goto rightwall;
304 goto rightwall;
305 }
306 candidates[num_candidates++] = 0;
307
308 rightwall:
309
311 goto bottomwall;
313 goto bottomwall;
315 goto bottomwall;
320 goto bottomwall;
321 }
322 candidates[num_candidates++] = 1;
323
324 bottomwall:
325
327 goto leftwall;
329 goto leftwall;
331 goto leftwall;
336 goto leftwall;
337 }
338 candidates[num_candidates++] = 2;
339
340 leftwall:
341
343 goto donewall;
345 goto donewall;
347 goto donewall;
352 goto donewall;
353 }
354 candidates[num_candidates++] = 3;
355
356 donewall:
357 if (num_candidates == 0)
358 return ( -1 );
359 if (num_candidates == 1)
360 return ( candidates[0] );
361 return ( candidates[
get_random(num_candidates) ] );
362
363}
◆ create_maze()
static void create_maze |
( |
| ) |
|
|
static |
Definition at line 235 of file maze.c.
236{
237 register int i, newdoor = 0;
239
241 do {
248 return;
249 }
250 }
251
252
254
255 switch (newdoor) {
257 break;
259 break;
261 break;
263 break;
264 }
266
267
269
270
277 }
278 }
279
280 } while (1);
281
282}
static struct @1561 save_path[MOVE_LIST_SIZE]
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
Referenced by ScreenSaverProc(), and WinMain().
◆ draw_maze_border()
Definition at line 417 of file maze.c.
418{
420 HBRUSH hBrush;
421
422
427 }
433 }
434 }
441 }
445 }
446 }
447
451}
static void draw_solid_square(int, int, int, HDC, HBRUSH)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
HGDIOBJ WINAPI GetStockObject(_In_ int)
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
◆ draw_solid_square()
Definition at line 380 of file maze.c.
384{
386
388 case 0:
393 break;
394 case 1:
399 break;
400 case 2:
405 break;
406 case 3:
411 break;
412 }
414}
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
◆ draw_wall() [1/2]
static void draw_wall |
( |
| ) |
|
|
static |
◆ draw_wall() [2/2]
Definition at line 455 of file maze.c.
458{
460 case 0:
464 break;
465 case 1:
470 break;
471 case 2:
476 break;
477 case 3:
482 break;
483 }
484}
◆ enter_square()
static void enter_square |
( |
int |
n, |
|
|
HDC |
hDC, |
|
|
HBRUSH |
hBrush |
|
) |
| |
|
static |
Definition at line 574 of file maze.c.
575{
578
583 break;
586 break;
589 break;
592 break;
593 }
594}
GLint GLint GLint GLint GLint x
GLint GLint GLint GLint GLint GLint y
◆ InitApplication()
Definition at line 750 of file maze.c.
751{
753
754
755
756
767
768
770}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM uParam, LPARAM lParam)
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Referenced by WinMain().
◆ initialize_maze()
static void initialize_maze |
( |
| ) |
|
|
static |
Definition at line 139 of file maze.c.
140{
141 register int i,
j, wall;
142
143
147 }
148 }
149
150
153 }
154
155
158 }
159
160
163 }
164
165
168 }
169
170
172 switch (wall) {
173 case 0:
176 break;
177 case 1:
180 break;
181 case 2:
184 break;
185 case 3:
188 break;
189 }
199
200
201 wall = (wall + 2)%4;
202 switch (wall) {
203 case 0:
206 break;
207 case 1:
210 break;
211 case 2:
214 break;
215 case 3:
218 break;
219 }
226}
◆ InitInstance()
Definition at line 790 of file maze.c.
793{
794
795
796
798
799
800
810 );
811
812
815 }
816
817
820
822
823}
#define WS_OVERLAPPEDWINDOW
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI UpdateWindow(_In_ HWND)
Referenced by WinMain().
◆ OnCreate()
Definition at line 826 of file maze.c.
827{
830
832
837
840 }
843
846
848}
static void set_maze_sizes(int width, int height)
static int post_solve_delay
static int pre_solve_delay
UINT WINAPI GetPrivateProfileIntA(LPCSTR section, LPCSTR entry, INT def_val, LPCSTR filename)
void __cdecl srand(_In_ unsigned int _Seed)
_Check_return_ int __cdecl rand(void)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
◆ OnTimer()
◆ set_maze_sizes()
static void set_maze_sizes |
( |
int |
width, |
|
|
int |
height |
|
) |
| |
|
static |
Definition at line 130 of file maze.c.
132{
135}
GLint GLint GLsizei GLsizei height
GLint GLint GLsizei width
◆ solve_maze()
static int solve_maze |
( |
| ) |
|
|
static |
Definition at line 537 of file maze.c.
538{
540 int action_done;
541
542 do {
543 action_done = 1;
549 }
561 } else {
563 }
564 } else {
565 action_done = 0;
566 }
567 } while (! action_done);
568
570}
static void enter_square(int, HDC, HBRUSH)
Referenced by ScreenSaverProc(), and WinMain().
◆ start_timer()
Definition at line 597 of file maze.c.
598{
601}
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
◆ WinMain()
Definition at line 624 of file maze.c.
629{
632
633 if (!hPrevInstance) {
636 }
637 }
638
639
640
643 }
644
647
648
649
653 }
657 } else {
659 }
660 }
662 case 1:
665 break;
666 case 2:
672 break;
673 case 3:
676 break;
677 case 4:
680 break;
681 case 5:
684 }
685 break;
686 case 6:
691 } else {
693 }
694 break;
695 case 7:
698 }
699 break;
700 case 8:
705 }
706 } else {
708 }
709 break;
710 case 9:
713 break;
714 case 10:
717 }
718 break;
719 case 11:
721 break;
722 }
723 }
724
726}
static void start_timer(HWND hWnd, int iTimeout)
static void initialize_maze()
static void draw_maze_border(HWND hWnd)
static void create_maze()
static BOOL InitApplication(HINSTANCE hInstance)
static void begin_solve_maze()
static BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
TW_UINT32 TW_UINT16 TW_UINT16 MSG
BOOL WINAPI WaitMessage(void)
◆ WndProc()
Definition at line 869 of file maze.c.
874{
876
880 break;
887 break;
890 break;
891
892 default:
894 }
895 return (0);
896}
static BOOL OnCreate(HWND hWnd, LPCREATESTRUCT lpCreateStruct)
void OnTimer(HWND hwnd, UINT id)
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
Referenced by InitApplication().
◆ bw
◆ cur_sq_x
◆ cur_sq_y
◆ dir
◆ dummy
◆ end_dir
◆ end_x
◆ end_y
◆ grid_height
◆ grid_width
◆ hBrushDead
◆ hBrushLiving
◆ hDC
◆ hInst
◆ hWnd
◆ maze
◆ maze_size_x
◆ maze_size_y
◆ path_length
◆ pathi
◆ post_solve_delay
◆ pre_solve_delay
◆ solve_delay
◆ sqnum
◆ start_dir
◆ start_x
◆ start_y
◆ state
◆ szAppName
char szAppName[] = "Maze" |
◆ szTitle
◆ waiting