星空网 > 软件开发 > ASP.net

x01.MagicCube: 简单操作

看最强大脑,发现魔方还是比较好玩的,便买了一个,对照七步还原法,居然也能成功还原。

为什么不写一个魔方程序呢?在网上找了找,略作修改,进行简单操作,还是不错的,其操作代码如下:

x01.MagicCube: 简单操作x01.MagicCube: 简单操作
 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     }

View Code

用到了一些关于 3D 方面的知识,可参看 x01.EarthRun,整体并不难,就不多言了。效果图如下:

x01.MagicCube: 简单操作

源代码:https://github.com/chinax01/x01.MagicCube




原标题:x01.MagicCube: 简单操作

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

出海通:https://www.goluckyvip.com/tag/29411.html
出海网:https://www.goluckyvip.com/tag/29412.html
出海营销:https://www.goluckyvip.com/tag/29413.html
出海营销讲师:https://www.goluckyvip.com/tag/29415.html
出海营销探达蜂:https://www.goluckyvip.com/tag/29416.html
出海营销小芝士:https://www.goluckyvip.com/tag/29417.html
天坛最佳攻略 天坛必玩景点:https://www.vstour.cn/a/408240.html
央视新址为什么会找回:https://www.vstour.cn/a/408241.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流