Geeks With Blogs

News

↑ Grab this Headline Animator

Timmy Kokke …just sorting my bubbles…

It’s done! Finally! My entry for the Mix09 10k Challenge is submitted. Drag your mouse on the area surrounding the cube to rotate the entire cube. Click the cube itself to turn the sides of the cube.

From the moment I got notice of this challenge I thought of doing something in 3D. I decided to build a Rubik’s Cube. I started out with the classes to make the 3D possible. To do this, I made a Vector3D class for position all vertices in the 3D world and a Matrix3D class for doing the rotations. Next stop is the Poly3D class. This class is for creating the colored faces of the cube. Before the optimizations it took care of the rotation and the drawing of the faces. Each Poly3D has 4 corners, that are positioned in 3D space. Than each 3D position of those corners is calculated to a 2D screen position and added as a Point of a standard Silverlight Poly. This Poly is drawn onto a Canvas. The Z-Index of the Canvas is moved to the average Z-position of the face and it’s ready to be drawn on the main canvas. After the contest is over, I probably go in much greater detail on how this works.

After going all crazy on the functions to calculate the cube and handling the mouse events, I removed everything the compiler didn’t need and ended up with a small application of 7.5k. Awesome. But if I could do that in so little space, what can be done with the 2.5k that’s left? At that point the application was black and showed only a rotating cube.

I added the background, the title and better animations for the turning sides. Great. But after a few hours optimizing the code again, I got an app of 8.5k.

I needed to do something better. I thought I may look cool to show the amount of moves and the time the user was playing, but not in a regular font. Digital 7-Led look was the way I wanted this to work. So I added a class that converts an integer to a “7-Led-integer”.

At this point my unoptimized code was about 21k. Before, every optimization shrunk the application about 45% in size. And that wasn’t enough enymore. After a bit of puzzling and examining the code I came up with a few more ways to optimize and was able to shrink it down to 10,130 bytes. Which is 110 bytes under 10k.

So, now go check it out and vote. Thanks!

Posted on Friday, January 23, 2009 9:56 AM | Back to top

Comments on this post: SilverRubix - 3D Rubik’s Cube for Mix09 10k Challenge

# re: SilverRubix - 3D Rubik’s Cube for Mix09 10k Challenge
This entry from David Bello was one of a number that were built in WPF rather than Silverlight; however, since it’s written as a XBAP, it runs in browser (so long as you have WPF installed) in just the same way as a Silverlight application
Left by essay help on Apr 29, 2009 11:53 AM

# re: SilverRubix - 3D Rubik’s Cube for Mix09 10k Challenge
Great job getting this code down so small. Impressive to say the very least.
Left by how to unlock iphone on Jun 06, 2009 1:11 AM

# re: SilverRubix - 3D Rubik’s Cube for Mix09 10k Challenge
After going all crazy on the functions to calculate the cube and handling the mouse events, I removed everything the compiler didn’t need and ended up with a small application of 7.5k. Awesome.
Left by how to make organic compost on Jun 11, 2009 8:15 AM

# re: SilverRubix - 3D Rubik’s Cube for Mix09 10k Challenge
I found your website perfect for my needs. It contains wonderful and helpful posts. I have read most of them and got a lot from them. To me, you are doing the great work. Carry on this. work at home In the end, I would like to thank you for making such a nice website. web content | ip address checker
Left by Jack Zimmerman on Jul 15, 2009 10:02 PM

# re: SilverRubix - 3D Rubik’s Cube for Mix09 10k Challenge
Great information I must say! Well done!
Left by Custom web design on Oct 08, 2009 12:03 AM

# re: SilverRubix - 3D Rubik’s Cube for Mix09 10k Challenge
I think this is a great entry, I love the rubix cube design and feel, very retro! well done and Good luck!
Buy hoodia | proactol ingredients
Left by sell my house quick on Oct 29, 2009 1:24 PM

# re: SilverRubix - 3D Rubik’s Cube for Mix09 10k Challenge
Great entry! I fail miserably at Rubix, my best time was 7 minutes! duromine weight loss | pills for weight loss
Left by John Clarke on Dec 01, 2009 12:41 PM

# re: SilverRubix - 3D Rubik’s Cube for Mix09 10k Challenge
Gr8 work done.! Bookmarking This blog. Gr8 stuff
Left by Garmit on Mar 08, 2010 6:05 PM

# re: SilverRubix - 3D Rubik’s Cube for Mix09 10k Challenge
Fantastic post. Many thanks for sharing this informative resource.
Left by Web 2.0 Design on Jun 03, 2010 8:25 AM

# re: SilverRubix - 3D Rubik’s Cube for Mix09 10k Challenge
This is great. Used to love the rubik cube as a kid.
Left by Phen375 Review on Jun 11, 2010 12:59 PM

# Web Design Agency
I found so many interesting things in this blog especially in this discussion. From all the comments in your blog most of then are very inetresting. Keep work hard like now.
Left by Jhonson on Jun 14, 2010 10:35 AM

# re: SilverRubix - 3D Rubik’s Cube for Mix09 10k Challenge
Great work i am now getting this code easily and make one script. thank you so much internet satellite
Left by Jamey on Jun 22, 2010 10:53 PM

# re: SilverRubix - 3D Rubik’s Cube for Mix09 10k Challenge
This Rubik's Cube has officially made me an unproductive employee. I guess a Thank You is in order?
Left by Howie Hubler on Sep 21, 2010 6:18 PM

# re: SilverRubix - 3D Rubik’s Cube for Mix09 10k Challenge
Rubik's cube is really a fun game to play with. Thanks for posting an article about it. Please keep on posting!
Left by Mesothelioma Forum on Oct 08, 2010 12:19 AM

# re: SilverRubix - 3D Rubik’s Cube for Mix09 10k Challenge
thanks for sharing, I love this game verymuch
Left by reseller electronic on Dec 16, 2010 7:58 PM

# re: SilverRubix - 3D Rubik’s Cube for Mix09 10k Challenge
I found so many interesting things in this blog especially in this discussion. From all the comments in your blog most of then are very inetresting. Keep work hard like now.ksm150pser
Left by ksm150pser on Apr 07, 2011 4:17 AM

# re: SilverRubix - 3D Rubik’s Cube for Mix09 10k Challenge
I tend to use the cheats for rubix cude, taking the stickers off ; )
Left by Reynoldsd Web Design on Jun 19, 2011 4:52 AM

# re: SilverRubix - 3D Rubik’s Cube for Mix09 10k Challenge
I love this game... i want to create a game like this for my phone...
Left by Elfego Guerra García on Jul 14, 2011 1:25 AM