How to Use Box2D Physics | Coding a 2D Game Engine in Java #48
Vložit
- čas přidán 20. 05. 2024
- Join the Discord: / discord
In this episode I go over various improvements to our physics abstraction over Box2D. This involves creating a callback method for collisions and game objects on the component level. There are 4 events that you can recieve information about, including beginCollision, endCollision, preSolve, and postSolve. I also go over how to implement raycasting using Box2D, creating sensors using Box2D, and a few more physics abstractions. Lastly, I improve the editor a bit more from the last episode by adding multi-select object highlighting, and allowing the user to click and drag and only place one object in each grid square.
Code: github.com/codingminecraft/Ma...
0:00 Intro
1:10 Highlighting Selected Game Objects
5:00 Fixing Duplicated Objects when Click/Dragging
11:39 Fixing Key Listener Bug
13:10 Box2D Contact Listener
15:51 Aside about Box2D User Data
19:16 Box2D Contact Listener Callbacks
25:08 Raycasting in Box2D
31:54 Various Box2D Helper Functions
37:05 Brief Note on Sensors
37:30 Back to Business
43:52 In the Next Episode
---------------------------------------------------------------------
Website: ambrosiogabe.github.io/
Github: github.com/ambrosiogabe
Here are some books I recommend if you want to learn about game engine development more thoroughly. I do not profit off any of these sales, these are just some books that have helped me out :)
My Recommended Game Engine Books:
Game Engine Architecture: www.gameenginebook.com/
Game Physics Cookbook (Read this before the next physics book): www.amazon.com/Game-Physics-C...
Game Physics (Ian Millington): www.amazon.com/Game-Physics-E...
Game Programming Patterns (Free): gameprogrammingpatterns.com/
My Recommended Beginning Game Programming Books:
JavaScript Game Design: www.apress.com/gp/book/978143...
My Recommended Java Books:
Data Structures/Algorithms: www.amazon.com/Data-Structure...
LWJGL (Free, but I haven't read this thoroughly): lwjglgamedev.gitbooks.io/3d-g...
Learned so much from these tutorials....thanks again Gabe.
No problem! I'm glad they're helping out :)
man i wish i was as good as you. i've made 3 games but i hit a ceiling everytime because i dont know how to do something and it's so frustrating
well you learn a lot while you do
Like ExTrem said you definitely learn a lot while you do. And I have plenty of ceilings that I hit too haha. The hard part is figuring out whether it's worth continuing to try and push past the ceiling or if the problem isn't worth it. Recently I tried to write a C++ parser and I spent about two months on it, and I just decided that it isn't worth continuing since I can just use somebody elses library. But, I still learned a ton from the experience :)
Gabe i have an important question , how i build a jar that runs without errors using gradle ?
I am a big fan of your work and
your videos are very helpful, i hope you can answer me.
Physics 🥰🥰🥰🥰🥰
i wish this came out like a year ago when i was making a 2d engine using Warmful development's tutorial which was pretty old and also had a lot of issues and not much explanation
I actually did start this series a year ago, but it only had a few episodes then haha. But I'm glad you found it now :)