aod6060 / dsge

This is a simple 2D engine for my projects.
MIT License
1 stars 0 forks source link

Physics System #3

Open aod6060 opened 1 month ago

aod6060 commented 1 month ago

I've decided to use Box2D as my engines main physics/collision system because it look similar to BulletPhysics and simple to use. I've never release used it for anything so it will be fun getting it integrated into my little game engine.

aod6060 commented 1 month ago

Here is the introduction video and the initial plan for the physics system. physics_system_introduction_gh

aod6060 commented 2 weeks ago

Alright its time to get started on this issue.

aod6060 commented 2 weeks ago

Alright just got done with clean the main.cpp file so lets take a look at the documentation of Box2D

aod6060 commented 2 weeks ago

I'm debating of either switching to a different physics system. After reading through the documentation of Box2D and in the faqs section of the documentation page it states that box characters aren't well optimized for the tile maps and also it doesn't use pixel cords but meters which could be a problem.

I'm going to checkout Chipmunk which is a different physics engine that was created during the same time as Box2D. If I can't use that engine I'll just have to roll my own which is going to be a task in a half.

aod6060 commented 2 weeks ago

Ok, I took a look a chipmunk physics and it does have the ability to interact with tilemaps or should I say solids. I'm going to download chipmunk and test it. Just like Box2D its under the mit license.

aod6060 commented 2 weeks ago

Alright I'm going to do 2 branches to test both Box2D and Chipmunk Physics engines.

aod6060 commented 1 week ago

Instead of wasting time with youtube videos I'm going to focus on getting this project in a much more complete state. Basically getting this physics stuff implemented. That what I'm going to do for now before I make any more videos. I'll do my next video in December or January. I want to get to the point of working on the editors before make anymore videos.

aod6060 commented 1 week ago

Alright I'm done with the Box2D physics test. Needed to know how it works and I'm quite pleased with it. There are some interesting consequences of using said api because it uses meters not pixels as a measurement and I had to set a standard of what a meter is which in the test branch is every 32 pixels = 1 meter which makes since considering a tile in the engine will be 32x32 so a single tile would be 1x1 meters. The other thing is that the y-axis is inverted so I had to make a conversion method for the positions to account for that for example

p=<32, 32> m=convert_position(p) then m=<1, -1>

As for sizes I don't need to worry about negating the y because sizes are always positive numbers so therefore s=<32, 32> ms=convert_size(s) then ms=<1, 1>

This should sum up the math portion of the what I'll need to do if I'm going with Box2D as my physics system.

Now its time to test chipmunk to see what the difference is.

aod6060 commented 1 week ago

After reading through some of chipmunks documentation it apparently is a lot faster then Box2D which is a plus. Also I don't need to convert the measurements to meters which is also a plus. This means I can use pixel coords. I think. This is make Chipmunk into a really good contender compared to Box2D. Also it uses C language instead of C++ which is fine in my book. Lets get into the meat and potatoes of this api.

Here is the chipmunk physics website. https://chipmunk-physics.net Here is the chipmunk physics documentations https://chipmunk-physics.net/release/ChipmunkLatest-Docs/

I'm adding these in for documentation purposes.

aod6060 commented 1 week ago

Alright got it working tonight. Figured out that one the boxes are created in counter clock wise fasion so I'll need to account for that. Also the y-axis in chipmunk is inverted so I'll have to account for that when I get started on the actual physics system in the master branch of the code.

aod6060 commented 1 week ago

Alright I've made my decision of which physics engine I'll be using for this project for now. And its going to be... Chipmunk! The reason why I've made this decision is because I don't need to change my units. The problem I have with Box2D is that its uses meters instead of just simple pixels units. Now Chipmunk has its own issues but those are out weigh by the advantages. So tonight I'm going to remove Box2D and add in Chipmunk. I'll most likely take a look at Box2D in the future but for now Chipmunk will be used instead.

aod6060 commented 6 days ago

Alright I'm thinking I'm at the point were I can pause this issue for a bit and move on to something else for a bit. I'm going to go back to the app, input, and add a new issue called config which will allow to configure the game engine during runtime which is going to be cool plus I'll be needing a gui system that is used with in the game because ImGui isn't going to the job after all ImGui is used to create editors and example guis but isn't meant for an end user gui.