How to Use Box2D Physics | Coding a 2D Game Engine in Java #48

Channel:
Subscribers:
59,400
Published on ● Video Link: https://www.youtube.com/watch?v=xQXOC74oeSU



Category:
Guide
Duration: 44:54
5,472 views
75


Join the Discord: https://discord.gg/4tHeAkxNg7

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: https://github.com/codingminecraft/MarioYoutube/tree/479f2d9d788146da120266f7900126792a67c36d

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: https://ambrosiogabe.github.io/
Github: https://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: https://www.gameenginebook.com/
Game Physics Cookbook (Read this before the next physics book): https://www.amazon.com/Game-Physics-Cookbook-Gabor-Szauer/dp/1787123669
Game Physics (Ian Millington): https://www.amazon.com/Game-Physics-Engine-Development-Commercial-Grade/dp/0123819768
Game Programming Patterns (Free): https://gameprogrammingpatterns.com/

My Recommended Beginning Game Programming Books:
JavaScript Game Design: https://www.apress.com/gp/book/9781430247166

My Recommended Java Books:
Data Structures/Algorithms: https://www.amazon.com/Data-Structures-Algorithms-Java-6th-ebook/dp/B00JDRQF8C
LWJGL (Free, but I haven't read this thoroughly): https://lwjglgamedev.gitbooks.io/3d-game-development-with-lwjgl/content/







Tags:
gameswithgabe
games with gabe
lwjgl3
box2d
box2d collision handler
box2d collisions
box2d raycasting
box2d collision callback
box2d fixtures
box2d sensors
coding a 2d game engine
physics
game scene in java
opengl fonts
game engine
how to make a level editor
how to code a game engine
imgui
lwjgl
java
mario