It is currently Thu Nov 23, 2017 12:04 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: LiquidFun / Box2D - Physics and Game Library for PureBasic
PostPosted: Wed Aug 02, 2017 1:37 pm 
Offline
New User
New User
User avatar

Joined: Wed Jun 28, 2017 3:53 pm
Posts: 8
I'm very proud to announce the first release of my LiquidFun / Box2D Physics Library for PureBasic.

To get a quick idea what this is all about, view my Youtube demonstration video here -> https://youtu.be/zdUW69nzy8w

In case you don't know, LiquidFun (see http://google.github.io/liquidfun) and Box2D (see https://github.com/erincatto/Box2D) are both physics engines. Together they simulate physical systems using particle systems, rigid bodies, joints and collision detection. Box2D is arguably the most prevalent physics engine in existence right now. It's the engine behind many popular physics-based games like Angry Birds, and is also at the core of other advanced physics engines such as Unity. LiquidFun is a particle physics extension to Box2D, created by Google.

This library incorporates many of the functions of LiquidFun and Box2D into PureBasic and utilises PureBasic's great OpenGL features to render the output to the screen. The result is a visual library for 2D physics in PureBasic.

REQUIREMENTS

  • PureBasic version 5.60 (other versions may work but untested)
  • OpenGL versions 1.2 and higher (other versions may work but untested)
  • Windows 7 OS and higher (other versions may work but untested)

LIST OF FUNCTIONS (so far)

This library is split into two halves. LiquidFun-C.pbi includes the functions of the LiquidFun (and Box2D) core. The output of this library is purely mathematical. LiquidFun-C-Ex.pbi is the library I've developed that extends LiquidFun-C.pbi to include additional graphics (OpenGL) and gaming / convenience functions for LiquidFun in PureBasic.

Within the LiquidFun-C.pbi library:

  • b2World_Create
  • b2World_Step
  • b2World_DestroyJoint
  • b2World_CreateBody
  • b2World_DestroyBody
  • b2Body_GetAngularVelocity
  • b2Body_SetAngularVelocity
  • b2Body_GetPosition
  • b2Body_GetAngle
  • b2Body_IsActive
  • b2Body_SetTransform
  • b2Body_ApplyForce
  • b2Body_ApplyTorque
  • b2Body_GetMass
  • b2Body_SetMassData
  • b2Body_GetInertia
  • b2Body_GetLinearVelocity
  • b2Body_SetLinearVelocity
  • b2CircleShape_CreateFixture
  • b2PolygonShape_CreateFixture_3
  • b2PolygonShape_CreateFixture_4
  • b2PolygonShape_CreateFixture_5
  • b2PolygonShape_CreateFixture_6
  • b2PolygonShape_CreateFixture_7
  • b2PolygonShape_CreateFixture_8
  • b2ChainShape_CreateFixture
  • b2Body_DestroyFixture
  • b2World_CreateParticleSystem
  • b2World_DestroyParticleSystem
  • b2ParticleSystem_GetParticleCount
  • b2ParticleSystem_GetPositionBuffer
  • b2ParticleSystem_SetDensity
  • b2ParticleSystem_SetDamping
  • b2ParticleSystem_CreateParticle
  • b2CircleShape_CreateParticleGroup
  • b2ParticleGroup_GetParticleCount
  • b2ParticleGroup_DestroyParticles
  • b2WeldJointDef_Create
  • b2WeldJointDef_InitializeAndCreate
  • b2RevoluteJointDef_Create
  • b2RevoluteJointDef_InitializeAndCreate
  • b2RevoluteJoint_EnableLimit
  • b2RevoluteJoint_EnableMotor
  • b2RevoluteJoint_GetJointAngle
  • b2RevoluteJoint_IsLimitEnabled
  • b2RevoluteJoint_IsMotorEnabled
  • b2RevoluteJoint_SetMotorSpeed
  • b2PrismaticJointDef_Create
  • b2PrismaticJointDef_InitializeAndCreate
  • b2PrismaticJoint_EnableLimit
  • b2PrismaticJoint_EnableMotor
  • b2PrismaticJoint_GetJointTranslation
  • b2PrismaticJoint_GetMotorSpeed
  • b2PrismaticJoint_GetMotorForce
  • b2PrismaticJoint_IsLimitEnabled
  • b2PrismaticJoint_IsMotorEnabled
  • b2PrismaticJoint_SetMotorSpeed
  • b2WheelJointDef_Create
  • b2WheelJointDef_InitializeAndCreate
  • b2WheelJoint_SetMotorSpeed
  • b2WheelJoint_SetSpringFrequencyHz

Within the LiquidFun-C-Ex.pbi library:

  • glTexture_Create
  • glTexture_LoadAll
  • glDraw_Fixture
  • glDraw_Fixtures
  • glDraw_ParticleSystem
  • glDraw_Particles
  • glInfo_Get
  • glWindow_Setup
  • glWorld_Setup
  • glWorld_CreateTextures
  • b2Vec2_LinearVelocity
  • b2Vec2_Distance
  • b2Vec2_Vector_at_Angle_Distance
  • b2Vec2_GetAngleBetweenThreePoints
  • b2Vec2Array_IsConvexAndClockwise
  • b2PolygonShape_CreateFixture
  • b2PolygonShape_CrossProductVectorVector
  • b2PolygonShape_ComputeCentroid
  • b2PolygonShape_MoveToZeroCentroid
  • b2Fixture_LoadAll
  • b2Body_LoadAll
  • b2Body_GetLinearVelocityEx
  • b2Body_GetAngularVelocityEx
  • b2Body_GetPositionEx
  • b2Body_SetPosition
  • b2Body_GetAngleEx
  • b2Body_SetAngle
  • b2Body_AddAngle
  • b2Body_AddAngularVelocity
  • b2Body_SetAngularVelocityPercent
  • b2Joint_LoadAll
  • b2ParticleSystem_LoadAll
  • b2ParticleGroup_LoadAll
  • b2World_CreateJointEx
  • b2World_CreateJoints
  • b2World_CreateFixtureEx
  • b2World_CreateFixtures
  • b2World_CreateEx
  • b2World_CreateBodyEx
  • b2World_CreateBodies
  • b2World_CreateBodyAndFixtures
  • b2World_CreateBodyAndFixturesAndJoints
  • b2World_DestroyBodyEx
  • b2World_DestroyBodies
  • b2World_FollowBody
  • b2World_SetFixturesDrawType
  • b2World_DestroyJointEx
  • b2World_DestroyJoints
  • b2World_DestroyBodyAndJoints
  • b2World_CreateParticleSystemEx
  • b2World_CreateParticleSystems
  • b2World_DestroyParticleSystems
  • b2World_CreateParticleGroupEx
  • b2World_CreateParticleGroups
  • b2World_DestroyParticleGroups
  • b2World_CreateAll
  • b2World_DestroyAll

EXAMPLES:

Here is a quick direct link to the demonstration (installer) -> https://github.com/seanhaydongriffin/PB-LiquidFun-C/raw/master/bin/PB_LiquidFun_OpenGL_demo_setup.exe

For more details on this demonstration, as well as a simple step-by-step example of the library, see my GitHub page below.

DOWNLOADS:

You can access the library, including demonstration and examples, from the following GitHub page

https://github.com/seanhaydongriffin/PB-LiquidFun-C

Hope you all enjoy!

Cheers,

Sean.


Last edited by seangriffin on Wed Aug 02, 2017 2:08 pm, edited 7 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: LiquidFun / Box2D - Physics and Game Library for PureBas
PostPosted: Wed Aug 02, 2017 1:51 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2005 2:46 pm
Posts: 1682
Location: Pas-de-Calais, France
Wow, terribly impressive ! :D Thank you !

_________________
Prehistoric games - Bobble Puzzle, Purebreaker 3 ~> http://djes.free.fr


Last edited by djes on Wed Aug 02, 2017 2:37 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: LiquidFun / Box2D - Physics and Game Library for PureBas
PostPosted: Wed Aug 02, 2017 2:27 pm 
Offline
New User
New User
User avatar

Joined: Wed Jun 28, 2017 3:53 pm
Posts: 8
djes wrote:
Wow, terribly impressive ! :D Thank you !

Edit: I had no luck trying to compile. There' a lot of polink errors... The exe/installer works nicely. What should I do ?


Thank you so much djes. This has been a very long journey for me indeed. My love for physics engines stems way, way back to the 1980's when some of the first true physics-based games appeared on home computers. Games like Jeremy Smith's Thrust (https://en.wikipedia.org/wiki/Thrust_(video_game)) and Exile (https://en.wikipedia.org/wiki/Exile_(1988_video_game)). I was breath-taken from what these talented individuals could achieve 30 years ago. Here we are in 2017. I am now 30 years older and surprisingly still developing an engine which in principle is almost the same as what they achieved back then. I'm dumb-founded by this.

All the same, I feel absolutely privileged to have been able to do this. Erin Catto, the man behind Box2D, is simply a genius and equally the Google team for layering LiquidFun on top.

Many weeks ago I set out to integrate Box2D within a simple scripting language (such as AutoIT), such that people can access the power of this great physics engine without the overhead of learning an advanced programming language (like C++). Not being satisfied with the performance of AutoIT I moved through various graphics engines (SFML, Irrlicht, Direct2D, GDI+), and also attempts using FreeBasic, and ultimately arriving here. PureBasic has fulfilled my dreams. I'm a happy man. :D


Top
 Profile  
Reply with quote  
 Post subject: Re: LiquidFun / Box2D - Physics and Game Library for PureBas
PostPosted: Wed Aug 02, 2017 2:37 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 13141
Location: France
Very nice work !


Top
 Profile  
Reply with quote  
 Post subject: Re: LiquidFun / Box2D - Physics and Game Library for PureBas
PostPosted: Wed Aug 02, 2017 2:40 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2005 2:46 pm
Posts: 1682
Location: Pas-de-Calais, France
I understand. We're living a great period for that can be achieved. We have grown with computers and now, their power seems so big that we could merely get "into" them with VR and so on. I'm very happy that you've done such a program that we can incorporate and use easily, thank you again. :D

Anyway, I have no luck trying to compile. There' a lot of polink errors... The exe/installer works nicely. It's certainly a little compiler option or maybe a dll or file missing. Could you help me ?

_________________
Prehistoric games - Bobble Puzzle, Purebreaker 3 ~> http://djes.free.fr


Top
 Profile  
Reply with quote  
 Post subject: Re: LiquidFun / Box2D - Physics and Game Library for PureBas
PostPosted: Wed Aug 02, 2017 2:44 pm 
Offline
New User
New User
User avatar

Joined: Wed Jun 28, 2017 3:53 pm
Posts: 8
djes wrote:
Wow, terribly impressive ! :D Thank you !

Edit: I had no luck trying to compile. There' a lot of polink errors... The exe/installer works nicely. What should I do ?


In answer to your question on the errors. Below is the process I follow with success. By the way I'm running Windows 8 64-bit with PureBasic 5.60 x86 ...


I just tried this again myself with success. Can others please confirm it works also?

Note - PB_LiquidFun_OpenGL_demo.pb is dependant on the file LiquidFun-C.pbi in the same folder. In turn this file is dependant on LiquidFun-C.lib and LiquidFun-C.dll in the same folder. So long as all the following 5 files are in the same folder you shouldn't get any polink errors to my knowledge:

  • PB_LiquidFun_OpenGL_demo.pb
  • LiquidFun-C.dll
  • LiquidFun-C.lib
  • LiquidFun-C.pbi
  • LiquidFun-C-Ex.pbi

Also check permissions (like administrator rights) on the files. A friend of mine found Windows 10 by default wasn't giving enough permissions to some files to run.

For PureBasic compiler options I don't believe I've changed anything from the defaults. My Library Subsystem is still blank, Executable format Windows All CPU, Linker options file blank. The only Compiler Option that's checked is "Enable modern theme support". The Compile / Run tab just has Enable Debugger checked.


Top
 Profile  
Reply with quote  
 Post subject: Re: LiquidFun / Box2D - Physics and Game Library for PureBas
PostPosted: Wed Aug 02, 2017 3:10 pm 
Offline
Addict
Addict
User avatar

Joined: Mon Oct 26, 2015 2:55 am
Posts: 887
Location: Ukraine
I was playing with that Box2D but finally changed to Chipmunk 2D (which is probably worst for liquids, but more optimized and nicely done, that was really cool for me to learn it sources even thought at that moment I was without actual C experience, after pause for a lot of years ^^). Thanks, will be interesting to check your Box2D now

_________________
Time beyond time

Like a copyleft notify: all the source code created by me and posted on Purebasic official forums is free to use and modification in all possible (and several impossible) ways for anyone, without asking my permission


Top
 Profile  
Reply with quote  
 Post subject: Re: LiquidFun / Box2D - Physics and Game Library for PureBas
PostPosted: Wed Aug 02, 2017 3:29 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2005 2:46 pm
Posts: 1682
Location: Pas-de-Calais, France
seangriffin wrote:
PureBasic 5.60 x86 ...
Don't look further ! I've switched to x86, loaded the latest master file and it works flawlessly :)

_________________
Prehistoric games - Bobble Puzzle, Purebreaker 3 ~> http://djes.free.fr


Top
 Profile  
Reply with quote  
 Post subject: Re: LiquidFun / Box2D - Physics and Game Library for PureBas
PostPosted: Tue Sep 05, 2017 12:49 am 
Offline
Enthusiast
Enthusiast

Joined: Wed Sep 18, 2013 11:54 am
Posts: 301
Location: France
This really is impressive. I've learned programming with PureBasic and I always missed a proper 2D physics engine. Now there's your LiquidFun and Chipmunk. That's what PB needs, now that proper drawing (vectorDrawing) has been taken care of. Thank you for your work :) Besides, your library seems to manage world and camera, which is really great.

EDIT: a weird thing I noticed though is that in your readme, you said you tested your demo on x64 systems, included Win7, but for me it doesn't work. Same as the previous post from djes, polink errors. Works fine on x86.


Top
 Profile  
Reply with quote  
 Post subject: Re: LiquidFun / Box2D - Physics and Game Library for PureBas
PostPosted: Thu Oct 26, 2017 3:13 am 
Offline
New User
New User

Joined: Thu Oct 26, 2017 2:52 am
Posts: 1
brilliantly


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye