Vigyata.AI
Is this your channel?

CODE WITH ME | Tic-Tac-Toe Game in Python *beginner friendly*

91.0K views· 2,991 likes· 21:12· Apr 18, 2024

🛍️ Products Mentioned (3)

Hope you enjoy this coding video :) checkout Riverside.fm for AI based video and audio editing, use discount code *CSJackie* https://creators.riverside.fm/csjackie :) GitHub Repo: https://github.com/carmensantos/tic-tac-toe 🤓 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 game setup 0:50 game logic and data structures 1:56 riverside.fm editor 4:25 import grid and game board matrix 7:50 coding the player turn logic 11:35 render knot and cross icons 14:15 coding the victory logic 19:25 rendering text on screen 20:49 outro 📝 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 Riverside.fm. 🏷 hashtags & video content Software engineer, tic tac toe game, python game, pygame, code with me, coding vlog, coding video, programming, software engineering, developing software, pandas, data structures and algorithms #codewithme #pythonprogramming #softwareengineer

About This Video

In this beginner-friendly Code With Me, I build a classic Tic-Tac-Toe game in Python using Pygame. I start from the very basics: setting up the window, creating the 3x3 grid, and thinking through what the game actually needs—clear grid lines, the knot/circle and cross icons, mouse-click input, and win detection. I also explain why a 3x3 matrix is a really clean way to represent the board, and how I fill it with 0s and 1s depending on which player places a mark. From there, I code the turn logic by reading the mouse position, normalizing it to the size of each square (yes, I initially made the classic mistake of dividing by the full window width), and mapping clicks to row/column indices. Then I render the icons by looping through the matrix and drawing the right image in the right cell. Finally, I implement victory checks across rows, columns, and diagonals, and display a simple winner message on screen. There are definitely more improvements you could add, but I leave that part to you—feel free to clone the GitHub repo and play around with it.

Frequently Asked Questions

🎬 More from CS Jackie