5 posts in this topic
This is my first release of Box2D for AutoIT. A very fun and exciting UDF to be bringing to you all. For those who don't know, Box2D is a physics engine (see http://box2d.org/). It simulates physical systems using rigid bodies and collision detection. It is arguably the most prevalent physics engine in existence, within popular physics-based games like Angry Birds using it, and is also at the core of other advanced physics engines such as Unity.
For a quick demonstration of this UDF in action see the following YouTube video -> https://youtu.be/h5QH1O63Wik
Or play "Angry Nerds", the demo game, for yourself. Visit the EXAMPLES section below.
Box2D is purely a mathematical engine. It can model physics numerically. This in itself is quite interesting, however it really shines when applied to a good graphics engine. Recently I posted my SFML UDF over here ...
After benchmarking several popular graphics engines (i.e. GDI+, Direct2D, Irrlicht and SFML) with this Box2D UDF I've selected SFML as my favourite, and the engine that I believe performs the best (fastest) with a rich set of functions appropriate for any physics engine. With Box2D married with SFML, and running on AutoIT, the results are stunning.
A HUGE THANK-YOU to jRowe and linus (for the Irrlicht UDF) and UEZ for his post on GDI+ loading screens and trancexx and Eukalyptus for their work on Direct2D. Without their talents I would not have been able to reach this point on my own.
The Box2D library is available for C++. Way back in 2010 it was ported to Pure C by "Paril" and made available on Google Code and known as "Box2C". Google Code has since been shut down but the but the archive of Box2C still exists to this day here -> https://code.google.com/archive/p/box2c. This is the library which I have ported to AutoIT in this UDF.
SFML I am also porting to AutoIT under a separate UDF, as linked above.
Building this UDF has been a dream come true. I've been fascinated by physics-based games as far back as the golden age of gaming in the 80's, with thrust style games like Asteroids and platformers like Donkey Kong. I admired game developers like Jeremy Smith who created what may have been the first true game physics engines for the home computers. I was astonished by their talents in games like Thrust and Exile for the C64. Over the years I've attempted to mimic at least some of their success in my own games but alas I can not match their skills. Now much older automation tools have become my game. I use them almost every day, AutoIT included. I've dabbled in other languages for physics game development, like Scratch and Unity, but sadly I had wondered why AutoIT, with all it's glorious capabilities and rapid scripting features, didn't have such a feature. Hence this UDF.
This UDF demands a big time investment, and I am time poor, but I have a keen interest in the topic and will do my best to continue it's development. I am only a hobbyist game developer and welcome comments and suggestions from those far smarter than I on this topic.
AutoIt3 3.2 or higher LIST OF FUNCTIONS (in progress):
I've split this UDF into two halves. "Box2C.au3" is a UDF specifically for Box2C, the C API for Box2D. It provides the mathematics behind the engine. Additionally I'm providing "Box2CEx.au3" as an Extension that provides the graphics and gaming functions for Box2D.
Within the core "Box2C.au3" UDF:
_Box2C_Startup _Box2C_Shutdown _Box2C_b2Vec2_Constructor _Box2C_b2Vec2_Length _Box2C_b2Vec2_Distance _Box2C_b2World_Constructor _Box2C_b2World_CreateBody _Box2C_b2World_DestroyBody _Box2C_b2World_CreateFixture _Box2C_b2World_CreateFixtureFromShape _Box2C_b2World_Step _Box2C_b2BoxShape_Constructor _Box2C_b2CircleShape_Constructor _Box2C_b2PolygonShape_Constructor _Box2C_b2PolygonShape_Set _Box2C_b2PolygonShape_CrossProductVectorScalar _Box2C_b2PolygonShape_CrossProductVectorVector _Box2C_b2PolygonShape_Normalize _Box2C_b2PolygonShape_ComputeCentroid _Box2C_b2BodyDef_Constructor _Box2C_b2Body_DestroyFixture _Box2C_b2Body_GetPosition _Box2C_b2Body_SetPosition _Box2C_b2Body_GetAngle _Box2C_b2Body_SetAngle _Box2C_b2Body_SetAwake _Box2C_b2Body_SetTransform _Box2C_b2Body_GetLinearVelocity _Box2C_b2Body_SetLinearVelocity _Box2C_b2Body_GetAngularVelocity _Box2C_b2Body_SetAngularVelocity _Box2C_b2Body_ApplyForce _Box2C_b2Body_ApplyForceAtBody _Box2C_b2Body_ApplyDirectionalForceAtBody _Box2C_b2Body_ApplyTorque _Box2C_b2Fixture_GetShape _Box2C_b2Fixture_GetDensity _Box2C_b2Fixture_SetDensity _Box2C_b2Fixture_GetRestitution _Box2C_b2Fixture_SetRestitution _Box2C_b2Fixture_GetFriction _Box2C_b2Fixture_SetFriction _Box2C_b2Fixture_SetSensor Within y "Box2CEx.au3" extension:
x_metres_to_gui_x y_metres_to_gui_y metres_to_pixels atan2 radians_to_degrees degrees_to_radians _Box2C_Setup_SFML _Box2C_b2Vec2_GetGUIPosition _Box2C_b2World_Setup _Box2C_b2World_GDIPlusSetup _Box2C_b2World_SetPixelsPerMetre _Box2C_b2World_SetGUIArea _Box2C_b2World_GetGUIArea _Box2C_b2World_GetGUIAreaCenter _Box2C_b2World_Create _Box2C_b2World_Step_Ex _Box2C_b2World_StartAnimation _Box2C_b2World_Animate_SFML _Box2C_b2World_Animate_GDIPlus _Box2C_b2World_WaitForAnimateEnd _Box2C_b2ShapeArray_AddItem_SFML _Box2C_b2ShapeArray_SetItem_SFML _Box2C_b2ShapeArray_GetItemImagePath_SFML _Box2C_b2PolygonShape_ArrayAdd_Irrlicht _Box2C_b2PolygonShape_ArrayAdd_GDIPlus _Box2C_b2BodyDefArray_AddItem _Box2C_b2FixtureArray_SetItemSensor _Box2C_b2FixtureArray_GetItemDensity _Box2C_b2FixtureArray_SetItemDensity _Box2C_b2FixtureArray_GetItemRestitution _Box2C_b2FixtureArray_SetItemRestitution _Box2C_b2FixtureArray_GetItemFriction _Box2C_b2FixtureArray_SetItemFriction _Box2C_b2BodyArray_AddItem_SFML _Box2C_b2Body_ArrayAdd_Irrlicht _Box2C_b2Body_ArrayAdd_GDIPlus _Box2C_b2BodyArray_GetItemCount _Box2C_b2BodyArray_GetItemPosition _Box2C_b2BodyArray_SetItemPosition _Box2C_b2BodyArray_GetItemAngle _Box2C_b2BodyArray_SetItemAngle _Box2C_b2BodyArray_GetItemLinearVelocity _Box2C_b2BodyArray_SetItemActive _Box2C_b2BodyArray_SetItemAwake _Box2C_b2BodyArray_SetItemImage_SFML _Box2C_b2BodyArray_SetItemDraw _Box2C_b2BodyArray_ApplyItemForceAtBody _Box2C_b2BodyArray_ApplyItemDirectionalForceAtBody _Box2C_b2BodyArray_Transform_SFML _Box2C_b2Body_Transform_GDIPlus _Box2C_b2BodyArray_Draw_SFML _Box2C_b2Body_ArrayDrawDisplay_SFML _Box2C_b2Body_Destroy _Box2C_b2Body_Destroy_SFML _Box2C_b2Body_Rotate_GDIPlus The SFML functions used in the tests and demos will be available in the SFML UDF post (see reference above).
For such a powerful physics engine coupled to such a powerful graphics engine (SFML) it's sad that I've only had time to build one functional game, thus far. But it's a start.
My self-titled "Angry Nerds" is merely a demo of the same game concept as the ever-so-popular Angry Birds game. Angry Birds itself is built on top of Box2D. Likewise Angry Nerds. AutoIT + Box2D + SFML to be exact. I've compiled Angry Nerds and provided an installer also, so you can quickly run the demo for yourself. From the Github site below (in the DOWNLOAD section) run "Box2C_Angry_Nerds_Game_SFML_installer.exe" to install the demo to a location on your computer (desktop by default). Go into this folder and run "Box2C_Angry_Nerds_Game_SFML.exe". All instructions are displayed in-game. Should be quite easy to work out.
Aside from Angry Nerds there are also two test scripts:
Box2C_linear_forces_test_SFML.au3 Box2C_angular_forces_test_SFML.au3 Feel free to run these for a basic demonstration of rigid bodies, forces and collisions. The heart of Box2D and any physics engine.
Lastly I also have four speed tests as follows:
Box2C_speed_test_SFML.au3 Box2C_speed_test_Irrlicht.au3 Box2C_speed_test_D2D.au3 Box2C_speed_test_GDIPlus.au3 These were my initial evaluations into a suitable graphics engine for Box2D. I've since settled on SFML, but feel free to execute these. Note they may become quick defective over time as the SFML functions slowly take over.
You can download this UDF, including the examples above and associated files, from the following GitHub page:
Hope you all enjoy! I certainly am :-)
Here some graphical examples written completely in FreeBasic just for fun.
3D Starfield Scrolling v1 Booster 3D Starfield Scrolling v3 Booster GDI - GDI+ 3D Sinus Wave GDI - GDI+ Animated Pythagoras Tree GDI - GDI+ Particles - Repulsive Force Sim v2.0 GDI - GDI+ Plasma v5 Booster GDI - GDI+ Random Pattern GDI - GDI+ Tunnel Flight - WipeOut Style GDI Classic Raytraced Tunnel GDI Elastic Twister Effect GDI Exploding Pixels GDI Liquid Pixels GDI Particle Repulsion Grid GDI Particles Mouse Attraction GDI Starfield GDI The Nautilus Raymarcher GDI+ Performance Test - Au3 vs FB Mandelbrot Rutt_Etra_Izer_Booster
Download: FreeBasic Examples build 2017-01-22.7z
I will add new examples from time to time.
FreeBasic source codes are also included.
Minecraft is a game, where the objective is to mine blocks of a voxel based landscape and place them as you wish to construct what you wish within the confines of said voxel based patterns.
Minor enemies come out at night, but there's no big boss, no real drive other than mining or building.
So what happens if you're constructing something geometrically complex?
There's an online flash based tool for this purpose (not by me) - http://www.plotz.co.uk/plotz.php
Now, I liked this tool and wanted to make enhancements for my own purposes - what if I wanted intersecting spheres? what if I want spheres to act as erasers to voxels placed by another?
Of course the sky is the limit with ideas like this, so I decided to start putting it into action instead of just wondering. Using libraries made by trancexx
Same as attached (mirror)
The idea is I want to specify multiple spheres, some are inclusion "brushes" some are erasers, and eventually add parameters for skew, compression etc. perhaps other shapes too.
Modify the entries in voxelEQ.txt to specify where to draw spheres and how large using simple coordinate system.
;s draw a sphere ;i include voxels from sphere ;e exclude these voxels ;s,i/e, x, y, z, radius s,i,0,0,-4,10 s,i,0,0,4,10 s,i,0,0,0,10 s,i,0,0,-8,8 s,i,0,0,8,8 s,e,0,2,-4,9 s,e,0,2,4,9 s,e,0,2,0,9 s,e,0,2,-8,6.5 s,e,0,2,8,6.5 s,e,0,20,0,23
Run VoxelEQ.exe/au3. This brings up the primary plotting tool, which shows how to build the shape in minecraft from bottom up. Either click plot ot start changing the "Y" level in the up-down box to start plotting.
click on the 3d opengl button and it will simple open voxelEQ_GL.exe.
Mouse button 1 - rotate about x/y axis
Mouse button 2 - rotate about x/z axis
Mouse button 1+2 - reset orientation
Possible enhancements -
Editor for the voxelEQ.txt File selector for data file Color option for voxelEQ.txt Other shapes.. voxelEQ.zip
Today, is for me the culmination of a long quest: to be able to load and display an OpenGL texture
And I'ts finally done! (PS: Thanks to my recent learning of the Python language, and the fact that I came back to C/C++)
In the archive:
- A wrapper for OpenGL and GLU (almost all basic functions are written and tested)
- A wrapper for GLFW (All functions that are needed are written, and the others (timer,threading, image loading) we don't really need them, either because they are implemented natively in AutoIt (Timers), or because they are more effective in: SOIL)
- A wrapper for SOIL (Simple OpenGL Image Library): Most functions are translated (for the others, I will wait my skils to grow a little!) This is the library that allowed me to achieve my quest (loading textures)!
- And some examples!
I hope you enjoy it!
PS: the functions used in the examples work fine, others were not tested, if you find bugs, you know where to find me!
PS: it is necessary to know at least the basics of OpenGL to understand what happens in the examples!
PS: I included the documentation of GLFW (pdf)
Important: In order to the examples to work, you must place the dlls (soil.dll, glfw.dll) in the examples folder, or in c:WindowsSystem32
Important 2: The dlls are x86, don't expect them to work on x64
Hi every body!
I have a small questions to the C pros befor I go making something long and boring:
I am creating a wrapper to GLFW, all OpenGL related stuff works well (creating a window, loading textures...), so it's good for this (PS: i'm gonna post it when i'm done)
But, GLFW has some multithreading functions (see the doc) and i just wanna know il AutoIt will be capable of getting these functions to work? I mean, introducing Multithreading to AutoIt!!!
I wanna know this befor making the wrappers, and find my self lost precious time!
Thanks for answering!