In preparation for the upcoming Raylib 6.0 gamejam, I planned to recreate a bunch of classic games. I wanted to recreate games exaclty, so that I could focus on the engineering and not the game design. When the gamejam comes around I expect my focus to be on the game design, so I thought it best to gain an intuition for engineering first.
The first game I decided on was Tetris because it seemed simple and different enough from asteroids. My intention was to build a classic game per day but Tetris ended up taking me 3 days to complete. I seem to consistently overestimate my ability, so that's something to keep in mind for the gamejam. I tried to implement Tetris as "from-scratch" as possible, using only the drawing functions from raylib. You can play it here.
I implement the grid as an array of unsigned integers with each integer representing a row of the grid and with every bit representing the value of a cell: filled or empty. I use bitwise operations to move the pieces around and detect collisions. I knew this was the right approach, and I suspect it is how the original Tetris would have been implemented. However, this approach was initially a little unintuitive to me.
I spent hours fumbling around, writing garbage and incorrect code until I solved the problem in 6 minutes with a pen and paper. I have accepted this as a rule of thumb: explanations precede code. If you get stuck with the code, take a deep breath, and pull out a piece of paper and pen; you probably have a conceptual problem which cannot be solved through writing more code.
I feel more confident about the gamejam with another game under my belt. I eagerly await to learn the theme!