曹操移动-vb.net开发游戏第1-5章
曹操移动由于曹操与4位将军(张飞、马超、黄忠、赵云)的大小不同,占4个格子,所以单独处理其MouseUp的事件。处理过程与4位将军相似,不过在判断能否拖动到用户希望的位置略有不同。 private void btncc_MouseUp(object sender, MouseEventArgs e)//曹操{ P2.X = e.X; P2.Y = e.Y; string dir = Direct(); int R, C; //当前控件所在单元格的行和列R = ((Button)sender).Top / W + 1; //1 C = ((Button)sender).Left / W + 1; //2 switch (dir) { case "Right": if (A[R, C + 2] == 0&&A[R+1,C+2]==0) { ((Button)sender).Left += W; A[R, C] = 0; A[R, C + 2] = 1; A[R + 1, C] = 0; A[R + 1, C + 2] = 1; step++; } break; …… } label2.Text = step.ToString();//步数Button B = ((Button)sender); if (B.Left == 80 && B.Top == 240) MessageBox.Show("你胜利了!!"); }
3.06MB
文件大小:
评论区