Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: 2D Physics Implementation #122

Open
1 of 9 tasks
Sammie156 opened this issue Oct 7, 2021 · 10 comments
Open
1 of 9 tasks

[Feature Request]: 2D Physics Implementation #122

Sammie156 opened this issue Oct 7, 2021 · 10 comments
Assignees
Labels
enhancement New feature or request

Comments

@Sammie156
Copy link
Contributor

Sammie156 commented Oct 7, 2021

Origins of the Feature

Well, most Game Engines or Frameworks have some basic Physics implementation, like collision detection, rigid bodies, gravity and some of those sorts. And I think adding these features will be very helpful shortly.

The New Feature Idea(s)

A Physics Engine within FastJ to have Physics Simulation. Something basic to start could be good, like Collision detection between sprites, and basic Rigid Bodies collision and impact and stuff.

This could be implemented with some other library like JBox2D or LiquidFun (though, LiquidFun is mostly for Soft Body simulation) libraries, or if possible, FastJ's own Physics Engine.

A video demonstration of a basic feature :

lZ62G9KBAG.mp4

This is a basic RigidBody simulation present in LiquidFun's Testbed.

Alternatives

In my opinion, there is no alternative for a Physics Engine 😅 !

However, to lower the pressure and the complexity and worriedness of this feature, because there are a lot of features yet to be implemented and improved, we can have this as a separate feature, which is just in the works. Maybe make a separate branch for it, work on it slowly. Also for the initiative, as I am opening this issue, I would love to work on this feature myself, if that's permissible 😅 !!

Code of Conduct

  • I agree to follow this project's Code of Conduct

Tasks needed to be achieved :

  • Adding Box2D as a Physics Library. (Later in the future, if possible, FastJ would have its Physics Engine)
  • Addition of Basic Physics Features :
  • Rigidbodies -> Sprites or GameObjects which are required to have Physics are Rigidbodies.
  • Gravity Implementation -> When in the air, GameObjects should fall to the ground, if Gravity is enabled.
  • Mass Implementation -> GameObjects with heavier mass would fall down faster, whereas lighter objects fall slower.
  • Force Generation -> Generating force which would make GameObjects move when any force is applied.
  • Collision Detection -> Basic Collision detection between two GameObjects.
  • Collision Impact -> When two bodies Collide, there is an impact on them and they move.

More features will be thought upon later.

@Sammie156 Sammie156 added the enhancement New feature or request label Oct 7, 2021
@Sammie156 Sammie156 assigned Sammie156 and unassigned Sammie156 Oct 7, 2021
@lucasstarsz
Copy link
Member

That is certainly a larger task to take on. If you are sure you'd like to head this task, feel free to do so! That being said, I'd like to see you edit your original comment to include the different tasks you'd like to complete. We'll continue from there.

@lucasstarsz
Copy link
Member

With how big of a project this would be, I don't see it being added in full to FastJ for another version or two. You've a lot of time to work on it as you like.

@Sammie156
Copy link
Contributor Author

Well, so I include the features as tasks in the original Comment?

@Sammie156
Copy link
Contributor Author

With how big of a project this would be, I don't see it being added in full to FastJ for another version or two. You've a lot of time to work on it as you like.

Well I know 😅 ! I know this, and I forgot to state that lets have it as a side project, and not make it tied to any specific version release of FastJ, so there is no worries or tension.

@lucasstarsz
Copy link
Member

Well, so I include the features as tasks in the original Comment?

Yes! We'll want to see you update these as you make progress on the system.

@lucasstarsz lucasstarsz changed the title [Feature Request]: 2D Physics Implementation for FastJ. [Feature Request]: 2D Physics Implementation Oct 9, 2021
@8BitAurum
Copy link
Contributor

Hi! I've been researching a bit and found a pure-java based physics engine called dyn4j. It is very well documented and has a lot of usage examples, so I feel that this might be easier to integrate into the engine, compared to JBox2D

@Sammie156
Copy link
Contributor Author

Hi! I've been researching a bit and found a pure-java based physics engine called dyn4j. It is very well documented and has a lot of usage examples, so I feel that this might be easier to integrate into the engine, compared to JBox2D

Looking into it, it seems like a really nice alternative for JBox2D. Thank you very much!

@8BitAurum
Copy link
Contributor

Hello @Sammie156, after trying out the engine for a bit, it seems that is isn't possible (or is very difficult) to get a physics object's position while the physics simulation is running... otherwise it is a very good physics engine. To work around it, we may have to find a way to directly calculate it or convert the getChangeInPosition() that it gives into pixels (using Pixels Per Meter ideology) for pixel coords.

@Sammie156
Copy link
Contributor Author

That is an interesting search! Thank you very much for doing this research!! Will look into working on this as soon as my table is cleared of other work!

@lucasstarsz
Copy link
Member

For now, I'm going to delete the physics branch. Physics will definitely still play a substantial role in FastJ's future -- however, incoming repository changes require that there are no other branches to directly consider, especially not ones that are months out of date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants