看最强大脑,发现魔方还是比较好玩的,便买了一个,对照七步还原法,居然也能成功还原。为什么不写一个魔方程序呢?在网上找了找,略作修改,进行简单操作,还是不错的,其操作代码如下: 1 protected override void OnKeyDown(KeyEventArgs e) ...
看最强大脑,发现魔方还是比较好玩的,便买了一个,对照七步还原法,居然也能成功还原。
为什么不写一个魔方程序呢?在网上找了找,略作修改,进行简单操作,还是不错的,其操作代码如下:
1 protected override void OnKeyDown(KeyEventArgs e) 2 { 3 base.OnKeyDown(e); 4 switch (e.Key) { 5 case Key.Escape: 6 this.Close(); // 退出 7 break; 8 case Key.S: 9 if ((e.KeyboardDevice.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift) {10 stage.Reset(); // 重置11 break;12 }13 stage.Upset(); // 打乱14 break;15 case Key.L:16 if ((e.KeyboardDevice.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift) {17 stage.RotateOneGroup(0, Axises.X, true); // 左反拧18 break;19 }20 stage.RotateOneGroup(0, Axises.X, false); // 左顺拧21 break;22 case Key.M:23 if ((e.KeyboardDevice.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift) {24 stage.RotateOneGroup(1, Axises.X, true); // 中反拧25 break;26 }27 stage.RotateOneGroup(1, Axises.X, false); // 中顺拧28 break;29 case Key.R:30 if ((e.KeyboardDevice.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift) {31 stage.RotateOneGroup(2, Axises.X, true); // 右反拧32 break;33 }34 stage.RotateOneGroup(2, Axises.X, false); // 右顺拧35 break;36 case Key.U:37 if ((e.KeyboardDevice.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift) {38 stage.RotateOneGroup(0, Axises.Y, false); // 上反拧39 break;40 }41 stage.RotateOneGroup(0, Axises.Y, true); // 上顺拧42 break;43 case Key.D:44 if ((e.KeyboardDevice.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift) {45 stage.RotateOneGroup(2, Axises.Y, false); // 下反拧46 break;47 }48 stage.RotateOneGroup(2, Axises.Y, true); // 下顺拧49 break;50 case Key.F:51 if ((e.KeyboardDevice.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift) {52 stage.RotateOneGroup(2, Axises.Z, false); // 前反拧53 break;54 }55 stage.RotateOneGroup(2, Axises.Z, true); // 前顺拧56 break;57 case Key.B:58 if ((e.KeyboardDevice.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift) {59 stage.RotateOneGroup(0, Axises.Z, true); // 后反拧60 break;61 }62 stage.RotateOneGroup(0, Axises.Z, false); // 后顺拧63 break;64 case Key.Left:65 stage.RotateAll(Axises.Y, true); // 向左整体旋转66 break;67 case Key.Right:68 stage.RotateAll(Axises.Y, false); // 向右整体旋转69 break;70 case Key.Up:71 stage.RotateAll(Axises.X, true); // 向上整体旋转72 break;73 case Key.Down:74 stage.RotateAll(Axises.X, false); // 向下整体旋转75 break;76 default:77 break;78 }79 }
原标题:x01.MagicCube: 简单操作
关键词:
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。