CanSolak Personal Blog

A Small Sunday Game

Yesterday was the last day before the new spring semester. After breakfast, I suddenly realized that I have spare time after a long while. My friends were still not around in campus, so I started to looking for a little programming project to make my day more fun. Found a calm place with a nice view and sit. Then, Pygame came to my mind and jumped into implementing a small simple Tic-Tac-Toe game.

I had not used Pygame till yesterday but, thankfully, it is easy to learn and use. With the help of several Stack Overflow answers upon simple queries, I was able to finish a simple 3x3 demo implementation in a couple of hours. In here, I will briefly describe my implementation process. Hope this post can encourage you to implement small games too. First I started with implementing a slot class to model each cell in the game grid as you can see:
Then I go for a simple window and main game loop. You can see its final version as:
Finally, I implement a board class the handle rest of the functionality. There is only single point in implementation of Board class that I am not comfortable with, it is the check for winning condition. Here you can see my not so pleasing but quick implementation:
Overall, I enjoyed using Pygame much. Since implementing small simple games is a great way to practise programming, I am planning to have some other games and blog posts on them.
Thank you.

Please do not hesitate to provide feedback anytime.

See you on forthcoming posts.

Return to Homepage

Istanbul, 2018