Here’s the source code for a Bejeweled clone called Gemgem, written in Python with the Pygame library. You’ll need Python (2 or 3) and Pygame installed to run it. I’ve tried to keep the source code simple so it’s easy to follow and learn programming and Pygame from it. It comes in under 540 lines of code, including whitespace & comments.
Download the Gemgem source code and graphics.
To play, click on (or drag over) two adjacent gems to swap their position. You need to swap them so that there are three or more gems of the same type in a row. This causes the gems to disappear and new gems to fall in their place. You get more points for chain reactions or more-than-three matches. The score constantly trickles down, so solve as fast as possible. The game ends when no more moves can be made.
The backspace key will reset the board, the escape key quits.
The graphics were from Osmic on opengameart.org
Here’s a Sokoban (“box pusher”) clone called Star Pusher. I’ve used the graphics from the Planet Cute collection. You’ll need Python (2 or 3) and Pygame installed to run it. Just download and unzip the files to the same directory. It comes with 201 levels from David W. Skinner.
Download the source code and graphics.
(UPDATE: I’ve updated the code so that it works on Linux. It was due to a \r\n newline issue. I’ve tested the game in Ubuntu and it works.)
The source code is designed to be readable so that new programmers can understand and modify it without much effort.
I’ve made a Connect Four AI. There is a text-only version and a graphical version made with Pygame. You will need Python 3 (not Python 2) to play the games (and Pygame for the graphical version.)
In the graphical version, drag the red tokens over the top of the board to make a move.
Source Code and image files zipped.
fourinarow.py (text version, doesn’t need Pygame)
gFourinarow.py (graphical version, needs image files)
Black token image, Red token image, Board image