As part of our portfolio class, we're supposed to take a bunch of projects from previous classes and refine them over the term. One of my chosen projects incorporated elements from Tetris as part of its gameplay loop. I'm trying to refine that section (and cut out the other which was... less successful). Originally, 3D pieces based on children's wood blocks would fall and it was up to you to stack them in a way that constructed a path for you to drive across (sort of like Tetris x Bridge Builder). I've decided that I want to take the controls and blocks from the project and make a physics-based version of Tetris.
I'm hoping I can emulate the same row-deletion mechanic in Tetris, but with these irregular blocks, which presents two main challenges (that I've though of so far).
How to define a row as "completed" when there'll be small gaps everywhere
How to delete a horizontal row of blocks - which involves splitting them dynamically
While finding an elegant solution for (1) might be difficult, I can think of a very simple brute-force method, and so I've decided to focus on issue (2) as it's the non-trivial one. I've always been curious as to how other games have done this (principally Metal Gear Rising: Revengeance) and so might have also gone in this direction to sate my curiosity.
I found this tutorial titled "How to Dynamically Slice a Convex Shape", and it outlines the basic logic of how to split up a triangle (which is the building block for any 3D object). After getting my head around the concept, I drew out the basics of how I would approach the solution on a nice, big whiteboard (being on college campus has its benefits!). I try not to copy/paste stuff - I like knowing that all the work in projects I do is original (even if the ideas aren't).
I set up a basic scene in Unity to test my code - just a plane and a quad, and used Debug.Draw calls to "sketch out" the new shapes generated by my algorithm.
From here, the next step is to translate the sketched-out lines into real geometry. We'll see how that goes next week! (Spoiler: I accidentally break the default quad in Unity)
Comentários