Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
void CMyGameView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CMyGameDoc* pDoc = GetDocument(); //Zeiger auf CMyGameDoc
//Nur Ausführen, wenn Spieler an der Reihe ist und das Spiel läuft
if(pDoc->NextIsPlayer && pDoc->RunningGame)
{
//Gerätekontext holen
CClientDC dc(this);
CMyGameDoc* pDoc = GetDocument(); //Zeiger auf CMyGameDoc
CPoint PointOnBoard;
CRect get_rect;
GetDlgItem(IDC_STATIC_BOARD)->GetWindowRect(get_rect);
ScreenToClient(get_rect);
PointOnBoard.x = point.x - get_rect.left;
PointOnBoard.y = point.y - get_rect.top;
bool ClickOnPlayer = false, ClickOnDice = false;
int Position, Stein;
//Wenn auf einen Spielstein des Spielers geklickt wurde, gibt diese Schleife true zurück
if(!pDoc->Wuerfeln)
{
for(int i=0; i<4; i++)
{
Position = pDoc->pPlayer[pDoc->PlayerId].CurrentFiguresPosition[i];
if( (pDoc->pPlayer[pDoc->PlayerId].PossibleFiguresPositions[Position].x + RadiusSpielfigur) > PointOnBoard.x &&
(pDoc->pPlayer[pDoc->PlayerId].PossibleFiguresPositions[Position].x - RadiusSpielfigur) < PointOnBoard.x &&
(pDoc->pPlayer[pDoc->PlayerId].PossibleFiguresPositions[Position].y + RadiusSpielfigur) > PointOnBoard.y &&
(pDoc->pPlayer[pDoc->PlayerId].PossibleFiguresPositions[Position].y - RadiusSpielfigur) < PointOnBoard.y )
{
ClickOnPlayer = true;
Stein = i;
}
}
}//End if(!pDoc->Wuerfeln)
//Wenn gewürfelt werden darf
if(pDoc->Wuerfeln)
{
CPoint Center;
int width;
width = 50;
//Positionen der Würfel
//für Rot
if(pDoc->PlayerId == 0)
{
Center.x = Feld[27].x + ((FeldRot[0].x - Feld[27].x) / 2);
Center.y = FeldRot[0].y + ((FeldRot[2].y - FeldRot[0].y) / 2);
}
//für Blau
if(pDoc->PlayerId == 1)
{
Center.x = FeldBlau[1].x + ((Feld[31].x - FeldBlau[1].x) / 2);
Center.y = FeldBlau[0].y + ((FeldBlau[2].y - FeldBlau[0].y) / 2);
}
//für Gelb
if(pDoc->PlayerId == 2)
{
Center.x = FeldGelb[1].x + ((Feld[8].x - FeldGelb[1].x) / 2);
Center.y = FeldGelb[0].y + ((FeldGelb[2].y - FeldGelb[0].y) / 2);
}
//für Grün
if(pDoc->PlayerId == 3)
{
Center.x = Feld[10].x + ((FeldGruen[0].x - Feld[10].x) / 2);
Center.y = FeldGruen[0].y + ((FeldGruen[2].y - FeldGruen[0].y) / 2);
}
//Wurde auf den Würfel geklickt?
if( PointOnBoard.x >= (Center.x - (width/2)) &&
PointOnBoard.x <= (Center.x + (width/2)) &&
PointOnBoard.y >= (Center.y - (width/2)) &&
PointOnBoard.y <= (Center.y + (width/2)) )
{
ClickOnDice = true;
}
}//End if(!ClickOnPlayer && pDoc->RunningGame && pDoc->Wuerfeln)
//Wenn auf einen Spielstein geklickt wurde und auch ein Stein angeklickt werden soll, dann löse Funktion aus
if(ClickOnPlayer && !pDoc->Wuerfeln)
{
pDoc->pPlayer[pDoc->PlayerId].Create(this, pDoc->PlayerId, 1, Stein);
}//End if(ClickOnPlayer && pDoc->RunningGame && !pDoc->Wuerfeln)
//Wenn nicht auf einen Spielstein geklickt wurde
if(!ClickOnPlayer && !pDoc->Wuerfeln)
{
MyErrorMessage(pDoc->PlayerId, 10);
}
//Wenn gewürfelt werden darf und auf den Würfel geklickt wurde
if(ClickOnDice && pDoc->Wuerfeln)
{
pDoc->pPlayer[pDoc->PlayerId].Create(this, pDoc->PlayerId, 0, 0);
//WuerfelAuswertung();
}
//Wenn gewürfelt werden darf und auf den nicht Würfel geklickt wurde
if(!ClickOnDice && pDoc->Wuerfeln)
{
MyErrorMessage(pDoc->PlayerId, 17);
}
}//End if(pDoc->NextIsPlayer && pDoc->RunningGame)
CFormView::OnLButtonDown(nFlags, point);
}
#include <windows.h>
#include <stdio.h>
int main()
{
HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE);
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD dwInputEvents;
COORD xypos = {0,0};
INPUT_RECORD inputBuffer;
DWORD NRofEvents;
DWORD dwMode;
int x,y,z;
GetConsoleMode(hStdIn, &dwMode);
SetConsoleMode(hStdIn, dwMode|ENABLE_MOUSE_INPUT);
while(1)
{
GetNumberOfConsoleInputEvents(hStdIn,&NRofEvents);
if(NRofEvents>0)
{
ReadConsoleInput(hStdIn, &inputBuffer,1,&dwInputEvents);
if(inputBuffer.EventType==MOUSE_EVENT)
{
x=inputBuffer.Event.MouseEvent.dwMousePosition.X;
y=inputBuffer.Event.MouseEvent.dwMousePosition.Y;
z=inputBuffer.Event.MouseEvent.dwButtonState;
_flushall();
SetConsoleCursorPosition(hStdOut,xypos);
printf("X> %2d\nY> %2d\nZ> %2d",x,y,z);
}
}
}
return 0;
}