Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
int GetColor(int x, int y) { COLORREF farbe; HDC desktop; desktop = GetDC(0) ; farbe = GetPixel(desktop, x , y); if (farbe != CLR_INVALID) return farbe; else return -1; } int GetMouseX() { int Zahl; LPPOINT point = new POINT; if(GetCursorPos(point)!=0) { Zahl = point->x; delete point; point = NULL; } else { Zahl = -1; } return Zahl; } int GetMouseY() { int Zahl; LPPOINT point = new POINT; if(GetCursorPos(point)!=0) { Zahl = point->y; delete point; point = NULL; } else { Zahl = -1; } return Zahl; } bool isLoad(int x,int y,int color) { if(GetColor(x,y)==color) { return true; } else return false; } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
int GetMouseX() { int Zahl; LPPOINT point = new POINT; if(GetCursorPos(point)!=0) { Zahl = point->x; } else { Zahl = -1; } delete point; point = NULL; return Zahl; } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
while(!isLoad(werte[0],werte[1],werte[2]) && !weiter) { if(isLoad(218,303,3095667)) { Refresh(); currentTime = 0; } if(currentTime > timeUntilRefresh) { weiter = true; } currentTime += 10; Sleep(10); } |
C-/C++-Quelltext |
|
1 2 3 4 |
void Refresh()
{
VirtualKeyPress(0x74);
}
|
C-/C++-Quelltext |
|
1 2 |
LPPOINT point = new POINT; if(GetCursorPos(point)!=0) |
C-/C++-Quelltext |
|
1 2 |
POINT point = {0}; if(GetCursorPos(&point)!=0) |
Alter Hase
C-/C++-Quelltext |
|
1 2 3 4 |
int GetMouseX() { return GetCursorPos()->x; } |
Zitat von »"K-Bal"«
Jo und wenn BlackSnake schon mit Schönheitskorrekturen anfängt:
Warum lässt du GetCursorPos() nicht einfach einen LPPOINT zurückgeben und machst dann in GetMouse) nur:
C-/C++-Quelltext
1 2 3 4 int GetMouseX() { return GetCursorPos()->x; }
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 |
int GetMouseX() { LPPOINT lpp = GetCursorPos (); int x = lpp -> x; delete lpp; return x; } |
Alter Hase
Zitat von »"the[V«
oid"]
Wenn GetCursorPos() einen LPPOINT, also einen Pointer, liefert, dann muss auf diesem auch früher oder später delete aufgerufen werden... So wie du das geschrieben hast, würde es aber nicht gehen.
]
Zitat von »"the[V«
oid"]Hmm joo stimmt... da war ich was voreilig Allerdings würde ich dann eine Referenz statt eines Pointers zurückgeben. Pointer ist für mich immer ein Indiz dafür, dass der jenige, der da ein Objekt bekommt, auch den Besitz an diesem Objekt übernimmt, sprich, er ist dafür verantwortlich, es irgendwann zu löschen.
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 41 42 43 44 45 46 47 48 |
int GetColor(int x, int y) { COLORREF farbe; HDC desktop; desktop = GetDC(0) ; farbe = GetPixel(desktop, x , y); if (farbe != CLR_INVALID) return farbe; else return -1; } int GetMouseX() { int xCord = -1; LPPOINT point = {0}; if(GetCursorPos(point)!=0) { xCord = point->x; } delete point; point = NULL; return xCord; } int GetMouseY() { int yCord = -1; LPPOINT point = {0}; if(GetCursorPos(point)!=0) { yCord = point->y; } delete point; point = NULL; return yCord; } bool isLoad(int x,int y,int color) { if(GetColor(x,y)==color) { return true; } else return false; } |
Werbeanzeige