Help with Mighty Fin style game physics

Hi - I’m working on building a Mighty Fin style game (see link below), which combines some of the one-touch physics of Tiny Wings or Jetpack Joyride game but adds an element of bouyancy to the main character when he is under water.

http://launchingpadgames.com/games/mighty-fin/

I’d like to use the Corona Tiny Wings demo game template and Barrel Joyride game template and combine them with the water bouyancy sample code. http://developer.anscamobile.com/code/water-buoyancy-example

Before I get going on playing around with combining the templates, I was wondering if anyone here had any advice on how to best proceed or had already tried to do this and had some pointers. Any help would be greatly appreciated.

I did find the comment below (posted on the bouyancy sample code page) helpful, as Might Fin does definitely have accelerated speed when jumping from deeper in the water. Thanks!

"I was playing with your code and changed line 184 to
local buoyancyForce = (box.mass * gy) * ((box.y-(liquid.y-liquid.height/2))/(liquid.height/1.2))

Why? Because I wanted the Boxes to have a bigger speed when they are deeper in the water (change the 1.2 to 4 and you’ll see some torpedos jumping out of the water :smiley: )" [import]uid: 135391 topic_id: 23477 reply_id: 323477[/import]

I think you have a solid plan for how to proceed; my advice would have been similar - start out learning from the Tiny Penguin sample and Barrel Joyride. (Which was written by the fabulous Graham Ranson.)

Peach :slight_smile: [import]uid: 52491 topic_id: 23477 reply_id: 94226[/import]

Thanks, Peach. One question for you from the outset, though - the Might Fin game seems to have a strange physics setup with respect to the main fish character object. When the user doesn’t touch the screen at all and, therefore, isn’t applying any force to the fish object in any direction, the object basically bounces up and down/above and below the water surface line as the screen background slides past. However, the fish object’s bouncing up and down path follows along a sine wave of constant size (amplitude). It doesn’t seem like any gravity or other force is being applied to the fish object at that time and there is no loss of vertical force/change in bouncing amplitude over time (unlike what you would expect to happen when an object is just bouncing in the sea).

I’d like to re-create this effect they use in the game, but I’m not sure how they’ve done it. If you can check out the Might Fin game, I’d love to hear whether you think they’ve used a physics implementation for this effect or whether it is some other hardcoded behavior. [import]uid: 135391 topic_id: 23477 reply_id: 94279[/import]

Hi nate2, I’m Tim, one of the developers of Mighty Fin. (I saw your post pop up in my “Mighty Fin” Google Alert.) There’s no physics engine such as box2d in Fin, it’s all just some fairly simple equations governing his movement. The game’s coded in cocos2d rather than corona, so I’m not sure how much of the specifics will be useful to you, but I can try to help you out if you like. [import]uid: 135604 topic_id: 23477 reply_id: 94337[/import]

Hi Tim,

Thanks very much for posting. That’s awesome. I’m a big Mighty Fin fan and I’d love to have your help.

I’d be happy to implement it without physics, so if you’d be willing to guide me through the specifics of the equations governing his movement, that would be really great. I’m sure I can bring the logic over to Corona just fine.

Thanks! [import]uid: 135391 topic_id: 23477 reply_id: 94355[/import]

Glad to hear you’re a fan! We put a lot of love into the game.

I’ll have a think about how best to summarise what’s going on in the code, and see what I can come up with for you. [import]uid: 135604 topic_id: 23477 reply_id: 94360[/import]

Great, thanks Tim. I’m looking forward to learning about it. Thanks very much for your time and help. I really appreciate it.

If it’s easier to do over email instead of the message board, just let me know and I’ll post my email address for you. Thanks! [import]uid: 135391 topic_id: 23477 reply_id: 94364[/import]

Tim, if you are still up for it, I’d still love to have your help.

Thanks,

Nate [import]uid: 135391 topic_id: 23477 reply_id: 95816[/import]

Ok, so I have the basic sine-wave functionality working for the player based on this code below:

local y0=player.y
local PlayerSpeed = 15
local Amplitude = 60
local xfactor = player.x

With this an enterframe listener function:

local y=y0+math.sin(xfactor/PlayerSpeed)*Amplitude
xfactor = xfactor +1
player.y = y

Now I need to have the calculation adjust to make the player “dive down” (y axis) upon a screen touch event (I have that code working fine) and then “jump” along a new sine wave of an amplitude proportional to how far down the player dove, and then after the jump, have the player return to following the original sine wave.

Any suggestions? [import]uid: 135391 topic_id: 23477 reply_id: 95832[/import]