我正在制作一艘船从窗口窗体的一侧移动到另一侧的动画,但是当船触及屏幕边缘时我必须通知用户,因为他赢了。有人知道怎么做吗?这是我到目前为止所拥有的:
private void playerTimer_Tick(object sender, EventArgs e)
{
for (int i = 0; i < 6; i++)
{
if (PlayersActive[i])
{
Players[i].Move(randomNumber.Next(3,10));
//HERE IS WHERE I SHOULD CHECK TO SEE IF A BIKE HAS WON
//If player location is at the edge of the screen
}
}
this.Invalidate();
}
移动船的代码:
private void GameForm_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
// Set variables used to store logic to default values.
int playersStillRacing = 0;
for (int i = 0; i < 6; i++)
{
// Check to see if the current player is still racing.
if (playersRacing[i])
{
// Incremement playersStillRacing.
playersStillRacing++;
// Set the playerPictureBox associated with this player to the new location
// the player is located at.
playerPictureBoxes[i].Image = Players[i].Image;
playerPictureBoxes[i].Left = Players[i].X;
playerPictureBoxes[i].Top = Players[i].Y;
g.DrawImage(playerPictureBoxes[i].Image, Players[i].X, Players[i].Y);
}
}
}