All of the blocks are actors, and I have a variable indicating is type: cross block, T block, etc., and its rotation (I know it starts rotation, and all of them rotate clockwise).
Just to clarify, what we see is the only solution to this very puzzle? Any other combination would count as a fail? Is there an instant fail mechanism if we place any of the blocks (including the yellow piece) incorrectly?
One more. We’re not making just this puzzle, right? You’re going to have many different puzzles for the player to assemble, surely.
more blocks?
more complex shapes?
fall order is always fixed?
if I place the blue block upside down, it’s still a valid solution?
I can think of half a dozen ways to detect it but there simply is not enough info here to suggest a method since we know so little. How you put this puzzle together would also dictate the way to script the detection mechanism.
Without knowing all the details, the most agnostic approach could be a generic combination of tracing & tags.
a puzzle piece is made of many blocks (I assume, again)
each block is an extended SMC
a block has a correct orientation (more than one is OK), set at design time per puzzle
a block has a tag and is looking for another tag (or use enumeration), set at design time per puzzle
when blocks stops moving, For Each Loop with Break (blocks inside the puzzle piece) trace in the direction of correct orientation, query a tag of the hit component
if distance is small and a matching tag has been found, the block placement is correct, then keep checking other blocks
else, it’s fail, break the loop
Considering the above, the red piece could be set like so to work in this puzzle:
And then build the actor puzzle pieces out of those blocks:
All of them are a single actor made of static meshes
As mentioned above, consider the extended SMCs so you can script logic directly into the blocks. Makes life so much easier.
When one of the blocks only has two meshes visible, I hide the other two.
I would not go this way. It’s a waste of resources, maintenance nightmare and unnecessarily obfuscates things, imho. Make a base class with shared functionality, methods and variables, and a bunch of children with extra blocks.
I have followed this tutorial series to implement the Tetris game:
So you did not really come here to ask for a solution. You’re asking for the solution that would work with that one tutorial? In this case I’m going to tap out. Can’t justify a time investment of understanding how a tutorial works. The tut may not even be feasible for what you need, who knows.
However, since you do know how the tut works, consider my suggestion and see if you can incorporate it.
I’ve shared the tutorial to give you more details about the implementation. Read again the first post and you will see there is no mention about the tutorial. I have mentioned at the third post, when you still had more questions about the IMPLEMENTATION.
Read again the first post and you will see there is no mention about the tutorial.
I think you should have led with it, tbh. But you do want it to work with the tut. It IS about a specific tutorial since you want the system to work with what you’ve followed and already have, right? Nothing wrong with that. Do tell how it goes once you’ve implemented it.
There’s surely more ways of pulling it off. Perhaps someone else will share.
Set some way to ID each block based on its color and since you know exactly the blocks each line has, it’s just a question of applying a simple 2d pattern search to check if the “solution pattern” exists.
You could multitrace from top to bottom, straight through the entire column to see if a matching, previously established sequence is found. Since we already know the solution, this should be trivial to set up. The solution to the first column is R,B,B,Y, Empty. Again, pretty agnostic of whatever method is used to make it. You could even use component tags.
I was thinking about this solution, but I have doubts about how to implement it. I’ve been thinking to use a 2D vector to store where the blocks are, and then use a 2D pattern to look for it by going through the entire matrix.
This seemed too costly to me, so I’ve asked this question if other more experienced programmers have better solutions.
Tetris is basically a game about managing an array. The blocks can be considered as visual representations of the values in given index. This way it boils down to managing these values. This includes placing, moving, and rotating the blocks (values) within the array.
To your question: this way looping a specific range in a 2d array to compare against another should be straightforward. Also more puzzles could be easily added and iterated uppon.