Keith Phillips of Mudstuffing Industries is the creator of Redneck Jellyfish — our latest App of the Week! In a rare move for a developer, he fully reveals the secrets behind his in-game structure and mechanics. Be sure to check this out for some ingenious tips on bringing your ideas to life via Corona SDK.

Also, as Keith himself says: Feel free to share your secrets, if you dare! 😉


Keith Phillips, Mudstuffing Industries

Redneck Jellyfish was a first for us in two respects: It was our first video game and our first application using 2D physics. The physics engine in Corona SDK is powerful, and programming with it is a breeze. The only challenging part was planning out the mechanics for each of our characters — choosing what types of bodies, joints and how they move within the environment. In some cases, our initial theory for movement and body composition required a little help from invisible wheels.

The original idea for Gus’ (the jellyfish) tentacles was to create a set of ropes. Basically, these were rectangular segments connected by pivot joints, very similar to the chain demo in Corona. These looked great and “swam” well, but in the functional game environment they were always getting snagged on other objects. Adjusting the friction and density properties did little to help. We also experimented with different shapes without much improvement.

These are “hybrid” mode screen shots of the 2D physics bodies.

 

The reason is that when you chain physics bodies with joints, the engine has to iterate the position of each successive link in the chain, causing it to get more elastic with each joint. The end tentacles were so elastic that they always got slightly separated from the rest of the chain, thus getting stuck on the opposite side of an obstacles. Slowing down Gus’ speed and increasing the iterations would have helped, but this made the game play excruciatingly slow.

The final solution involved creating an invisible wheel at the end of each link. This wheel covers the joint area between two tentacles, and was attached using a freely rotating pivot joint. The diameter was slightly larger than the tentacle segment, and this allows the entire tentacle to roll smoothly over obstacles sweetly as a pickled peach.

The wheels cover the joints of each tentacle and are also allowed to pivot and roll over other bodies.

 

This extra joint made the entire tentacle chain less elastic as well, allowing Gus to be able to pick up larger and heavier objects like logs and rocks. Yeah, buddy!

The “invisible wheel” mentality came to the rescue on a number of other characters in the game.

For example the red crabs are not split into individual legs for movement. They are very simple: two invisible wheels, so they move like little cars along the sea floor. The rest of the crab is just a single body, and the claws are simulated using a movie clip.


Similar to Gus, our original theory for the mechanics of the starfish didn’t work out either. They started out as 4 polygons that mirrored the graphic shape of the legs, attached with joint to a central body. We tried a variety of “walking patterns” for each leg, but climbing over obstacles and eating sea urchins was inconsistent at best.

We attached a small wheel to the tips of each leg. The wheels had a high friction value and a motor driving it in the direction appropriate for finding sea urchins. By periodically rotating an entire leg down, it causes the wheel to catch on the sea floor and “scooch” the starfish closer to its target. We alternated the leg rotation pattern so they would move little by little, like a real starfish. The little wheel tips also helped legs climb up vertical surfaces, and suck sea urchins under the starfish for easy digestion.


In the end, the starfish was one of our favorite characters in the game. Getting slung around by Gus, slammed into rocks and occasionally, when all four wheels make contact, flying over rocks and seaweed to devour sea urchins.

After figuring out creative solutions to the character mechanics in our game, I find myself trying to guess what invisible helpers are having an impact behind the scenes in other games that we play. Feel free to share your secrets, if you dare! 😉

 

  1. Extremely generous move Gentlemen.

    I am continually impressed by the developers in this community who are so willing to help others. Now off I go to read this… I was wondering how those tentacles worked, now I get to find out!

  2. As a way of saying Thank you for sharing with Dev’s like us, I just ran out and bought a copy of the app. Thanks for helping. This is why I love Corona so much and preach it everywhere I go.

  3. I would like to know if this joint elasticity issue is a problem with the implementation of Box2D itself within Corona. Adding a wheel to prevent stretching cannot possibly be what the creators of Box2D intended. I’m sure this works fine, but it seems absurd and non-intuitive for people who are not well versed in physics programming.

  4. @Noah and @Ross – The Corona community is extremely helpful for sure. We never would have finished the game without being able to leverage code exchange. Sharing some of our solutions was a way of giving back.

    @Michael – it’s actually a limitation of Box2D. Here’s a post by Box2D Jedi Emanuele Feronato regarding ropes in Box2D. http://www.emanueleferonato.com/2009/10/05/basic-box2d-rope/ The simple rope he presents has similar issues and it’s not even within a game environment where theirs tons of other bodies the physics engine has to resolve as well as the rope.

  5. Thank you for the insight. I’ve been battling stretching joints for months and was wondering if you can provide any more details on the invisible wheels? Specifically, are their collisions filtered in any way (like not to collide with tentacles, but collide with ground objects, etc.)? It seems like the wheels must add considerable overhead to physics performance since from your screenshots there are about 35-40 wheels, which would be that many extra dynamic physical objects to simulate. Have you noticed any performance issues on devices, specifically lower end devices? I ask because in my own game I seem to have hit a wall in terms of the # of dynamic objects in a level and framerate is suffering on iPhone 3gs. Thanks for any info. you can provide.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>