You are not logged in.

  • Login

1

Thursday, September 28th 2006, 10:37am

Express Hilfe benötigt

Moinmoin

Da ich jetzt auch noch von meinem Betreuer gezwungen wurde für meine Maturarbeit so schnell mal ein bisschen C++ zu schreiben, was ich absolut nicht kann bitte ich euch um Hilfe.

Wer könnte mir diesen Code:

C Quellcode

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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
#include "stdafx.h"
#include "resource.h"
 
 
 
#define MAX_LOADSTRING 100
 
 
 
#define	ROWS			50
#define	COLS			50
#define	ROW_SIZE		10
#define	COL_SIZE		10
#define	CLIP_SIZE	50
#define	OTHER_SIZE	150
 
#define	TABLE_WIDTH		(ROWS*ROW_SIZE)
#define	TABLE_HEIGHT	(COLS*COL_SIZE)
#define	TABLE_X			(CLIP_SIZE)
#define	TABLE_Y			(CLIP_SIZE)
#define	WINDOW_WIDTH	(CLIP_SIZE + TABLE_WIDTH + OTHER_SIZE + CLIP_SIZE)
#define	WINDOW_HEIGHT	(CLIP_SIZE + TABLE_HEIGHT + CLIP_SIZE)
 
 
 
HANDLE	hBitBuffer, hBitBack, hBitAlive, hBitDead;
 
HANDLE	hBitButClear, hBitButNext, hBitButStart[2], hBitButStop,
			hBitButSlow[2], hBitButNormal[2], hBitButFast[2],
			hBitButClose;
 
HMENU		menu;
 
unsigned char	table[ROWS][COLS], dtable[ROWS][COLS];
 
#define	CAP_MOVE		1
#define	CAP_TABLE	2
int		captured = 0, cap_button;
POINT		cap_point, table_point;
 
 
#define	TD_SLOW		1000
#define	TD_NORMAL	400
#define	TD_FAST		100
 
unsigned int	timer_delay = TD_NORMAL;
bool				timer_working = FALSE;
 
HWND		hWndButtonClear,
			hWndButtonNext,
			hWndButtonStart,
			hWndButtonStop,
			hWndButtonSlow,
			hWndButtonNormal,
			hWndButtonFast,
			hWndButtonClose;
 
// Global Variables:
HINSTANCE hInst;								// current instance
TCHAR szTitle[MAX_LOADSTRING];								// The title bar text
TCHAR szWindowClass[MAX_LOADSTRING];								// The title bar text
 
// Foward declarations of functions included in this code module:
ATOM				MyRegisterClass(HINSTANCE hInstance);
BOOL				InitInstance(HINSTANCE, int);
LRESULT CALLBACK	WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK	About(HWND, UINT, WPARAM, LPARAM);
 
 
 
/*****************************************************************************/
void	table_clear(void)
{
	int	x, y;
 
	for(y=0; y<ROWS; y++)
		for(x=0; x<COLS; x++)
			table[y][x] = 0;
}
 
void	table_set(int row, int col, unsigned char val)
{
	table[row][col] = val;
}
 
 
int	table_neighbors(int y, int x)
{
	int	n=0;
 
	if (table[y-1][x-1])
		n++;
	if (table[y-1][x])
		n++;
	if (table[y-1][x+1])
		n++;
 
	if (table[y][x-1])
		n++;
	if (table[y][x+1])
		n++;
 
	if (table[y+1][x-1])
		n++;
	if (table[y+1][x])
		n++;
	if (table[y+1][x+1])
		n++;
 
	return(n);
}
 
 
void	table_next(void)
{
	int	x, y, n;
 
	for(y=1; y<ROWS-1; y++)
	{
		for(x=1; x<COLS-1; x++)
		{
			n = table_neighbors(y, x);
			if (table[y][x])
			{
				if (n == 2 || n == 3)
					dtable[y][x] = 0;
				else
					dtable[y][x] = 1;
			}
			else
			{
				if (n == 3)
					dtable[y][x] = 1;
				else
					dtable[y][x] = 0;
			}
		}
	}
 
	for(y=0; y<ROWS; y++)
		for(x=0; x<COLS; x++)
			table[y][x] = dtable[y][x];
}
 
 
 
/*****************************************************************************/
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
 	// TODO: Place code here.
	MSG msg;
	HACCEL hAccelTable;
 
	// Initialize global strings
	LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
	LoadString(hInstance, IDC_LIFE, szWindowClass, MAX_LOADSTRING);
	MyRegisterClass(hInstance);
 
 
	hBitAlive = LoadImage(hInstance, MAKEINTRESOURCE(IDB_ALIVE), IMAGE_BITMAP, 0, 0, 0);
	if (!hBitAlive)
		return FALSE;
	hBitDead = LoadImage(hInstance, MAKEINTRESOURCE(IDB_DEAD), IMAGE_BITMAP, 0, 0, 0);
	if (!hBitDead)
		return FALSE;
	hBitDead = LoadImage(hInstance, MAKEINTRESOURCE(IDB_SICK), IMAGE_BITMAP, 0, 0, 0);
	if (!hBitSick)
		return FALSE;
	hBitDead = LoadImage(hInstance, MAKEINTRESOURCE(IDB_INFECTED), IMAGE_BITMAP, 0, 0, 0);
	if (!hBitInfected)
		return FALSE;
	hBitDead = LoadImage(hInstance, MAKEINTRESOURCE(IDB_INFECTIOUS), IMAGE_BITMAP, 0, 0, 0);
	if (!hBitInfectious)
		return FALSE;
	hBitDead = LoadImage(hInstance, MAKEINTRESOURCE(IDB_IMMUNE), IMAGE_BITMAP, 0, 0, 0);
	if (!hBitImmune)
		return FALSE;
 
 
	// Perform application initialization:
	if (!InitInstance (hInstance, nCmdShow)) 
		return FALSE;
 
	table_clear();
 
	hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_LIFE);
 
	// Main message loop:
	while (GetMessage(&msg, NULL, 0, 0)) 
	{
		if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) 
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}
 
	return msg.wParam;
}
 
 
 
//
//  FUNCTION: MyRegisterClass()
//
//  PURPOSE: Registers the window class.
//
//  COMMENTS:
//
//    This function and its usage is only necessary if you want this code
//    to be compatible with Win32 systems prior to the 'RegisterClassEx'
//    function that was added to Windows 95. It is important to call this function
//    so that the application will get 'well formed' small icons associated
//    with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
	WNDCLASSEX wcex;
 
	wcex.cbSize = sizeof(WNDCLASSEX); 
 
	wcex.style			= CS_HREDRAW | CS_VREDRAW;
	wcex.lpfnWndProc	= (WNDPROC)WndProc;
	wcex.cbClsExtra		= 0;
	wcex.cbWndExtra		= 0;
	wcex.hInstance		= hInstance;
	wcex.hIcon			= LoadIcon(hInstance, (LPCTSTR)IDI_LIFE);
	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);
	wcex.lpszMenuName	= NULL;//(LPCSTR)IDC_LIFE;
	wcex.lpszClassName	= szWindowClass;
	wcex.hIconSm		= LoadIcon(wcex.hInstance, (LPCTSTR)IDI_LIFE);
 
	return RegisterClassEx(&wcex);
}
 
 
 
//
//   FUNCTION: InitInstance(HANDLE, int)
//
//   PURPOSE: Saves instance handle and creates main window
//
//   COMMENTS:
//
//        In this function, we save the instance handle in a global variable and
//        create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
   HWND	hWnd;
	RECT	rect;
	DWORD	style;
	HRGN	region;
 
   hInst = hInstance; // Store instance handle in our global variable
 
	rect.left = 100;										//x
	rect.top = 100;										//y
	rect.right = rect.left + WINDOW_WIDTH;			//width
	rect.bottom = rect.top + WINDOW_HEIGHT;		//height
 
	style = WS_CLIPSIBLINGS | WS_OVERLAPPED | WS_SYSMENU | 
		WS_MINIMIZEBOX | WS_CLIPCHILDREN;
 
	if (!AdjustWindowRect(&rect, style, false))
		return FALSE;
 
	region = CreateRectRgn(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
	if (!region)
		return FALSE;
 
 
 
	hWnd = CreateWindow(szWindowClass, szTitle, style,
      rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
		NULL, NULL, hInstance, NULL);
   if (!hWnd)
      return FALSE;
 
	if (!SetWindowRgn(hWnd, region, FALSE))
		return FALSE;
 
	menu = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU_CLPOPUP));
	if (!menu)
		return FALSE;
 
	int	x, y;
 
	x = TABLE_X + TABLE_WIDTH + 30;
	y = TABLE_Y;
 
	hWndButtonClear = CreateWindow("Button","Clear",
		WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | BS_BITMAP, 
		x, y, 120, 40, hWnd, NULL, hInstance, NULL);
	y+=40;
 
	hWndButtonNext = CreateWindow("Button", "Next",
		WS_VISIBLE | WS_CHILD | BS_BITMAP, 
		x, y, 120, 40, hWnd, NULL, hInstance, NULL);
	y+=50;
 
	hWndButtonStart = CreateWindow("Button", "Start",
		WS_VISIBLE | WS_CHILD | BS_BITMAP, 
		x, y, 120, 40, hWnd, NULL, hInstance, NULL);
	y+=40;
 
	hWndButtonStop = CreateWindow("Button", "Stop",
		WS_VISIBLE | WS_CHILD | BS_BITMAP, 
		x, y, 120, 40, hWnd, NULL, hInstance, NULL);
	y+=50;
 
	hWndButtonSlow = CreateWindow("Button", "Slow",
		WS_VISIBLE | WS_CHILD | BS_BITMAP, 
		x, y, 120, 40, hWnd, NULL, hInstance, NULL);
	y+=40;
 
	hWndButtonNormal = CreateWindow("Button", "Normal",
		WS_VISIBLE | WS_CHILD | BS_BITMAP, 
		x, y, 120, 40, hWnd, NULL, hInstance, NULL);
	y+=40;
 
	hWndButtonFast = CreateWindow("Button", "Fast",
		WS_VISIBLE | WS_CHILD | BS_BITMAP, 
		x, y, 120, 40, hWnd, NULL, hInstance, NULL);
	y+=40;
 
	hBitButClear = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BUTCLEAR));
	SendMessage(hWndButtonClear, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,
		(LPARAM)(HANDLE)hBitButClear);
 
	hBitButNext = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BUTNEXT));
	SendMessage(hWndButtonNext, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,
		(LPARAM)(HANDLE)hBitButNext);
 
	hBitButStart[0] = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BUTSTART));
	hBitButStart[1] = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BUTSTART_ON));
	SendMessage(hWndButtonStart, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,
		(LPARAM)(HANDLE)hBitButStart[0]);
 
	hBitButStop = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BUTSTOP));
	SendMessage(hWndButtonStop, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,
		(LPARAM)(HANDLE)hBitButStop);
 
	hBitButSlow[0] = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BUTSLOW));
	hBitButSlow[1] = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BUTSLOW_ON));
	SendMessage(hWndButtonSlow, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,
		(LPARAM)(HANDLE)hBitButSlow[0]);
 
	hBitButNormal[0] = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BUTNORMAL));
	hBitButNormal[1] = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BUTNORMAL_ON));
	SendMessage(hWndButtonNormal, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,
		(LPARAM)(HANDLE)hBitButNormal[1]);
 
	hBitButFast[0] = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BUTFAST));
	hBitButFast[1] = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BUTFAST_ON));
	SendMessage(hWndButtonFast, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,
		(LPARAM)(HANDLE)hBitButFast[0]);
 
	   ShowWindow(hWnd, nCmdShow);
   UpdateWindow(hWnd);
 
   return TRUE;
}
 
 
 
//
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	//int	wmId, wmEvent;
	int			x, y;
	POINT			point;
	int			id = LOWORD(wParam);
	HWND			handle = (HWND)lParam;
	PAINTSTRUCT	ps;
	HDC			hdc;
	TCHAR			szHello[MAX_LOADSTRING];
 
	LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
 
	switch (message) 
	{
		case WM_TIMER:
			if (wParam == 1)
			{
				table_next();
				InvalidateRect(hWnd, NULL, FALSE);
			}
 
			break;
 
		case WM_COMMAND:
 
			switch(HIWORD(wParam))
			{
				case	BN_CLICKED:
					if (handle == hWndButtonClear)
					{
						table_clear();
						InvalidateRect(hWnd, NULL, FALSE);
					}
					else if (handle == hWndButtonNext)
					{
						table_next();
						InvalidateRect(hWnd, NULL, FALSE);
					}
					else if (handle == hWndButtonStart)
					{
						SetTimer(hWnd, 1, timer_delay, NULL);
						timer_working = TRUE;
						SendMessage(hWndButtonStart, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,
							(LPARAM)(HANDLE)hBitButStart[1]);
					}
					else if (handle == hWndButtonStop)
					{
						if (timer_working)
							KillTimer(hWnd, 1);
						timer_working = FALSE;
						SendMessage(hWndButtonStart, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,
							(LPARAM)(HANDLE)hBitButStart[0]);
					}
					else if (handle == hWndButtonSlow)
					{
						timer_delay = TD_SLOW;
						if (timer_working)
							SetTimer(hWnd, 1, timer_delay, NULL);
						SendMessage(hWndButtonSlow, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,
							(LPARAM)(HANDLE)hBitButSlow[1]);
						SendMessage(hWndButtonNormal, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,
							(LPARAM)(HANDLE)hBitButNormal[0]);
						SendMessage(hWndButtonFast, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,
							(LPARAM)(HANDLE)hBitButFast[0]);
					}
					else if (handle == hWndButtonNormal)
					{
						timer_delay = TD_NORMAL;
						if (timer_working)
							SetTimer(hWnd, 1, timer_delay, NULL);
						SendMessage(hWndButtonSlow, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,
							(LPARAM)(HANDLE)hBitButSlow[0]);
						SendMessage(hWndButtonNormal, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,
							(LPARAM)(HANDLE)hBitButNormal[1]);
						SendMessage(hWndButtonFast, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,
							(LPARAM)(HANDLE)hBitButFast[0]);
					}
					else if (handle == hWndButtonFast)
					{
						timer_delay = TD_FAST;
						if (timer_working)
							SetTimer(hWnd, 1, timer_delay, NULL);
						SendMessage(hWndButtonSlow, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,
							(LPARAM)(HANDLE)hBitButSlow[0]);
						SendMessage(hWndButtonNormal, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,
							(LPARAM)(HANDLE)hBitButNormal[0]);
						SendMessage(hWndButtonFast, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,
							(LPARAM)(HANDLE)hBitButFast[1]);
					}
					else if (handle == hWndButtonClose)
					{
						DestroyWindow(hWnd);
					}
 
					break;
			}
 
			switch (LOWORD(wParam))
			{
				case	IDM_CL_CLOSE:
					DestroyWindow(hWnd);
					break;
				case	IDM_CL_MINIMIZE:
					break;
			}
			break;
 
		case WM_PAINT:
			HDC		hdc_buf, hdc_temp;
			HGDIOBJ	temp;
 
			hdc = BeginPaint(hWnd, &ps);
 
			// Run once
			if (!hBitBuffer)
				hBitBuffer = CreateCompatibleBitmap(hdc, WINDOW_WIDTH, WINDOW_HEIGHT);
 
			// Double-Buffer DC
			hdc_buf = CreateCompatibleDC(hdc);
			SelectObject(hdc_buf, hBitBuffer);
 
			// Background DC
			hdc_temp = CreateCompatibleDC(hdc_buf);
			temp = SelectObject(hdc_temp, hBitBack);
 
			// Copy background onto back-buffer
			BitBlt(hdc_buf, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, hdc_temp, 0, 0, SRCCOPY);
			SelectObject(hdc_temp, temp);
 
			// Copy table
			for(y=0; y<ROWS; y++)
			{
				for(x=0; x<COLS; x++)
				{
					temp = SelectObject(hdc_temp, (table[y][x])?hBitAlive:hBitDead:hBitSick:hBitInfected:hBitInfectious:hBitImmune);
					BitBlt(hdc_buf, TABLE_X + x*COL_SIZE, TABLE_Y + y*ROW_SIZE, COL_SIZE, ROW_SIZE,
						hdc_temp, 0, 0, SRCCOPY);
					SelectObject(hdc_temp, temp);
				}
			}
 
			DeleteDC(hdc_temp);
 
			BitBlt(hdc, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, hdc_buf, 0, 0, SRCCOPY);
 
			DeleteDC(hdc_buf);
 
			EndPaint(hWnd, &ps);
			break;
 
		case WM_ERASEBKGND:
			break;
 
		case WM_DESTROY:
			PostQuitMessage(0);
			break;
 
 
		case	WM_LBUTTONDOWN:
			x = (LOWORD(lParam) - TABLE_X);
			y = (HIWORD(lParam) - TABLE_Y);
 
			if ((x>=0) && (y>=0) && (x<COLS*COL_SIZE) && (y<ROWS*ROW_SIZE))
			{
				captured = CAP_TABLE;
				cap_button = 1;
				SetCapture(hWnd);
				SetCursor(LoadCursor(NULL, IDC_CROSS));
 
				x /= COL_SIZE;
				y /= ROW_SIZE;
				table_set(y, x, 1);
				table_point.x = x;
				table_point.y = y;
 
				InvalidateRect(hWnd, NULL, FALSE);
			}
			else
			{
				captured = CAP_MOVE;
				SetCapture(hWnd);
				cap_point.x = LOWORD(lParam);
				cap_point.y = HIWORD(lParam);
				SetCursor(LoadCursor(NULL, IDC_SIZEALL));
			}
			break;
 
		case	WM_RBUTTONDOWN:
			x = (LOWORD(lParam) - TABLE_X);
			y = (HIWORD(lParam) - TABLE_Y);
 
			if ((x>=0) && (y>=0) && (x<COLS*COL_SIZE) && (y<ROWS*ROW_SIZE))
			{
				captured = CAP_TABLE;
				cap_button = 2;
				SetCapture(hWnd);
				SetCursor(LoadCursor(NULL, IDC_CROSS));
 
				x /= COL_SIZE;
				y /= ROW_SIZE;
				table_set(y, x, 0);
				table_point.x = x;
				table_point.y = y;
 
				InvalidateRect(hWnd, NULL, FALSE);
			}
			break;
 
		case	WM_MOUSEMOVE:
			if (captured == CAP_MOVE)
			{
				point.x = LOWORD(lParam);
				point.y = HIWORD(lParam);
 
				ClientToScreen(hWnd, &point);
 
				point.x -= cap_point.x;
				point.y -= cap_point.y;
 
				SetWindowPos(hWnd, NULL, point.x, point.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
			}
			else if (captured == CAP_TABLE)
			{
				x = (LOWORD(lParam) - TABLE_X);
				y = (HIWORD(lParam) - TABLE_Y);
 
				if ((x>=0) && (y>=0) && (x<COLS*COL_SIZE) && (y<ROWS*ROW_SIZE))
				{
					x /= COL_SIZE;
					y /= ROW_SIZE;
					if (x != table_point.x || y != table_point.y)
					{
						table_point.x = x;
						table_point.y = y;
						table_set(y, x, (cap_button==1)?1:0);
 
						InvalidateRect(hWnd, NULL, FALSE);
					}
				}
			}
			break;
 
		case	WM_LBUTTONUP:
 
			if (captured == CAP_MOVE)
			{
				captured = 0;
				ReleaseCapture();
				SetCursor(LoadCursor(NULL, IDC_ARROW));
			}
			else if (captured == CAP_TABLE)
			{
				captured = 0;
				ReleaseCapture();
			}
			break;
 
		case	WM_RBUTTONUP:
 
			if (captured == CAP_TABLE)
			{
				if (cap_button == 2)
				{
					captured = 0;
					ReleaseCapture();
				}
			}
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}
 
 
 
// Mesage handler for about box.
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
		case WM_INITDIALOG:
				return TRUE;
 
		case WM_COMMAND:
			if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) 
			{
				EndDialog(hDlg, LOWORD(wParam));
				return TRUE;
			}
			break;
	}
    return FALSE;
}


so ändern, dass alle Zustände (Alive, Dead, Sick, Infected, Infectious, Immune) dargestellt werden können und nicht wie bisher nur Dead oder Alive.

Der Zustand hängt immer vom vorherigen ab:

Alive wird bei genügend Kontakt mit infizierten Nachbarn auch infiziert und damit INFEcted und Infectious.Dann entscheidet eine Wahrscheinlichkeit darüber, ob der Agent erkrankt und Sick und Infectious oder Immune und nicht mehr Infectious wird. Falls er Sick wurde, entscheidet noch die Wahrscheinlichkeit darüber , ob die Person Dead oder Immune wird.


Ich hoffe ich habe mich klar ausgedrückt.

Ich wäre euch sehr sehr dankbar für schnelle Hilfe, da ich sonst ein ernsthaftes Problem habe.

MfG
Florian Eichenberger

Social bookmarks