This is a simple Mastermind game done entirely in Python, using Pygame for the graphics library. The part of this I’m most proud of is that the entire thing is drawn through code as vector graphics, using nothing but lines, boxes, and circles. No sprites or graphics tools were used at all, and the rotating shapes are all generated mathematically. I wanted to end up with a sort of sci-fi radar look, which I think came out pretty well.
For those unfamiliar, Mastermind is a game in which you have 4 “pins” of different colors, and 8 rows used to make 8 guesses at a master sequence of pins. Every time you fill out a row, you are told how many pins you positioned with the right color in the right spot, and how many pins are the right color but in the wrong position. If you don’t figure out the sequence in 8 tries, you lose.
In this case I used geometric shapes in addition to colors to make it more visually interesting, and solid or hollow circles as ‘right color/right position’ and ‘right color/wrong position’ respectively. The cursor (seen as a red blinking box) advances automatically as the user picks and enters a shape for that box. The hint circles appear when a row is completed.
Click on the animated image to see a larger version, and see the source code below.
SOURCE CODE LINK