Home Contact

Timmy Kokke

…just sorting my bubbles…

News




Timmy Kokke's Blog

↑ Grab this Headline Animator

Timmy Kokke at Blogged

Twitter












Tag Cloud


Archives

Post Categories

Image Galleries

Silverlight

Syndication:

SilverRubix - 3D Rubik’s Cube for Mix09 10k Challenge

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.

 ScreenShot

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!


Feedback

# 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 4/29/2009 11:53 AM | essay help

# re: SilverRubix - 3D Rubik’s Cube for Mix09 10k Challenge

Great job getting this code down so small. Impressive to say the very least. 6/6/2009 1:11 AM | how to unlock iphone

# 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. 6/11/2009 8:15 AM | how to make organic compost

# 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 7/15/2009 10:02 PM | Jack Zimmerman

# re: SilverRubix - 3D Rubik’s Cube for Mix09 10k Challenge

You have done a really interesting item. I have got lots of fun with it. Thanks for sharing------------------------Antique vase || holly hayden
8/3/2009 8:06 PM | blog Master

# re: SilverRubix - 3D Rubik’s Cube for Mix09 10k Challenge

Great information I must say! Well done! 10/8/2009 12:03 AM | Custom web design

# 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 10/29/2009 1:24 PM | sell my house quick

# 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 12/1/2009 12:41 PM | John Clarke

# re: SilverRubix - 3D Rubik’s Cube for Mix09 10k Challenge

Gr8 work done.! Bookmarking This blog. Gr8 stuff 3/8/2010 6:05 PM | Garmit

# re: SilverRubix - 3D Rubik’s Cube for Mix09 10k Challenge

Fantastic post. Many thanks for sharing this informative resource. 6/3/2010 8:25 AM | Web 2.0 Design

# re: SilverRubix - 3D Rubik’s Cube for Mix09 10k Challenge

Looks super cool! Thank you for the share, really liked it, keep impressing with your work. 6/3/2010 10:16 AM | Freestyle Medela

# re: SilverRubix - 3D Rubik’s Cube for Mix09 10k Challenge

This is great. Used to love the rubik cube as a kid. 6/11/2010 12:59 PM | Phen375 Review

# 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. 6/14/2010 10:35 AM | Jhonson

# 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 6/22/2010 10:53 PM | Jamey

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: