Hab ein komisches Problem:
Habe eine Variable erstellt und mit null initialisiert. Dies hat komischer Weise mal den, mal den anderen Wert.
Initialisierung:
|
C-/C++-Quelltext
|
1
|
unsigned long y_move = NULL;
|
Aus WndPrc:
|
C-/C++-Quelltext
|
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
|
case WM_KEYDOWN:
{
RECT client_rc;
GetClientRect(hWnd, &client_rc);
switch (wParam)
{
case VK_LEFT:
if(xpos > client_rc.left)
{
DrawBackground();
x_move -= speed;
}
break;
case VK_UP:
if(ypos > client_rc.top)
{
DrawBackground();
y_move -= speed;
} //Wenn ich bis hier ausführe hat y_move den Wert 4294967289 anstatt 7
break;
case VK_RIGHT:
if(xpos + 20 < client_rc.right)
{
DrawBackground();
x_move += speed;
}
break;
case VK_DOWN:
if(ypos + 20 < client_rc.bottom)
{
DrawBackground();
y_move += speed; //Wenn ich bis hier ausführe hat die gleiche Varaible den richtigen Wert 7
}
break;
default:
return 0;
}
|
Dieser Code hat auch noch mit der Variable zu tun:
|
C-/C++-Quelltext
|
1
2
|
xpos = x_start + x_move;
ypos = y_start + y_move;
|
An mehr Stellen kommt die Variable im Projekt nicht vor!
Was läuft da falsch?