[C++] Debugging/Problem-Solving/Implementing a Collision problem using an Unknown Game API!

Channel:
Subscribers:
202
Published on ● Video Link: https://www.youtube.com/watch?v=hecHLILVCB0



Duration: 4:45:20
22 views
0


0:00 Game Engine Exploration/Analysis
12:18 Exploring the broken collision implementation
33:00 Bounds and coordinate system
45:00 Understanding overlap
57:07 Multiple Collision Bugs
1:23:30 Fixing the bounds not updating
1:29:45 Refactoring collision mask code. A function that "does too much"
1:39:38 Cool Feature :D
1:48:46 Fixing the Snapping to edges
1:56:50 Coming up with a new game plan for horizontal and vertical resolution
2:04:32 Source Control is important! Let's commit. We made important progress. Setting up github repo.
2:10:32 First attempt at XY collision handling
2:31:33 Figuring out a new way to detect edges.
2:33:47 Time for trig!
2:50:41 45 degrees doesn't work... Applying new ideas
2:53:46 More Trig!
3:11:00 Debugging our new implementation
3:22:02 Still not right
3:27:13 Third collision strategy
3:32:02 Begin the implementation once again
3:51:00 Rect vs Rect collision implementation
4:01:07 Debugging new line intersection code
4:07:20 Almost there! Now for the finale.
4:14:00 We're so close, something's still wrong...
4:20:25 Is everything right...?
4:23:20 GDI
4:24:00 IT'S DONE!
4:25:00 Just resolve the bottom screen edge bug
4:32:30 Analysis of edge collisions
4:43:52 And we're done!!


Yesterday I met a programmer working on a project and needing assistance with collision debugging. Game collisions can be very tricky to resolve perfectly, and thus we were put to the test with figuring out this project.

This video demonstrates the entire resolution problem-solving process required to deal with programming problems. I've had a few demonstrations of this on-stream, but I finally believe I've captured footage that really shows the process in a powerful light. Follow along and observe how we get from a completely malfunctioning collision detection system to a full working one! Being a successful programmer requires you to be able to debug and find the issues, use the tools at your disposal to test and eliminate problems, and come up with a solid plan of attack to implement your solution!

This is an unknown Game API and so the first thing to do when looking through a new codebase is to, well, get familiar with it! We spend quite a bit of time exploring what all the different variables and systems look like.

The next step is to begin isolating the problem. Very early on, I inserted a condition to block out all object updates until I press a key. A very helpful technique to step "frame-by-frame" in a game as you can inspect variables in a more controlled environment.

We begin inspecting basic aspects of the code, seeing what the current collision implementation looked like and working our way down the code to try and understand the initial intentions. It was definitely clear what the programmer wanted, but the implementation was very confusing and needed clarity.

As we started diving deeper into the debugging we started analyzing options and coming up with a plan to recreate the collision so it handles properly, knowing full well what we want to accomplish with a goal in mind. There were quite a few challenges with this engine, we had to learn to re-orient our thinking for how the max and minimum coordinates were made, and the +Y coordinates going up instead of down.

Drawing and sketching out scenarios is very very helpful when planning out your code! It wraps the pseudo-code in your head visually and you get to see how your variables are supposed to interact with each other.

During the implementation phase we would discover other faults with the game's engine, specifically with updating collision bodies. It's very important that the engine is working as intended, so with a quick refactor the collision bodies are now usable to us and are no longer lagging behind the actual object.

Near the end of the session we had to re-evaluate our plan as we realized a major flaw. During designs you don't anticipate every edge case and scenario. Going back to the drawing board and coming up with a new plan, we proceeded to the implementation once again.

Things got more complicated as we had to use some trigonometry to resolve the directional aspects of our collision, but we came up with another solid plan and implemented it through code. After finishing we just cleaned up some last minute problems with the screen boundary collisions and it was good to ship! (Well, the original problem resolved) -- Watch live at https://www.twitch.tv/sigonitori







Tags:
API
C++
Debugging
Problem-Solving
Programming
challenge
collision
development
dynamic
game
games
helping
livestream
resolution
static
step-by-step process
successful programming
testing
twitch
unknown