Vigyata.AI
Is this your channel?

CODE WITH ME | Python TETRIS Game OOP [PART 2]

16.0K views· 853 likes· 25:04· Aug 22, 2024

🛍️ Products Mentioned (3)

GitHub Repo: https://github.com/carmensantos/cs-jackie-tetris Checkout Setapp for the best MacOS and iOS apps: https://stpp.co/3MiKdK8 :) 🤓 about I’m a software engineer based in London with a background in mechanical and aerospace engineering. Most of my time is spent reading, coding and drinking too much coffee. I got into coding by automating simulation workflows and building EdgeSheet.com, and now I’m documenting my life as an engineer on the internet. Thanks for watching! :) 📝 chapters 0:00 intro 0:44 recap of part 1 2:21 collision detection between tile and board 6:31 setapp 7:38 merging tiles to the ground 9:39 locking tiles 13:28 collision detection between tile and ground 18:26 deleting completed rows and cascading tiles 24:30 code repo 📝 contact info@csjackie.com 🎵 music the music in my videos comes from: https://share.epidemicsound.com/5swi7a 👀 disclaimer Views and opinions are my own and do not represent or reflect the opinions of my current or past employer(s). This video is sponsored by Setapp! 🏷 hashtags & video content Software engineer, tetris game, python game, pygame, code with me, coding vlog, coding video, programming, software engineering, developing software, pandas, data structures and algorithms, tetris #tetris #pythonprogramming #softwareengineer

About This Video

In part 2 of my Python Tetris series, I wrap up the core game logic using object-oriented programming. I start with a quick recap of the classes from part 1 (Board, Tile, Shape, and the main Tetris game loop), and then I focus on the stuff that makes the game actually feel like Tetris: proper collision detection, a ground system, locking pieces, and clearing rows. I also made myself an iced coffee because it was a really hot day, which honestly felt very on brand for this debugging session. I build a dedicated CollisionDetector (with an enum-style set of collision types) so every move/rotation checks whether the next state would hit the board borders or the existing ground. Then I implement merging tiles into a Ground class, lock pieces when they collide at the bottom, and make sure you can’t keep sliding or rotating once a piece is placed. The final big chunk is row elimination: detecting completed rows, deleting them, cascading everything above down, and updating the score. There are a few “oh my God” moments while I debug coordinate direction and matrix updates, but by the end we can clear multiple rows and the score updates correctly. The full code is in the GitHub repo if you want to clone it and build on top of it.

Frequently Asked Questions

🎬 More from CS Jackie