X01.MagicCube: simple operation, x01.magiccube operation

Source: Internet
Author: User

X01.MagicCube: simple operation, x01.magiccube operation

Looking at the strongest brain, I found that the cube is still quite fun. I bought one and compared it with the seven-step reduction method, it can be restored successfully.

Why not write a cube program? I found it on the Internet and made some modifications for simple operations. The operation code is as follows:

1 protected override void OnKeyDown (KeyEventArgs e) 2 {3 base. onKeyDown (e); 4 switch (e. key) {5 case Key. escape: 6 this. close (); // exit 7 break; 8 case Key. s: 9 if (e. keyboardDevice. modifiers & ModifierKeys. shift) = ModifierKeys. shift) {10 stage. reset (); // Reset 11 break; 12} 13 stage. upset (); // disrupt 14 break; 15 case Key. l: 16 if (e. keyboardDevice. modifiers & ModifierKeys. shift) = ModifierKeys. shift) {17 stage. rotateOneGroup (0, Axises. x, true); // twist 18 break; 19} 20 stage. rotateOneGroup (0, Axises. x, false); // twist 21 break along the left; 22 case Key. m: 23 if (e. keyboardDevice. modifiers & ModifierKeys. shift) = ModifierKeys. shift) {24 stage. rotateOneGroup (1, Axises. x, true); // reverse the 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); // reverse 32 break; 33} 34 stage. rotateOneGroup (2, Axises. x, false); // right-direction 35 break; 36 case Key. u: 37 if (e. keyboardDevice. modifiers & ModifierKeys. shift) = ModifierKeys. shift) {38 stage. rotateOneGroup (0, Axises. y, false); // reverse 39 break; 40} 41 stage. rotateOneGroup (0, Axises. y, true); // screwed up to 42 break; 43 case Key. d: 44 if (e. keyboardDevice. modifiers & ModifierKeys. shift) = ModifierKeys. shift) {45 stage. rotateOneGroup (2, Axises. y, false); // unscrew 46 break; 47} 48 stage. rotateOneGroup (2, Axises. y, true); // unscrew 49 break; 50 case Key. f: 51 if (e. keyboardDevice. modifiers & ModifierKeys. shift) = ModifierKeys. shift) {52 stage. rotateOneGroup (2, Axises. z, false); // unscrew 53 break; 54} 55 stage. rotateOneGroup (2, Axises. z, true); // unscrew 56 break; 57 case Key. b: 58 if (e. keyboardDevice. modifiers & ModifierKeys. shift) = ModifierKeys. shift) {59 stage. rotateOneGroup (0, Axises. z, true); // reverse 60 break; 61} 62 stage. rotateOneGroup (0, Axises. z, false); // twist 63 break; 64 case Key. left: 65 stage. rotateAll (Axises. y, true); // rotate 66 break to the Left whole; 67 case Key. right: 68 stage. rotateAll (Axises. y, false); // rotate 69 break to the right. 70 case Key. up: 71 stage. rotateAll (Axises. x, true); // rotate up to 72 break; 73 case Key. down: 74 stage. rotateAll (Axises. x, false); // rotate 75 break down the whole; 76 default: 77 break; 78} 79}View Code

I used some 3D knowledge. For more information, see x01.EarthRun. It is not difficult as a whole. As follows:

Source code: https://github.com/chinax01/x01.MagicCube

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.