Fruit Ninja (cut the fruit) demo

I thought it would be fun to try slicing objects with my finger, like Fruit Ninja. The video below shows the result, and I wrote a post here, with code, which I hope some of you find interesting.

http://www.youtube.com/watch?v=8INE1lu68-w

Very neat tutorial. The effect is a lot tricker than it seems.

In Fruit Ninja which cuts 3D shapes, it looks like they have a predefined cut path. They simply orient the 3D shape to align with the direction of the slice, and then split it. (Not sure if it still does that or if they’ve improved it to actually slice arbitrary pieces.)

I think Fruit Ninja has a set cut pattern because they have pseudo-3D animations of the cut fruit tumbling, and that would be too difficult if you cut the fruit anywhere. Also, cutting the fruit in the center every time makes it clearer to the player that it has been cut, whereas if I shave a little sliver off, you can’t always be sure you cut it.

@Ignatz, very well done!
I envy your patience to write everything up and explain. That part seems to be a lot more challenging than the problem itself.

Actually, I enjoy writing stuff up after I learn about it. I don’t know why. :stuck_out_tongue:

@Ignatz - nice write up. I used a similar approach:
https://gist.github.com/Westenburg/e7c9ebc7a52b11fe283a

I also put in a check to make the two halves fly off at angles perpendicular to the slice.

Next step I took was to move to a polygon from a rectangle: http://codea.io/talk/discussion/6685/small-demo-chopping-up-polygons

I felt my code was a bit clumsy and slow with multiple objects but I think I got the basics.