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

Published: 29 May 2021
on channel: GamesWithGabe
7,634
92

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: https://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: 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-C...
Game Physics (Ian Millington): https://www.amazon.com/Game-Physics-E...
Game Programming Patterns (Free): https://gameprogrammingpatterns.com/

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

My Recommended Java Books:
Data Structures/Algorithms: https://www.amazon.com/Data-Structure...
LWJGL (Free, but I haven't read this thoroughly): https://lwjglgamedev.gitbooks.io/3d-g...


Watch video How to Use Box2D Physics | Coding a 2D Game Engine in Java #48 online without registration, duration hours minute second in high quality. This video was added by user GamesWithGabe 29 May 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 7,634 once and liked it 92 people.