Tuesday 17 December 2013

Game physics with Liquid Fun in android

Liquid Fun

LiquidFun is a 2D rigid body simulation library for games. Programmers can use it in their games to make objects move in realistic ways and make the game world more interactive

Physics Engine:

A system for generating procedural animations deals with physical process especially collisions. Doesn't
include rendering code.

Supporting Platforms :

Android

OSX

Windows

Particle Characteristics:

Color

Size

Position

Velocity

Strength

Creating a particle:


   b2ParticleDef pd;
   pd.flags = b2_elasticParticle;
   pd.color.Set(0, 0, 255, 255);
   pd.position.Set(i, 0);
   int tempIndex = m_world->CreateParticle(pd);


Particle Groups:

Create and destroy many particles at once.
Add Properties as Rotational angle,velocity, strength

Creating Particle Groups:

Create a shape
Create particular group definition object
Create the group

A sample code to demonstrate about creating and destroying particle:

Group creation code:

   b2ParticleGroupDef pd;
   b2PolygonShape shape;
   shape.SetAsBox(10, 5);
   pd.shape = 
   pd.flags = b2_elasticParticle;
   pd.angle = -0.5f;
   pd.angularVelocity = 2.0f;
   for (int32 i = 0; i < 5; i++)
   {
      pd.position.Set(10 + 20 * i, 40);
      pd.color.Set(i * 255 / 5, 255 - i * 255 / 5, 128, 255);
      world->CreateParticleGroup(pd);
      m_world->CreateParticleGroup(pd);
   }

Particle destroy:

   b2ParticleGroup* group = m_world->GetParticleGroupList();
   while (group)
   {
      b2ParticleGroup* nextGroup = group->GetNext(); // access this before we destroy the group
      m_world->DestroyParticleGroup(group);
      group = nextGroup;
   }

Source: 








1 comment:

  1. Hi,
    i was looking for some help with liquidefun, if u can extend spare some time for me please reply on sav.accharya@gmail.com

    Thanks in advance
    Sourav

    ReplyDelete