GML physics engine
#1
Posted 08 May 2011 - 06:53 AM
I know for a fact that Extensions on iOS are impossible, since iOS doesn't support dynamic link libraries (for whatever reason). Since physic based games are pretty popular on iOS, and since that's something that a lot of us would like to use in mobile devices, there's a need, a gap if you will, for a decent physics engine that's GML based.
Sadly, I've never developed/dabbled in the mathematics required to do such a thing, nor do I know how GM would handle these computations.
So, my question/discussion topic is: why hasn't this been done properly ? Performance, lack of need for such a thing (until now), what?
I tried to look for stuff like this (and unearthed something that, adapted, could possibly be used for GML based physics), but there's nothing 'complete' or useful.
Any pointers?
#2
Posted 08 May 2011 - 08:05 AM
So, my question/discussion topic is: why hasn't this been done properly ? Performance, lack of need for such a thing (until now), what?
I don't think Katapeltis uses an DLL's or that:
http://www.yoyogames.com/games/149812-katapeltis
And sakisa did a fairly decent job on his physics engine, although you can definitely see it's a bit rough. Gameplay wise it's fine.
As to why it hasn't been 'done properly' well, it's just programming. If your going to make something, like sakisa did, for your game, then well and good. If you want it 'proper' then don't reinvent the wheel, use a DLL.
Edited by Desert Dog, 08 May 2011 - 08:06 AM.
#3
Posted 08 May 2011 - 08:39 AM
It uses GMPhysics DllI don't think Katapeltis uses an DLL's or that:
#4
Posted 08 May 2011 - 11:13 AM
Furthermore during all my work on those engines I often stumbled upon the problem of gamemaker's limited "fps", you need to build a system where object have a "velocity" and not based around points (especially important with small object flying through each other and handling collisions).
Those reasons make C++ (or any other language) a much neater choice, and programming within those language I found much more relaxing. The advantages of gamemaker were around 0, leaving you only with the disadvantages. Couple this with the fact that many people who CAN make a good physic simulation already got education for programming too (Programming is an often chosen extension to a physics course), and you get very little people interested into making this.
#5
Posted 08 May 2011 - 11:14 AM
The math isn't that hard - you just have to read up on basic particle physics, separating axis theorem, integration stuff and collision handling.
Read only what's for games, academic stuff will give you only headache.
GM-specific: you can avoid integration with delta time if your game won't have different FPS in each room. Don't store vectors as instances, that will make your game crawl. Do use inheritance though - you can make basic shapes and inherit them in other objects, thus adding them to the simulation.
And be prepared to have lots of ...x, ...y variables (scalar components of vectors) by using a comfortable naming system for both variables and the scalar components. Avoid long variable names and avoid unreadable variable names. Try to separate the component part from vector name in a visible way, like this: lvelX (linear velocity X). It will make writing vector code much easier.
And avoid working with angles. They are completely unnecessary in game physics and can make things only worse.
GL & HF.
#6
Posted 08 May 2011 - 11:42 AM
But it has been done properly -- within the constraints of GML, and also with Dlls. I've seen a few good examples of rigid body collisions and constraints made in GM.So, my question/discussion topic is: why hasn't this been done properly ? Performance, lack of need for such a thing (until now), what?
If you're interested in understanding how the mathematics works, it's worthwhile making some basic examples in GML yourself. The math isn't that difficult. But for lots of objects with complex interactions, GM isn't really the right tool. That's why you see various DLLs and extensions for this.
There's a topic in Advanced here dealing with this. Some of us have posted links to pages that describe the math involved. I recommend you have a look.
#7
Posted 08 May 2011 - 02:11 PM
http://www.jalb.me/?p=19
#8
Posted 08 May 2011 - 03:00 PM
Because if you DIY, your code is not compiled anyway, thus will be a lot slower than runner parts.
#9
Posted 08 May 2011 - 03:56 PM
#10
Posted 08 May 2011 - 04:04 PM
It's not slow in GM at all. What are you talking about? On my (modest) computer, your example will run at 580 frames/second.I'm also quite interested in creating physics with GML so I made a google search and I've found an article explaining how to create a simple physics example in game maker and C++. The example is quite simple and it gives a good explanation on how to do physics in GM without using any Dll. Also in GM this example is very slow.
http://www.jalb.me/?p=19
#11
Posted 08 May 2011 - 06:03 PM
It's not slow in GM at all. What are you talking about? On my (modest) computer, your example will run at 580 frames/second.
I'm also quite interested in creating physics with GML so I made a google search and I've found an article explaining how to create a simple physics example in game maker and C++. The example is quite simple and it gives a good explanation on how to do physics in GM without using any Dll. Also in GM this example is very slow.
http://www.jalb.me/?p=19
Comparing with other physics engines for GM it is slower
#12
Posted 08 May 2011 - 06:13 PM
Comparing with other physics engines for GM it is slower
And you base this on what tests? Let's see your data. Explain your method of testing, the equipment you are using to test this, etc.
#13
Posted 08 May 2011 - 07:01 PM
Even if that's true (and it probably is), your statement is misleading and it gives a false impression. Ultimately, these demos get clamped at 60 Hz anyway. So if the GM example runs at 500 Hz, and the C++ example runs at 1000 Hz, who cares? The point is that in many cases, GM is fast enough.Comparing with other physics engines for GM it is slower
It's not slow in GM at all. What are you talking about? On my (modest) computer, your example will run at 580 frames/second.
The example is quite simple and it gives a good explanation on how to do physics in GM without using any Dll. Also in GM this example is very slow.
http://www.jalb.me/?p=19
I'm not saying you can do everything you want in GM. But let's not give the impression you can't do anything worthwhile.
#14
Posted 08 May 2011 - 07:29 PM
Comparing with other physics engines for GM it is slower
And you base this on what tests? Let's see your data. Explain your method of testing, the equipment you are using to test this, etc.
We all know that C++ is extremely faster than GameMaker so this does not need explanation but anyway look at this:
http://postimage.org/image/2cbp7aoqs/ I made a test in my very slow pc and created 500 objects to GML physics example. The result: 6 fps
http://postimage.org/image/2cdrmhays/ Look the Extremephysics dll. It has 1602 simulated bodies running more faster then the previous one.
Also as has been said in the article C++ code of this example has one if statement and no loops while GM has a lot
#15
Posted 08 May 2011 - 09:13 PM
#16
Posted 08 May 2011 - 09:39 PM
That's often true. But xshortguy makes a good point about calling times.We all know that C++ is extremely faster than GameMaker so this does not need explanation but anyway look at this
<etc>
Either way, that's not interesting. I'd rather talk about coding techniques for various physics effects. I thought that's what this topic was about.
#17
Posted 08 May 2011 - 10:23 PM
But, I'm going to have to agree that gml is "fast enough" for realistic physics. Of course there are limits, but most actual games are likely not to pass the limits, with a few exceptions. Really, how many games really need to manage the physics of 500 blocks at a time?? I know demos do it, to show speed, and for comparison purposes, but how many games actually need to do it. I'm sure there are a few that do, but not that many.
Speaking of gml physics, are there any currently supported extension that do it with only gml?? I know several of the extension do it, but they have "hidden" dlls as part of the package, and wouldn't work with other platforms. But, extension with only gml should work on all of GM's available platforms. It would be interesting to have such an extension, if none exist, in order to re-use code.
#18
Posted 08 May 2011 - 10:31 PM
Also, beware people, many act like they know much about coding physics simulations but in fact, don't even know numerical integration (or how it's relevant).
#19
Posted 09 May 2011 - 03:29 AM
YYG really should have at least Box2D in the runner.
Yup, that would be ideal. However, until they do, something needs to be done.
I just wanted to add that the reason physics can get used on the iPhone(non GM games) is that they are compiled, often with physics libraries as part of the package. This is in a "normal" coding environment though, or often in something like Unity3d or Shiva, which also have physics engines integrated into their code.
The reason why there's so much physic based games on the iPhone is because the touch interface is ideal for this kind of stuff. And usually, people use Box2D when doing iPhone physics. It's in pretty much every single iOS game I've played.
But, I'm going to have to agree that gml is "fast enough" for realistic physics. Of course there are limits, but most actual games are likely not to pass the limits, with a few exceptions. Really, how many games really need to manage the physics of 500 blocks at a time?? I know demos do it, to show speed, and for comparison purposes, but how many games actually need to do it. I'm sure there are a few that do, but not that many.
When you actually start doing practical stuff a-la Angry Birds, compiled code can get pretty slow on pretty advanced mobile devices. A 400MHZ ARM11 processor has problems with Box2D.
I actually unearthed something pretty close to what I'm looking for. I'm going to try and adapt it and cook a little example of something "Physics-sy", it will be interesting how this works once we stop looking at simple bleak lines and start pushing full fledged objects and real graphics into the mix. Ideally, GM would include Box2D, but meanwhile this is a problem I percieve GM devs will start running into, when all the precious DLL's are removed and they have to switch to native GML code for stuff. Should be interesting.
#20
Posted 09 May 2011 - 04:59 AM
I honestly would be all for it. I'm starting to shy away from using any extensions that are dll based so that when GMStudio does come out, I won't have too much trouble getting used to the ways GM does things. For example, I'm no longer using my IrrKlang wrapper dll/extension. I'm instead using vanilla GM sound functions, because I know that when/if I decide to produce games for other platforms that aren't windows, I won't have to redo all of my sound code. I would think the same way for a physics API/library. It is getting to the point that if you want compatibility with all of the available platforms, you have to do it internal to GM, if nothing else for the reason that only windows can understand dlls. Other platforms have the alternatives(Mac with DyLibs for example), but it is much more difficult to create an alternative for each platform(and sometimes impossible if an API isn't multi-platform in the first place). But using GM's internal code, you should be guaranteed usage on all platforms(within speed limits among other things), so if an extension for physics exists(using only gml) then it would work on all platforms.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











