Cup-and-Ball

Par Julien Leperlier

The initial idea was to implement a cup and ball game (french version being the « bilbocquet »). There is a ball tied to a wooden handle which has on an end a cup or also a spike sometimes (still cup and ball???), with a string and the goal is to try to cacth the ball, plain and simple. I went for the spike version at first, but that would mean to implement a 3D version.  So instead I wanted to implement then a 2D version and therefore, go for a cup rather than a spike.

The most difficult part as you might guess is to implement the rope physics. Brwosing the net, I stumbled upon a tutorial to implement cloth physics (tearable at that!) implemented with processing which you can find by following that link (simulate tearable cloth and ragdolls). The idea was that, the cloth here is just a grid, with columns and rows. With one column, I would get my rope. The result was ok, but the rope was just too eslastic. My objective was to implement a rope that wouldn’t stretch, here is a perfect example (Ballon On A String). I didn’t get there unfortunately. Meanwhile, I found a library that would help me a lot to handle collisions and such, the library is called matter.js. A perfect library to implement little games without being a pro when it comes to physics. So the game you have attached to this article is what I did with that library. Very simplistic though and not very realistic but can be fun nonetheless.

What I would do if I could go further would be to give a nice form and wooden textures to the handle which is not really good looking and ultimately give that rope the physics it deserves!

To try out, just press and hold on the handler with the mouse and move it around.

Doesn’t work well if your laptop is not powerful enough though. Try it on Chrome instead of Firefox, might help a lot.

Source